Skip to content

Commit

Permalink
Update engine and examples package.json (#7172)
Browse files Browse the repository at this point in the history
  • Loading branch information
slimbuck authored Dec 4, 2024
1 parent 461bcb4 commit 9e277aa
Show file tree
Hide file tree
Showing 179 changed files with 6,408 additions and 14,041 deletions.
55 changes: 55 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import playcanvasConfig from '@playcanvas/eslint-config';
import babelParser from '@babel/eslint-parser';
import globals from 'globals';

export default [
...playcanvasConfig,
{
files: ['**/*.js', '**/*.mjs'],
languageOptions: {
ecmaVersion: 2022,
sourceType: 'module',
parser: babelParser,
parserOptions: {
requireConfigFile: false
},
globals: {
...globals.browser,
...globals.mocha,
...globals.node,
'Ammo': 'readonly',
'earcut': 'readonly',
'opentype': 'readonly',
'pc': 'readonly',
'TWEEN': 'readonly',
'twgsl': 'readonly',
'webkitAudioContext': 'readonly'
}
},
rules: {
'import/order': 'off'
}
},
{
files: ['scripts/**/*.js'],
rules: {
'no-var': 'off'
}
},
{
files: ['test/**/*.mjs'],
rules: {
'no-unused-expressions': 'off',
'prefer-arrow-callback': 'off' // Mocha uses function callbacks
}
},
{
ignores: [
'tests/**/*',
'examples/lib/*',
'scripts/textmesh/*.min.js',
'src/polyfill/*',
'scripts/spine/*'
]
}
];
30 changes: 30 additions & 0 deletions examples/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import playcanvasConfig from '@playcanvas/eslint-config';
import globals from 'globals';

export default [
...playcanvasConfig,
{
files: ['**/*.js', '**/*.mjs'],
languageOptions: {
globals: {
...globals.browser,
...globals.node,
'ObjModelParser': 'readonly',
'OutlineEffect': 'readonly'
}
},
rules: {
'import/no-unresolved': 'off'
}
},
{
ignores: [
'assets/scripts/utils/area-light-lut-bin-gen.js',
'cache',
'dist',
'src/lib',
'src/app/monaco/languages',
'src/app/monaco/tokenizer-rules.mjs'
]
}
];
6 changes: 3 additions & 3 deletions examples/iframe/loader.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { updateDeviceType, fetchFile, localImport, clearImports, parseConfig, fire } from 'examples/utils';
import { data, refresh } from 'examples/observer';
import files from 'examples/files';
import { data, refresh } from 'examples/observer';
import { updateDeviceType, fetchFile, localImport, clearImports, parseConfig, fire } from 'examples/utils';

import MiniStats from './ministats.mjs';

Expand Down Expand Up @@ -79,7 +79,7 @@ class ExampleLoader {
*/
const locations = [];
lines.forEach((line) => {
const match = /^\s*at\s(.+):(\d+):(\d+)$/g.exec(line);
const match = /^\s*at\s(.+):(\d+):(\d+)$/.exec(line);
if (!match) {
return;
}
Expand Down
12 changes: 6 additions & 6 deletions examples/iframe/utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ export const rootPath = root.replace(/\/iframe/g, '');
*/
export function getQueryParams(url) {
return Object.fromEntries(url
.split('?').pop()
.split('#')[0]
.split('&').map(s => s.split('=')));
.split('?').pop()
.split('#')[0]
.split('&').map(s => s.split('=')));
}

/**
Expand Down Expand Up @@ -80,14 +80,14 @@ export function clearImports() {
* @returns {Record<string, any>} - The parsed config.
*/
export function parseConfig(script) {
const regex = /\/\/ @config ([^ \n]+) ?([^\n]+)?/g;
const regex = /\/\/ @config (\S+)(?:\s+([^\n]+))?/g;
let match;
/** @type {Record<string, any>} */
const config = {};
while ((match = regex.exec(script)) !== null) {
const key = match[1].trim();
const val = match[2]?.trim();
config[key] = /true|false/g.test(val) ? val === 'true' : val ?? true;
config[key] = /true|false/.test(val) ? val === 'true' : val ?? true;
}
return config;
}
Expand All @@ -104,7 +104,7 @@ export function updateDeviceType(config) {
deviceType = DEVICE_TYPES.includes(savedDevice) ? savedDevice : 'webgl2';

if (params.deviceType && DEVICE_TYPES.includes(params.deviceType)) {
console.warn("Overriding default device: ", params.deviceType);
console.warn('Overriding default device: ', params.deviceType);
deviceType = params.deviceType;
return;
}
Expand Down
Loading

0 comments on commit 9e277aa

Please sign in to comment.