From 5f39ab699aac9011f7945954c07fb149b109600f Mon Sep 17 00:00:00 2001 From: Endel Dreyer Date: Thu, 6 Jul 2023 14:39:35 -0300 Subject: [PATCH] use 'fetch' by default on browser env. force XHR for Cocos Creator. bump 0.15.10 --- package-lock.json | 28 ++++++++++++++-------------- package.json | 7 +++---- rollup.config.js | 13 ++++++------- 3 files changed, 23 insertions(+), 25 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8fdd820..55202e8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "colyseus.js", - "version": "0.15.1", + "version": "0.15.9", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "colyseus.js", - "version": "0.15.1", + "version": "0.15.9", "license": "MIT", "dependencies": { "@colyseus/schema": "^2.0.4", @@ -81,9 +81,9 @@ } }, "node_modules/@colyseus/schema": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/@colyseus/schema/-/schema-2.0.6.tgz", - "integrity": "sha512-453Z+nCa3HU1U5tleFe3nnSlU2twfuAbQRqIgoXyM0uG99WOWAgXFri++Gl7ZYfDs4+Rg+jsCYpHNDKuBAIexg==", + "version": "2.0.9", + "resolved": "https://registry.npmjs.org/@colyseus/schema/-/schema-2.0.9.tgz", + "integrity": "sha512-YuIs9oPuVAFAvjEtNFLDdZ4yiRi3d0DfGkeDDrMKFqaI8G4G/MnVb+zHIWN21QeSru+urzqZnZoVV+gHKHNK0w==", "bin": { "schema-codegen": "bin/schema-codegen" } @@ -209,9 +209,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "20.0.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.0.0.tgz", - "integrity": "sha512-cD2uPTDnQQCVpmRefonO98/PPijuOnnEy5oytWJFPY1N9aJCz2wJ5kSGWO+zJoed2cY2JxQh6yBuUq4vIn61hw==", + "version": "20.2.5", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.2.5.tgz", + "integrity": "sha512-JJulVEQXmiY9Px5axXHeYGLSjhkZEnD+MDPDGbCbIAbMslkKwmygtZFy1X6s/075Yo94sf8GuSlFfPzysQrWZQ==", "dev": true }, "node_modules/@types/resolve": { @@ -729,9 +729,9 @@ } }, "node_modules/is-core-module": { - "version": "2.12.0", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.12.0.tgz", - "integrity": "sha512-RECHCBCd/viahWmwj6enj19sKbHfJrddi/6cBDsNTKbNq0f7VeaUkBo60BqzvPqo/W54ChS62Z5qyun7cfOMqQ==", + "version": "2.12.1", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.12.1.tgz", + "integrity": "sha512-Q4ZuBAe2FUsKtyQJoQHlvP8OvBERxO3jEmy1I7hcRXcJBGGHFh/aJBswbXuS9sgrDH2QUO8ilkwNPHvHMd8clg==", "dev": true, "dependencies": { "has": "^1.0.3" @@ -6148,9 +6148,9 @@ } }, "node_modules/tslib": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz", - "integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==" + "version": "2.5.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.3.tgz", + "integrity": "sha512-mSxlJJwl3BMEQCUNnxXBU9jP4JBktcEGhURcPR6VQVlnP0FdDEsIaz0C35dXNGLyRfrATNofF0F5p2KPxQgB+w==" }, "node_modules/tslint": { "version": "5.20.1", diff --git a/package.json b/package.json index 0e9dfdf..157d8bb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "colyseus.js", - "version": "0.15.9", + "version": "0.15.10", "description": "Colyseus Multiplayer SDK for JavaScript/TypeScript", "author": "Endel Dreyer", "license": "MIT", @@ -12,7 +12,7 @@ "build-zip-dist": "zip --junk-paths colyseus-js-client dist/colyseus.*", "build-all": "tsc && npm run build && npm run build-dist-dts && npm run copy-cocos-creator-files && npm run copy-construct3-files", "copy-construct3-files": "cp dist/colyseus.js ../colyseus-construct3/plugin/colyseus.js", - "copy-cocos-creator-files": "cp dist/colyseus.js cocos-creator-3-extension/colyseus-sdk/runtime && cp dist/colyseus.d.ts cocos-creator-3-extension/colyseus-sdk/runtime", + "copy-cocos-creator-files": "cp dist/colyseus-cocos-creator.js cocos-creator-3-extension/colyseus-sdk/runtime/colyseus.js && cp dist/colyseus.d.ts cocos-creator-3-extension/colyseus-sdk/runtime", "watch": "tsc -w", "tslint": "tslint --project .", "prepublishOnly": "tsc && npm run build" @@ -36,8 +36,7 @@ "require": "./build/cjs/index.js", "types": "./lib/index.d.ts" }, - "./package.json": "./package.json", - "./decentraland": "./dist/colyseus-decentraland.js" + "./package.json": "./package.json" }, "decentralandLibrary": { "main": "./dist/colyseus-decentraland.js", diff --git a/rollup.config.js b/rollup.config.js index acd755a..abf69ea 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -53,8 +53,8 @@ export default [ typescript({ tsconfig: './tsconfig/tsconfig.cjs.json' }), alias({ entries: [ - // httpie: force XHR implementation on browser/UMD environment - { find: 'httpie', replacement: './node_modules/httpie/xhr/index.js' }, + // httpie: force `fetch` for web environments + { find: 'httpie', replacement: './node_modules/httpie/fetch/index.js' }, // ws: force browser.js version. { find: 'ws', replacement: './node_modules/ws/browser.js' }, @@ -66,20 +66,19 @@ export default [ commonjs(), nodeResolve({ browser: true }), // "browser" seems to have no effect here. (why??) ], - }, - // Decentraland SDK (same as browser/embedded, but use FETCH instead of XHR) + // Cocos Creator SDK (same as browser/embedded, but use XHR instead of fetch) { preserveModules: false, input: ['src/index.ts'], output: [ { - banner: bannerStatic, + banner: `// THIS VERSION USES "XMLHttpRequest" INSTEAD OF "fetch" FOR COMPATIBILITY WITH COCOS CREATOR\n${bannerStatic}`, dir: 'dist', name: "Colyseus", format: 'umd', - entryFileNames: 'colyseus-decentraland.js', + entryFileNames: 'colyseus-cocos-creator.js', sourcemap: true, amd: { id: pkg.name } }, @@ -89,7 +88,7 @@ export default [ alias({ entries: [ // httpie: force XHR implementation on browser/UMD environment - { find: 'httpie', replacement: './node_modules/httpie/fetch/index.js' }, + { find: 'httpie', replacement: './node_modules/httpie/xhr/index.js' }, // ws: force browser.js version. { find: 'ws', replacement: './node_modules/ws/browser.js' },