diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 8c0ec3df78..2533c78f03 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -1,14 +1,9 @@ -const {getESLintConfig} = require('ocular-dev-tools/configuration'); +const {getESLintConfig} = require('@vis.gl/dev-tools/configuration'); // Make any changes to default config here module.exports = getESLintConfig({ overrides: { - parser: '', - parserOptions: { - project: ['./tsconfig.json'] - }, - - plugins: ['tree-shaking','import'], + plugins: ['tree-shaking'], env: { browser: true, @@ -17,38 +12,30 @@ module.exports = getESLintConfig({ }, rules: { - // Definitely disable - 'no-use-before-define': 0, // disabled after ocular upgrade to unbreak build 'prefer-rest-params': 'warn', 'import/named': 'off', - 'no-shadow': 'warn', - '@typescript-eslint/no-explicit-any': 'off', // 'warn', - // desiabled by choice + // disabled by choice 'no-unused-expressions': 'warn', - 'no-console': 1, - 'no-continue': ['warn'], + 'no-console': 'warn', + 'no-continue': 'warn', 'callback-return': 0, 'accessor-pairs': 0, 'max-depth': ['warn', 4], - camelcase: 'off', - complexity: 'off', - 'max-statements': 'off', - 'default-case': ['warn'], - 'no-eq-null': ['warn'], - eqeqeq: ['warn'], + camelcase: 0, + complexity: 0, + 'max-statements': 0, + 'default-case': 'warn', radix: 0, - 'spaced-comment': ["error", "always", { "exceptions": ["/ <"] }] - // 'accessor-pairs': ['error', {getWithoutSet: false, setWithoutGet: false}] + // handled by prettier + quotes: 0, + indent: 0 }, overrides: [ { files: ['**/*.ts', '**/*.tsx', '**/*.d.ts'], rules: { - 'quotes': 0, // handled by prettier - 'indent': 0, // handled by prettier - '@typescript-eslint/no-explicit-any': 'off', // 'warn', // typescript-eslint 6.0 '@typescript-eslint/no-unsafe-argument': 0, @@ -61,9 +48,6 @@ module.exports = getESLintConfig({ 'consistent-return': 0, // We use typescript noImplicitReturn 'default-case': 0, // We rely on typescript - 'import/no-unresolved': 'error', - 'import/no-extraneous-dependencies': 'error', - 'no-unused-expressions': 'warn', '@typescript-eslint/no-empty-function': 0, '@typescript-eslint/no-misused-promises': 0, '@typescript-eslint/no-floating-promises': 0, @@ -80,16 +64,6 @@ module.exports = getESLintConfig({ 'warn', {vars: 'all', args: 'none', ignoreRestSiblings: false} ], - // Warn instead of error - // 'max-params': ['warn'], - // 'no-undef': ['warn'], - // camelcase: ['warn'], - // '@typescript-eslint/no-floating-promises': ['warn'], - // '@typescript-eslint/await-thenable': ['warn'], - // '@typescript-eslint/no-misused-promises': ['warn'], - // '@typescript-eslint/no-empty-function': ['warn', {allow: ['arrowFunctions']}], - // We use function hoisting - '@typescript-eslint/no-use-before-define': 0, // We always want explicit typing, e.g `field: string = ''` '@typescript-eslint/no-inferrable-types': 0, '@typescript-eslint/restrict-template-expressions': 0, @@ -97,8 +71,7 @@ module.exports = getESLintConfig({ '@typescript-eslint/require-await': 0, '@typescript-eslint/no-unsafe-return': 0, '@typescript-eslint/no-unsafe-call': 0, - '@typescript-eslint/no-empty-interface': 0, - '@typescript-eslint/restrict-plus-operands': 0 + '@typescript-eslint/no-empty-interface': 0 } }, // tests are run with aliases set up in node and webpack. diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a4fa51aee1..a212d98f34 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,8 +22,9 @@ jobs: id: permitted run: | result= - branchName=$(git branch -a --contains $GITHUB_SHA | grep 'remotes/origin/' || echo "") - if [[ $branchName == *"master" || $branchName == *"-release" ]]; then + if git branch -a --contains $GITHUB_SHA | grep -q 'remotes/origin/master$'; then + result=true + elif git branch -a --contains $GITHUB_SHA | grep -q 'remotes/origin/.*-release$'; then result=true fi echo "result=${result}" >> "$GITHUB_OUTPUT" @@ -42,26 +43,21 @@ jobs: steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - uses: volta-cli/action@2d68418f32546fd191eb666e232b321d5726484d # v4.1.1 with: cache: 'yarn' - - name: Create GitHub release entry - run: | - body=$(node scripts/github-release.js) && - curl \ - -X POST \ - -H "Accept: application/vnd.github.v3+json" \ - https://api.github.com/repos/visgl/luma.gl/releases \ - -d "${body}" \ - -H "Authorization: token ${GITHUB_TOKEN}" + - name: Install dependencies + run: yarn + + - name: Build packages + run: npm run build + + - name: Run tests from transpiled code + run: npx ocular-test dist - name: Login to NPM run: npm config set "//registry.npmjs.org/:_authToken=${NPM_ACCESS_TOKEN}" - - name: Install dependencies - run: yarn - - name: Publish to NPM run: npx ocular-publish from-git diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bd7375c719..da16f98068 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -34,11 +34,11 @@ jobs: - name: Run tests in Puppeteer and generage Coverage run: | - yarn test-cover + yarn test cover - name: Run tests on Node run: | - yarn test-node + yarn test node - name: Run lint run: | diff --git a/.github/workflows/website.yml b/.github/workflows/website.yml index ef473c2bb4..0315fe2100 100644 --- a/.github/workflows/website.yml +++ b/.github/workflows/website.yml @@ -12,10 +12,14 @@ jobs: should_deploy: ${{ endsWith(github.ref, steps.get_version.outputs.latest) }} steps: + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - name: Get version id: get_version run: | - LATEST=$(npm show @luma.gl/core@latest version | grep -o -E "^[0-9]+\.[0-9]+") + packageFile=$(if [ -d modules ]; then ls modules/*/package.json | head -n 1; else echo package.json; fi) + packageName=$(jq -r '.name' $packageFile) + LATEST=$(npm show "${packageName}@latest" version | grep -o -E "^[0-9]+\.[0-9]+") echo "latest=${LATEST}-release" >> "$GITHUB_OUTPUT" deploy: @@ -31,7 +35,6 @@ jobs: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 with: token: ${{ secrets.WEBSITE_DEPLOY_TOKEN }} - - uses: volta-cli/action@2d68418f32546fd191eb666e232b321d5726484d # v4.1.1 with: cache: 'yarn' @@ -49,5 +52,5 @@ jobs: with: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} BRANCH: gh-pages - FOLDER: website/public + FOLDER: website/build CLEAN: true diff --git a/.ocularrc.js b/.ocularrc.js index 53050bc7c6..a91f5024bd 100644 --- a/.ocularrc.js +++ b/.ocularrc.js @@ -9,17 +9,12 @@ const testDir = join(packageRoot, 'test'); /** @type {OcularConfig} */ const config = { - babel: false, lint: { - paths: ['modules', 'docs', 'test'], // 'examples'], module resolution errors + paths: ['modules', 'test'], // 'docs', 'examples'], module resolution errors extensions: ['js', 'ts', 'jsx', 'tsx'] }, - typescript: { - project: 'tsconfig.build.json' - }, - aliases: { // DEV MODULES 'dev-modules': devModules, @@ -44,7 +39,7 @@ const config = { entry: { test: 'test/index.ts', - 'test-browser': 'index.html', + 'test-browser': 'test/index.html', bench: 'test/bench/index.js', 'bench-browser': 'test/bench/index.html', size: 'test/size/import-nothing.js' diff --git a/modules/constants/tsconfig.json b/modules/constants/tsconfig.json index d957750e3d..bd0887e7f4 100644 --- a/modules/constants/tsconfig.json +++ b/modules/constants/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../../tsconfig.module.json", + "extends": "../../tsconfig.json", "include": ["src/**/*"], "exclude": ["node_modules"], "compilerOptions": { diff --git a/modules/core/tsconfig.json b/modules/core/tsconfig.json index b6fd1b1d70..3cc1dfaf02 100644 --- a/modules/core/tsconfig.json +++ b/modules/core/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../../tsconfig.module.json", + "extends": "../../tsconfig.json", "include": ["src/**/*"], "exclude": ["node_modules"], "compilerOptions": { diff --git a/modules/engine/src/passes/shader-pass-renderer.ts b/modules/engine/src/passes/shader-pass-renderer.ts index d0014ffed1..2ddeba1de5 100644 --- a/modules/engine/src/passes/shader-pass-renderer.ts +++ b/modules/engine/src/passes/shader-pass-renderer.ts @@ -155,11 +155,10 @@ void main() { } first = false; - // eslint-disable-next-line no-shadow - const sourceTexture = this.swapFramebuffers.current.colorAttachments[0].texture; + const swapBufferTexture = this.swapFramebuffers.current.colorAttachments[0].texture; const bindings = { - sourceTexture + sourceTexture: swapBufferTexture // texSize: [sourceTextures.width, sourceTextures.height] }; diff --git a/modules/engine/tsconfig.json b/modules/engine/tsconfig.json index 7fc2c79c33..dcee5c9b95 100644 --- a/modules/engine/tsconfig.json +++ b/modules/engine/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../../tsconfig.module.json", + "extends": "../../tsconfig.json", "include": ["src/**/*"], "exclude": ["node_modules"], "compilerOptions": { diff --git a/modules/gltf/test/gltf/gltf.spec.ts b/modules/gltf/test/gltf/gltf.spec.ts index d8b156f7bf..b1ce8dc010 100644 --- a/modules/gltf/test/gltf/gltf.spec.ts +++ b/modules/gltf/test/gltf/gltf.spec.ts @@ -10,8 +10,9 @@ import {createScenegraphsFromGLTF, loadPBREnvironment} from '@luma.gl/gltf'; test('gltf#loading', async t => { const webglDevice = await getWebGLTestDevice(); + // path is relative to /test/index.html + const gltf = await load('data/box.glb', GLTFLoader); - const gltf = await load('test/data/box.glb', GLTFLoader); const processedGLTF = gltf.json ? postProcessGLTF(gltf) : gltf; const result = createScenegraphsFromGLTF(webglDevice, processedGLTF); @@ -27,7 +28,7 @@ test('gltf#loading', async t => { test('gltf#animator', async t => { const webglDevice = await getWebGLTestDevice(); - const gltf = await load('test/data/BoxAnimated.glb', GLTFLoader); + const gltf = await load('data/BoxAnimated.glb', GLTFLoader); const processedGLTF = gltf.json ? postProcessGLTF(gltf) : gltf; const {scenes, animator} = createScenegraphsFromGLTF(webglDevice, processedGLTF); @@ -52,7 +53,7 @@ test.skip('gltf#environment', async t => { const webglDevice = await getWebGLTestDevice(); const environment = loadPBREnvironment(webglDevice, { - brdfLutUrl: 'test/data/webgl-logo-0.png', + brdfLutUrl: 'data/webgl-logo-0.png', getTexUrl: (type, dir, mipLevel) => `test/data/webgl-logo-${mipLevel}.png`, specularMipLevels: 9 }); diff --git a/modules/gltf/tsconfig.json b/modules/gltf/tsconfig.json index e3653c6591..01c66bd9e2 100644 --- a/modules/gltf/tsconfig.json +++ b/modules/gltf/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../../tsconfig.module.json", + "extends": "../../tsconfig.json", "include": ["src/**/*"], "exclude": ["node_modules"], "compilerOptions": { diff --git a/modules/shadertools/tsconfig.json b/modules/shadertools/tsconfig.json index 3bf1b33ff9..53071d8396 100644 --- a/modules/shadertools/tsconfig.json +++ b/modules/shadertools/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../../tsconfig.module.json", + "extends": "../../tsconfig.json", "include": ["src/**/*"], "exclude": ["node_modules", "test"], "compilerOptions": { diff --git a/modules/test-utils/tsconfig.json b/modules/test-utils/tsconfig.json index 51247a5f16..9fd415ee12 100644 --- a/modules/test-utils/tsconfig.json +++ b/modules/test-utils/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../../tsconfig.module.json", + "extends": "../../tsconfig.json", "include": ["src/**/*"], "exclude": ["node_modules"], "compilerOptions": { diff --git a/modules/webgl/src/context/parameters/webgl-parameter-tables.ts b/modules/webgl/src/context/parameters/webgl-parameter-tables.ts index 3b2512a049..01a6a40917 100644 --- a/modules/webgl/src/context/parameters/webgl-parameter-tables.ts +++ b/modules/webgl/src/context/parameters/webgl-parameter-tables.ts @@ -412,9 +412,9 @@ export const GL_HOOKED_SETTERS = { update({ [pname]: value }), - hint: (update: UpdateFunc, pname: GL, hint: GL) => + hint: (update: UpdateFunc, pname: GL, value: GL) => update({ - [pname]: hint + [pname]: value }), // SPECIFIC SETTERS diff --git a/modules/webgl/tsconfig.json b/modules/webgl/tsconfig.json index efd7408788..027e162d56 100644 --- a/modules/webgl/tsconfig.json +++ b/modules/webgl/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../../tsconfig.module.json", + "extends": "../../tsconfig.json", "include": ["src/**/*"], "exclude": ["node_modules"], "compilerOptions": { diff --git a/modules/webgpu/tsconfig.json b/modules/webgpu/tsconfig.json index 7073d8496f..8123ccb2e1 100644 --- a/modules/webgpu/tsconfig.json +++ b/modules/webgpu/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../../tsconfig.module.json", + "extends": "../../tsconfig.json", "include": ["src/**/*"], "exclude": ["node_modules"], "compilerOptions": { diff --git a/package.json b/package.json index c364d61517..75c750609f 100644 --- a/package.json +++ b/package.json @@ -21,27 +21,15 @@ "fs": false }, "scripts": { - "bootstrap": "ocular-bootstrap", - "postinstall": "echo postinstall", + "bootstrap": "yarn && ocular-bootstrap && yarn build", "start": "open https://luma.gl/docs/getting-started", - "clean": "ocular-clean", "build": "ocular-clean && (cd modules/constants && yarn pre-build) && ocular-build", - "cover": "ocular-test cover", "lint": "ocular-lint", "publish-beta": "ocular-publish version-only-beta", "publish-prod": "ocular-publish version-only-prod", - "version": "node scripts/verify-changelog.js && git add CHANGELOG.md", "test": "ocular-test", - "test-ci": "ocular-lint && ocular-test node && ocular-test cover", - "test-node": "ocular-test node", - "test-cover": "ocular-test cover", - "test-fast": "ocular-test fast", - "test-browser": "ocular-test browser", - "test-browser-headless": "ocular-test browser-headless | tap-spec", + "test-fast": "ocular-lint && ocular-test node", "test-website": "cd website && yarn && yarn build && cd ..", - "perf": "ocular-test perf-browser", - "bench": "ocular-test bench", - "bench-browser": "ocular-test bench-browser", "metrics": "./scripts/metrics.sh && ocular-metrics" }, "devDependencies": { @@ -53,13 +41,13 @@ "@probe.gl/stats-widget": "^4.0.8", "@probe.gl/test-utils": "^4.0.8", "@types/tape-promise": "^4.0.1 ", + "@vis.gl/dev-tools": "1.0.0-alpha.19", + "@vis.gl/ts-plugins": "1.0.0-alpha.19", "eslint-plugin-tree-shaking": "^1.9.2", "nyc": "^15.1.0", - "ocular-dev-tools": "2.0.0-alpha.34", "pre-commit": "^1.2.2", "pre-push": "^0.1.1", - "puppeteer": "^22.0.0", - "tap-spec": "^5.0.0" + "puppeteer": "^22.0.0" }, "resolutions": { "typescript": "^5.5.0", diff --git a/scripts/bundle.config.js b/scripts/bundle.config.js deleted file mode 100644 index f791c3e6d1..0000000000 --- a/scripts/bundle.config.js +++ /dev/null @@ -1,133 +0,0 @@ -const {getOcularConfig} = require('ocular-dev-tools'); -const {resolve} = require('path'); -const webpack = require('webpack'); - -const ALIASES = getOcularConfig({ - aliasMode: 'src', - root: resolve(__dirname, '..') -}).aliases; - -const PACKAGE_ROOT = resolve('.'); -const PACKAGE_INFO = require(resolve(PACKAGE_ROOT, 'package.json')); - -/** - * peerDependencies are excluded using `externals` - * https://webpack.js.org/configuration/externals/ - * e.g. @deck.gl/core is not bundled with @deck.gl/geo-layers - */ -function getExternals(packageInfo) { - const externals = { - // Hard coded externals - }; - - const {peerDependencies = {}, browser} = packageInfo; - - Object.assign(externals, browser); - - for (const depName in peerDependencies) { - if (depName.startsWith('@luma.gl')) { - // Instead of bundling the dependency, import from the global `deck` object - externals[depName] = 'luma'; - } - } - - return externals; -} - -const NODE = { - Buffer: false, - fs: 'empty', - http: 'empty', - https: 'empty', - path: 'empty', - crypto: 'empty' -}; - -const ES5_BABEL_CONFIG = { - presets: [ - '@babel/preset-typescript', - ['@babel/preset-env', {forceAllTransforms: true}] - ], - plugins: [ - // webpack 4 cannot parse the most recent JS syntax - '@babel/plugin-proposal-optional-chaining', - '@babel/plugin-proposal-nullish-coalescing-operator', - // typescript supports class properties - '@babel/plugin-proposal-class-properties', - // inject __VERSION__ from package.json - 'version-inline', - ["@babel/plugin-transform-modules-commonjs", { allowTopLevelThis: true }], - // 'inline-webgl-constants', - ['remove-glsl-comments', {patterns: ['**/*.glsl.js']}] - ] -}; - -const config = { - mode: 'production', - - entry: { - main: resolve('./src/bundle.ts') - }, - - output: { - libraryTarget: 'umd', - path: PACKAGE_ROOT, - filename: 'dist/dist.min.js' - }, - - node: NODE, - - resolve: { - extensions: ['.js', '.mjs', '.jsx', '.ts', '.tsx', '.json'], - alias: ALIASES - }, - - module: { - rules: [ - { - // Compile ES2015 using babel - test: /\.(js|ts)$/, - loader: 'babel-loader', - include: [/src/, /esm/], - options: ES5_BABEL_CONFIG - }, - { - test: /\.mjs$/, - include: /node_modules/, - type: "javascript/auto" - } - ] - }, - - externals: getExternals(PACKAGE_INFO), - - plugins: [ - // This is used to define the __VERSION__ constant in api/src/init.js - // babel-plugin-version-inline uses the package version from the working directory - // Therefore we need to manually import the correct version from the core - // This is called in prepublishOnly, after lerna bumps the package versions - new webpack.DefinePlugin({ - __VERSION__: JSON.stringify(PACKAGE_INFO.version) - }) - ], - - devtool: false -}; - -module.exports = (env = {}) => { - // console.log(JSON.stringify(env, null, 2)); - - if (env.dev) { - // Set development mode (no minification) - config.mode = 'development'; - // Remove .min from the name - config.output.filename = 'dist/dist.js'; - // Disable transpilation - // config.module.rules = []; - } - - // NOTE uncomment to display config - // console.log('webpack config', JSON.stringify(config, null, 2)); - - return config; -}; diff --git a/scripts/github-release.js b/scripts/github-release.js deleted file mode 100644 index 01f5cc9019..0000000000 --- a/scripts/github-release.js +++ /dev/null @@ -1,53 +0,0 @@ -import {execSync} from 'child_process'; -import {readFileSync} from 'fs'; - -// Get the latest tag -const tag = getGitTag(); -if (!tag) { - console.error('TAG NOT FOUND'); - process.exit(1); -} - -// Parse changelog -const changelog = getReleaseNotes(tag); -if (!changelog) { - console.error('CHANGELOG NOT FOUND'); - process.exit(1); -} - -// Publish release notes to GitHub -// https://docs.github.com/en/rest/reference/repos#create-a-release -const requestBody = { - tag_name: tag, - name: tag, - body: changelog, - prerelease: tag.search(/alpha|beta|rc/) > 0 -}; - -console.log(JSON.stringify(requestBody)); - -function getGitTag() { - try { - return execSync('git describe --tags --exact-match HEAD', { - stdio: [null, 'pipe', null], - encoding: 'utf-8' - }).trim(); - } catch (err) { - // not tagged - return null; - } -} - -function getReleaseNotes(version) { - let changelog = readFileSync('CHANGELOG.md', 'utf-8'); - const header = changelog.match(new RegExp(`^###.*\\b${version.replace('v', '')}\\b.*$`, 'm')); - if (!header) { - return null; - } - changelog = changelog.slice(header.index + header[0].length); - const endIndex = changelog.search(/^#/m); - if (endIndex > 0) { - changelog = changelog.slice(0, endIndex); - } - return changelog.trim(); -} diff --git a/scripts/postinstall.sh b/scripts/postinstall.sh deleted file mode 100755 index d58ad45606..0000000000 --- a/scripts/postinstall.sh +++ /dev/null @@ -1,5 +0,0 @@ -#/bin/sh - -# TODO - -exit 0; \ No newline at end of file diff --git a/scripts/verify-changelog.js b/scripts/verify-changelog.js deleted file mode 100644 index db57c81112..0000000000 --- a/scripts/verify-changelog.js +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Verifies that CHANGELOG has been updated before publishing a new version - */ -import {readFileSync} from 'fs'; - -const {version} = JSON.parse(readFileSync('lerna.json')); - -const changelog = readFileSync('CHANGELOG.md', 'utf-8'); -const header = changelog.match(new RegExp(`^###.*\\b${version}\\b.*$`, 'm')); -if (!header) { - console.error(`Cannot find an entry for ${version} in CHANGELOG.md`); - process.exit(1); -} diff --git a/index.html b/test/index.html similarity index 62% rename from index.html rename to test/index.html index 83427a5dce..40c8d857d7 100644 --- a/index.html +++ b/test/index.html @@ -4,6 +4,6 @@