Skip to content

Commit

Permalink
use microverse-library version 0.7.7
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshikiohshima committed Sep 1, 2023
1 parent 3fec4a4 commit a75e619
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 57 deletions.
34 changes: 23 additions & 11 deletions behaviors/PrototypeBehavior.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ export type WorldcoreExports = {
* @param {number} a
* @returns {Vector3}
*/
v3_rotateY(v: Vectnlor3, a: number): Vector3,
v3_rotateY(v: Vector3, a: number): Vector3,

/**
* Rotate around z axis. Angle in radians. Clockwise looking along axis
Expand Down Expand Up @@ -796,17 +796,20 @@ export type WorldcoreExports = {
GetPawn(id: string): CardPawn,
};

export type PhysicsExports = {
// export type Rapier = typeof import("@dimforge/rapier3d");

type PhysicsExports = {
PhysicsVersion(): string,
Physics: any
Physics: any // Rapier
};

export type FrameExports = {

type FrameExports = {
sendToShell(command: string, ...args: Array<any>)
}

export type THREE = typeof import("three");
export type MicroverseModule = {THREE: THREE} & WorldcoreExports & PhysicsExports & FrameExports & {getViewRoot(): any};
type MicroverseModule = {THREE: THREE} & WorldcoreExports & PhysicsExports & FrameExports & {getViewRoot(): any};

export type BehaviorMethod = Array<string>;
export type PlaneMaterial = THREE.MeshStandardMaterial|Array<THREE.Material>;
Expand Down Expand Up @@ -916,6 +919,15 @@ The scale of the card in three axes.

hidden: boolean|undefined

/**
The Rapier Physics Engine object.
@public
@type any
*/

rigidBody: any

/**
Any other values that the CardActor holds are stored in an object stored in the `_cardData` property. This is needed to mark the values to be stored in the persistent data.
Expand Down Expand Up @@ -983,7 +995,7 @@ When the first form is used, it specifies the globally known module name and the
@param {number} time - the delay in logical millisecond
@returns A proxy to invoke a method on
*/
future(time: number): ThisType
future(time: number): this

/**
This method updates some elements in the `_cardData` object. The current value and the new values are merged to create the new `_cardData` object. As a side effect, it publishes `cardDataSet` Croquet event that can be handled by the pawn or any other subscribers.
Expand Down Expand Up @@ -1369,7 +1381,7 @@ mth` of the same behavior will be invoked. If you would like to call a method of
@returns a proxy to call a method on
@param {number} time - the wall clock time to delay the method invocatino.
*/
future(time: number): ThisType
future(time: number): this

/**
This method adds a "listener" to be invoked when an event occurs on the pawn of a card. When `listener` is a string, it has to have the name of an existing method of CardPawn or the behavior itself. (Internally the function object is stored in the event listener data structure.)
Expand Down Expand Up @@ -1418,7 +1430,7 @@ This method removes the event listener that was added. You can call it even when
@param {string|function} listener - the name of the handler in the calling behavior, or a function specified in the form of `this.mth`
*/

unsubscribe(scope: string, eventName: string, listener?: string|((evt: T) => void)): void
unsubscribe<T>(scope: string, eventName: string, listener?: string|((evt: T) => void)): void

/**
This method publishes a Croquet event.
Expand Down Expand Up @@ -1589,13 +1601,13 @@ if (this.actor.layers && this.actor.layers.includes("walk")) {
Add an additional method to invoke at each display frame, typically modify the visual appearance of the object.
*/

addUpdateRequest(spec: Array<string, string>): void
addUpdateRequest(spec: [string, string]): void

/**
Remove an additional method to invoke at each display frame, typically modify the visual appearance of the object.
*/

removeUpdateRequest(spec: Array<string, string>): void
removeUpdateRequest(spec: [string, string]): void
/**
recompute matrices
*/
Expand Down Expand Up @@ -1790,7 +1802,7 @@ export class AvatarPawn extends PawnBehavior {
returns {boolean}
*/

collideBVH(collideList: Array<Mesh>, vq: VQ): boolean
collideBVH(collideList: Array<THREE.Mesh>, vq: VQ): boolean

/**
This method checks if there is a mesh with walk layer toward the negative y direction from the position (v).
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<title>Microverse</title>
<link id="microverse-css" rel="stylesheet" href="./assets/css/microverse.css" />
<script defer src="lib/index-aef48027.js"></script></head>
<script defer src="lib/index-bcc3336e.js"></script></head>

<body class="no-select">
</body>
Expand Down
60 changes: 30 additions & 30 deletions lib/index-aef48027.js → lib/index-bcc3336e.js
Original file line number Diff line number Diff line change
Expand Up @@ -16226,23 +16226,18 @@ function checkModule(module) {
});
}

function compileToModule(text, path) {
async function compileToModule(text, path) {
let language = path.endsWith(".ts") ? "ts" : "js";

let jsCompiler;
let tsCompiler;

if (!jsCompiler) {
jsCompiler = new _compiler_js__WEBPACK_IMPORTED_MODULE_4__.JSCompiler();
}

let js = jsCompiler.compile(text, path);
jsCompiler = new _compiler_js__WEBPACK_IMPORTED_MODULE_4__.JSCompiler();
let js = await jsCompiler.compile(text, path);

if (language === "ts") {
if (!tsCompiler) {
tsCompiler = new _compiler_js__WEBPACK_IMPORTED_MODULE_4__.TSCompiler();
}
js = tsCompiler.compile(js, path);
tsCompiler = new _compiler_js__WEBPACK_IMPORTED_MODULE_4__.TSCompiler();
js = await tsCompiler.compile(js, path);
}

let dataURL = URL.createObjectURL(new Blob([js], {type: "application/javascript"}));
Expand All @@ -16269,23 +16264,31 @@ __webpack_require__.r(__webpack_exports__);
/* harmony export */ TSCompiler: () => (/* binding */ TSCompiler)
/* harmony export */ });
class TSCompiler {
constructor() {
if (!window.ts) {return;}
async compile(tsCode, location) {
if (!window.tsPromise) {
window.tsPromise = new Promise((resolve, _reject) => {
let script = document.createElement("script");
script.src = "https://cdn.jsdelivr.net/npm/[email protected]/lib/typescript.min.js";
script.onload = resolve;
script.type = "text/javascript";
document.head.appendChild(script);
});
}

await window.tsPromise;
if (!window.ts) {return tsCode;}
this.options = {
module: ts.ModuleKind.ESNext,
target: ts.ScriptTarget.ESNext,
module: window.ts.ModuleKind.ESNext,
target: window.ts.ScriptTarget.ESNext,
noResolve: true,
};
this.compilerHost = this.createCompilerHost();
}

compile(tsCode, location) {
if (!window.ts) {return tsCode;}
this.compilerHost = this.createCompilerHost();
this.sources = new Map([[location, tsCode]]);
this.results = new Map();

let program = ts.createProgram([location], this.options, this.compilerHost);
let result = program.emit();
let program = window.ts.createProgram([location], this.options, this.compilerHost);
let _result = program.emit();

let compiledName = location.replace(/\.ts$/, ".js");

Expand All @@ -16299,7 +16302,7 @@ class TSCompiler {
getSourceFile(fileName, languageVersion, _onError) {
const sourceText = this.readFile(fileName);
return sourceText !== undefined
? ts.createSourceFile(fileName, sourceText, languageVersion)
? window.ts.createSourceFile(fileName, sourceText, languageVersion)
: undefined;
}

Expand All @@ -16319,7 +16322,7 @@ class TSCompiler {
createCompilerHost() {
return {
getSourceFile: this.getSourceFile,
getDefaultLibFileName: (defaultLibOptions) => "/" + ts.getDefaultLibFileName(defaultLibOptions),
getDefaultLibFileName: (defaultLibOptions) => "/" + window.ts.getDefaultLibFileName(defaultLibOptions),
writeFile: (fileName, content) => this.writeFile(fileName, content),
getCurrentDirectory: () => "/",
getDirectories: (_path) => [],
Expand All @@ -16336,31 +16339,28 @@ class TSCompiler {

class JSCompiler {
compile(jsCode, _location) {
console.log(_location);
let result = [];

let codeArray = jsCode.split("\n");

for (let i = 0; i < codeArray.length; i++) {
let line = codeArray[i];
if (/^import/.test(line)) {
result.push("");
result.push(line[line.length - 1] === "\r" ? "\r" : "");
continue;
}
let test = /^class(\s+)(\S+)\s+extends\s(ActorBehavior|PawnBehavior)(.*)\r?$/.exec(line)
let test = /^\s*class(\s+)(\S+)\s+extends\s(ActorBehavior|PawnBehavior)(.*)(\r?)$/.exec(line);
if (test) {
let newLine = `class${test[1]}${test[2]}${test[4]}`;
let newLine = `class${test[1]}${test[2]}${test[4]}${test[5]}`;
result.push(newLine);
continue;
}
result.push(line);
}
return result.join("\n");
return Promise.resolve(result.join("\n"));
}
}

/* globals ts*/


/***/ }),

Expand Down Expand Up @@ -117005,4 +117005,4 @@ start();
})();

/******/ })()
;
;
2 changes: 1 addition & 1 deletion meta/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
commit: 9e5d9a864611fc44571357e957a1dc3e58fc25fb Date: Tue Aug 29 16:59:08 2023 -0700
commit: ae0c614f57c1bf578c1b807f26080dbb5445b86e Date: Fri Sep 1 13:19:23 2023 -0700
59 changes: 55 additions & 4 deletions 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 package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
"watch-server": "watch-server"
},
"dependencies": {
"@croquet/microverse-library": "^0.7.5"
"@croquet/microverse-library": "^0.7.7"
},
"devDependencies": {
"@croquet/microverse-file-server": "^1.0.7",
"@croquet/microverse-watch-server": "^1.0.7",
"@types/three": "0.155.0",
"npm-run-all": "^4.1.5"
}
}
9 changes: 0 additions & 9 deletions prelude.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export async function prelude() {
let css = document.createElement("link");
css.rel = "stylesheet";
css.type = "text/css";
css.
css.id = "joystick-css";
css.onload = resolve;
css.href = "/assets/css/joystick.css";
Expand All @@ -60,13 +59,5 @@ export async function prelude() {
Promise like the one above.
*/

await new Promise((resolve, reject) => {
let script = document.createElement("script");
script.src = "https://cdn.jsdelivr.net/npm/[email protected]/lib/typescript.min.js";
script.onload = resolve;
script.type = "text/javascript";
document.head.appendChild(script);
});

return null;
}

0 comments on commit a75e619

Please sign in to comment.