Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RuntimeTypeInspector.js: Add RTI build target + Examples integration #5817

Draft
wants to merge 84 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
5e8b2a6
Adding RTI transpiler to every target, I will fine-tune a bit later
kungfooman Nov 9, 2023
e8aa110
Merge branch 'main' into rti
kungfooman Nov 9, 2023
91dec96
name output build/playcanvas-rti and update packages
kungfooman Nov 9, 2023
d4bb80d
Merge branch 'main' into rti
kungfooman Nov 10, 2023
1ff92a2
Resolve RTI runtime and update to latest RTI rollup plugin
kungfooman Nov 10, 2023
82feb3a
Integrate RTI into Examples browser via `npm run develop:rti`
kungfooman Nov 10, 2023
53ab80c
only add node-resolve plugin for RTI
kungfooman Nov 10, 2023
af6366e
Don't type check framework/parsers/draco-worker.js (because a Worker …
kungfooman Nov 11, 2023
20a249a
npm i @runtime-type-inspector/[email protected] (added `types.d.ts`…
kungfooman Nov 11, 2023
3cae39b
Merge branch 'main' into rti
kungfooman Nov 11, 2023
c89fde4
Add type reporting mode: never
kungfooman Nov 13, 2023
c1bab6b
Merge branch 'main' into rti
kungfooman Nov 28, 2023
b4cb08d
npm run develop:rti - Support live reload
kungfooman Nov 28, 2023
8fcb5e1
extras: JSDoc
kungfooman Dec 2, 2023
1557987
update RTI version, use index.rti.js for custom types/validations
kungfooman Dec 2, 2023
6472337
JSDoc fixes from Splat PR for extras type testing
kungfooman Dec 3, 2023
46daac2
fix lint
kungfooman Dec 3, 2023
5e668a0
Merge branch 'main' into rti
kungfooman Dec 6, 2023
c26a7c5
rollup.config.mjs: add rti target
kungfooman Dec 6, 2023
d18508c
Keep utils/rollup-build-target.mjs without RTI, using rollup-build-ta…
kungfooman Dec 6, 2023
eb75549
Fix lint
kungfooman Dec 6, 2023
5bd053b
little jsdoc fix
kungfooman Dec 17, 2023
e4a1433
npm install --save-dev @runtime-type-inspector/[email protected]
kungfooman Dec 30, 2023
2636752
Fix rollup/acorn error
kungfooman Dec 31, 2023
66c6492
Merge branch 'main' into rti
kungfooman Jan 1, 2024
e2f01a0
package-lock.json: npm install (changed jsdoc-typeof-plugin)
kungfooman Jan 1, 2024
73d1fca
npm update @runtime-type-inspector/transpiler (in root and examples/)
kungfooman Jan 1, 2024
bf397b2
npm update @runtime-type-inspector/plugin-rollup
kungfooman Jan 19, 2024
f3b1567
npm update @runtime-type-inspector/plugin-rollup
kungfooman Jan 20, 2024
1e9eb4f
Merge branch 'main' into rti
kungfooman Jan 25, 2024
cbb2d95
Update to @runtime-type-inspector/[email protected]
kungfooman Jan 25, 2024
9e35146
Merge branch 'main' into rti
kungfooman Jan 25, 2024
6e37268
Ignore node_modules for RTI to fix issue with DisplayAnything
kungfooman Jan 25, 2024
788331d
Merge branch 'main' into rti
kungfooman Feb 22, 2024
5837e5a
Bump RTI rollup plugin and integrate into examples again for `npm run…
kungfooman Feb 23, 2024
faa9c92
`cd examples && npm install` to fix `examples/package-lock.json`
kungfooman Feb 23, 2024
4f68608
Update RTI rollup plugin to 3.2.5
kungfooman May 13, 2024
add8005
Merge branch 'main' into rti
kungfooman May 14, 2024
78a6fd7
Reintegrate npm run build:rti
kungfooman May 14, 2024
e751a99
Reintegrate RTI after bunch of merge conflicts
kungfooman May 15, 2024
a305044
Merge branch 'main' into rti
kungfooman May 15, 2024
d8116b8
Fix package.json and package-lock.json from merge conflict
kungfooman May 15, 2024
4787e03
npm i --save-dev @runtime-type-inspector/[email protected]
kungfooman May 16, 2024
6272f07
Merge branch 'main' into rti
kungfooman May 18, 2024
cba932b
src/framework/anim/binder/anim-binder.js mini comment fix, you can te…
kungfooman May 18, 2024
ae4abb8
Fix custom types
kungfooman May 18, 2024
1dafa68
Merge branch 'main' into rti
kungfooman May 24, 2024
8dccff2
Bump RTI version
kungfooman Jun 13, 2024
b84f139
Merge branch 'main' into rti
kungfooman Jun 13, 2024
871dbab
Bump RTI to 3.3.1
kungfooman Jun 14, 2024
c5034cd
Validate `ArrayBufferView`'s via `ArrayBuffer.isView` as custom type
kungfooman Jun 14, 2024
3229985
Bump RTI to 3.3.2
kungfooman Jun 14, 2024
37cb138
src/index.rti.js: IArguments and ArrayBufferView are checked in RTI i…
kungfooman Jun 14, 2024
2a650a3
src/index.rti.js: Check for Quaternion floating point precision error…
kungfooman Jun 16, 2024
0830707
src/index.rti.js: Add specific warning message to Quat denormalizatio…
kungfooman Jun 17, 2024
b97bcde
Bump RTI to 3.3.3
kungfooman Jun 17, 2024
c0b4013
Fix loaders/gsplat-many example (workers don't do RTI)
kungfooman Jun 17, 2024
f90ab9f
Bump RTI to 3.3.7
kungfooman Jun 21, 2024
f64f74e
Merge branch 'main' into rti
kungfooman Jun 21, 2024
9fed558
Ignore denormalization check for `Quat#mulScalar` aswell
kungfooman Jun 21, 2024
831a781
Merge branch 'main' into rti
kungfooman Sep 4, 2024
3ad1089
Merge branch 'main' into rti
kungfooman Sep 9, 2024
503e473
Fix lint for new single quote rule
kungfooman Sep 11, 2024
ab85082
Merge branch 'main' into rti
kungfooman Sep 11, 2024
81aac9c
Sync both engine/ and examples/ package-lock.json
kungfooman Sep 11, 2024
48c3c30
Merge branch 'main' into rti
kungfooman Sep 29, 2024
4caa970
Small JSDoc fixes
kungfooman Sep 29, 2024
6d5743c
Few more JSDoc fixes
kungfooman Sep 29, 2024
41f53e4
Merge branch 'main' into rti
kungfooman Nov 15, 2024
05c2440
Merge branch 'main' into rti
kungfooman Nov 15, 2024
568e5ff
Fix lint
kungfooman Nov 15, 2024
2f88759
Merge branch 'main' into rti
kungfooman Nov 15, 2024
7e218c9
Update package-lock.json
kungfooman Nov 15, 2024
0774a34
Update to RTI v4 (ability to send errors over context boundaries, e.g…
kungfooman Nov 16, 2024
af1fd5e
Start with Bottombar for bigger debug output integrated in PCUI
kungfooman Dec 16, 2024
dc75aa3
Merge branch 'main' into rti
kungfooman Feb 12, 2025
a3ab9c4
Update and reintegrate RTI and hide Bottombar until finished
kungfooman Feb 13, 2025
ddef428
fix lint, enable RTI for vercel preview
kungfooman Feb 13, 2025
5e4fdbf
fix lint round 2
kungfooman Feb 13, 2025
ebdf6fa
Update RTI to 4.0.5 to fix last cross-context cloning issue (e.g. sen…
kungfooman Feb 14, 2025
a164c39
Fix ShaderVariantParams from spamming
kungfooman Feb 14, 2025
fc8217e
Update canvas and add anim-curve.js (until pr is fixed, I want to rem…
kungfooman Feb 15, 2025
b9b3a11
Remove canvas
kungfooman Feb 15, 2025
58fe165
npm i RTI 4.0.6
kungfooman Feb 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 26 additions & 25 deletions examples/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
"main": "index.js",
"type": "module",
"scripts": {
"build": "npm run -s build:metadata && cross-env NODE_ENV=production rollup -c",
"build": "npm run -s build:metadata && cross-env NODE_ENV=production RTI=on rollup -c",
"build:metadata": "node ./scripts/build-metadata.mjs",
"build:thumbnails": "node ./scripts/build-thumbnails.mjs",
"clean": "node ./scripts/clean.mjs",
"develop": "cross-env NODE_ENV=development concurrently --kill-others \"npm run watch\" \"npm run serve\"",
"develop:rti": "RTI=on npm run develop",
"lint": "eslint .",
"serve": "serve dist -l 5555 --no-request-logging --config ../serve.json",
"watch": "npm run -s build:metadata && cross-env NODE_ENV=development rollup -c -w"
Expand Down
5 changes: 5 additions & 0 deletions examples/rollup.config.js → examples/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { exampleMetaData } from './cache/metadata.mjs';
import { copy } from './utils/plugins/rollup-copy.mjs';
import { isModuleWithExternalDependencies } from './utils/utils.mjs';
import { treeshakeIgnore } from '../utils/plugins/rollup-treeshake-ignore.mjs';
import { buildTargetRTI } from '../utils/rollup-build-target-rti.mjs';
import { buildTarget } from '../utils/rollup-build-target.mjs';
import { buildHtml } from './utils/plugins/rollup-build-html.mjs';
import { buildShare } from './utils/plugins/rollup-build-share.mjs';
Expand All @@ -21,6 +22,7 @@ import { removePc } from './utils/plugins/rollup-remove-pc.mjs';
const NODE_ENV = process.env.NODE_ENV ?? '';
const ENGINE_PATH = !process.env.ENGINE_PATH && NODE_ENV === 'development' ?
'../src/index.js' : process.env.ENGINE_PATH ?? '';
const { RTI = '' } = process.env;

/**
* Get the engine path files.
Expand Down Expand Up @@ -230,6 +232,9 @@ const engineRollupOptions = () => {

/** @type {RollupOptions[]} */
const options = [];
if (RTI === 'on') {
options.push(buildTargetRTI('es', '../src/index.rti.js', 'dist/iframe/ENGINE_PATH'));
}
if (ENGINE_PATH) {
return options;
}
Expand Down
126 changes: 126 additions & 0 deletions examples/scripts/build-examples.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
/**
* This script is used to generate the standalone HTML file for the iframe to view the example.
*/
import fs from 'fs';
import { dirname, resolve } from 'path';
import { fileURLToPath } from 'url';

import { parseConfig, engineFor, patchScript } from './utils.mjs';
import { exampleMetaData } from '../cache/metadata.mjs';

// @ts-ignore
const __filename = fileURLToPath(import.meta.url);
const MAIN_DIR = `${dirname(__filename)}/../`;
const EXAMPLE_HTML = fs.readFileSync(`${MAIN_DIR}/iframe/example.html`, 'utf-8');
const DIR_CACHE = new Map();

const TEMPLATE_CONTROLS = `/**
* @param {import('../../app/components/Example.mjs').ControlOptions} options - The options.
* @returns {JSX.Element} The returned JSX Element.
*/
export function controls({ fragment }) {
return fragment();
}\n`;

/**
* @param {string} categoryKebab - The category kebab name.
* @param {string} exampleNameKebab - The example kebab name.
* @param {import('./utils.mjs').Engine | undefined} setEngineType - The engine type.
* @param {string[]} files - The files in the example directory.
* @returns {string} File to write as standalone example.
*/
const generateExampleFile = (categoryKebab, exampleNameKebab, setEngineType, files) => {
let html = EXAMPLE_HTML;

// title
html = html.replace(/'@TITLE'/g, `${categoryKebab}: ${exampleNameKebab}`);

// js files
html = html.replace(/'@FILES'/g, JSON.stringify(files));

// engine
const engineType = process.env.ENGINE_PATH ? 'development' : process.env.NODE_ENV === 'development' ? 'debug' : setEngineType;
let engine = engineFor(engineType);
if (process.env.RTI === 'on') {
engine = './ENGINE_PATH/playcanvas.rti.mjs';
}
html = html.replace(/'@ENGINE'/g, JSON.stringify(engine));

if (/'@[A-Z0-9_]+'/.test(html)) {
throw new Error('HTML file still has unreplaced values');
}

return html;
};

/**
* @param {Record<string, string>} env - The environment variables.
*/
export const build = (env = {}) => {
Object.assign(process.env, env);

if (!fs.existsSync(`${MAIN_DIR}/dist/`)) {
fs.mkdirSync(`${MAIN_DIR}/dist/`);
}
if (!fs.existsSync(`${MAIN_DIR}/dist/iframe/`)) {
fs.mkdirSync(`${MAIN_DIR}/dist/iframe/`);
}

exampleMetaData.forEach((/** @type {{ categoryKebab: string; exampleNameKebab: string; path: string; }} */ data) => {
const { categoryKebab, exampleNameKebab, path } = data;
const name = `${categoryKebab}_${exampleNameKebab}`;

if (!DIR_CACHE.has(path)) {
DIR_CACHE.set(path, fs.readdirSync(path));
}

/**
* @type {string[]}
*/
const files = [];
for (const file of DIR_CACHE.get(path)) {
if (file.startsWith(`${exampleNameKebab}.`)) {
files.push(file.replace(`${exampleNameKebab}.`, ''));
}
}
if (!files.includes('example.mjs')) {
throw new Error(`Example ${name} is missing an example.mjs file`);
}
if (!files.includes('controls.mjs')) {
files.push('controls.mjs');
}

files.forEach((file) => {
if (file === 'example.mjs') {
const examplePath = resolve(path, `${exampleNameKebab}.${file}`);

// example file
const script = fs.readFileSync(examplePath, 'utf-8');
fs.writeFileSync(`${MAIN_DIR}/dist/iframe/${name}.example.mjs`, patchScript(script));

// html file
const config = parseConfig(script);
const out = generateExampleFile(categoryKebab, exampleNameKebab, config.ENGINE, files);
fs.writeFileSync(`${MAIN_DIR}/dist/iframe/${name}.html`, out);
return;
}

if (file === 'controls.mjs') {
const controlsPath = resolve(path, `${exampleNameKebab}.${file}`);
const controlsExist = fs.existsSync(controlsPath);

// controls file
const script = controlsExist ? fs.readFileSync(controlsPath, 'utf-8') : TEMPLATE_CONTROLS;
fs.writeFileSync(`${MAIN_DIR}/dist/iframe/${name}.controls.mjs`, patchScript(script));
return;
}

const scriptPath = resolve(path, `${exampleNameKebab}.${file}`);
let script = fs.readFileSync(scriptPath, 'utf-8');
if (/\.(?:mjs|js)$/.test(file)) {
script = patchScript(script);
}
fs.writeFileSync(`${MAIN_DIR}/dist/iframe/${name}.${file}`, script);
});
});
};
Loading
Loading