Skip to content
Permalink
Browse files

Use stanza-shims to handle different runtimes

  • Loading branch information...
legastero committed Oct 16, 2019
1 parent 9978550 commit d5b26be6d4e552a269856c8fc785da55264fdb08
@@ -7,3 +7,6 @@ coverage
.nyc_output
.vscode

# ignore node_modules symlink
node_modules
node_modules.nosync
@@ -70,6 +70,14 @@ client.connect();

MUC Room: [discuss@stanzajs.org](https://stanzajs.org/discuss/logs) / [Logs](https://stanzajs.org/discuss/logs)

## Related Modules

These are related modules that form part of StanzaJS:

| Name | Description | Source |
| ------------------------------------------------------ | -------------------------------------------------------------------- | --------------------------------------------------- |
| [stanza-shims](https://npmjs.org/package/stanza-shims) | Runtime shims used by StanzaJS for node, browsers, and React Native. | [Source](https://github.com/legastero/stanza-shims) |

## Recommended Modules

These are some additional modules that are highly recommended for use with StanzaJS:

Large diffs are not rendered by default.

@@ -3,47 +3,47 @@
"description": "Modern XMPP in the browser, with a JSON API",
"version": "12.3.3",
"author": "Lance Stout <lancestout@gmail.com>",
"bugs": "https://github.com/legastero/stanza.io/issues",
"bugs": "https://github.com/legastero/stanza/issues",
"contributors": [
"Philipp Hancke <fippo@andyet.net>",
"Steven Lloyd Watkin <lloyd@evilprofessor.co.uk>"
],
"dependencies": {
"@types/async": "^3.0.1",
"@types/node": "^12.7.4",
"@types/async": "^3.0.3",
"@types/node": "^12.11.1",
"@types/punycode": "^2.1.0",
"@types/readable-stream": "^2.3.3",
"@types/readable-stream": "^2.3.5",
"@types/ws": "^6.0.2",
"async": "^3.0.1",
"node-fetch": "^2.6.0",
"punycode": "^2.1.1",
"react-native-randombytes": "^3.5.3",
"readable-stream": "^2.3.6",
"sdp": "^2.10.0",
"stanza-shims": "^1.0.0",
"tslib": "^1.9.3",
"ws": "^7.1.1"
},
"devDependencies": {
"@types/jest": "^24.0.18",
"@types/jest": "^24.0.19",
"expect": "^24.9.0",
"husky": "^3.0.5",
"husky": "^3.0.9",
"jest": "^24.9.0",
"jest-mock": "^24.9.0",
"prettier": "^1.18.2",
"pretty-quick": "^1.11.0",
"pretty-quick": "^2.0.0",
"rimraf": "^3.0.0",
"rollup": "^1.20.3",
"rollup": "^1.24.0",
"rollup-plugin-node-resolve": "^5.0.1",
"rollup-plugin-visualizer": "^2.5.4",
"ts-jest": "^24.0.2",
"ts-node": "^8.2.0",
"tslint": "^5.17.0",
"ts-jest": "^24.1.0",
"ts-node": "^8.4.1",
"tslint": "^5.20.0",
"tslint-sonarts": "^1.9.0",
"typedoc": "^0.15.0",
"typescript": "^3.6.2",
"webpack": "^4.39.3",
"webpack-bundle-analyzer": "^3.4.1",
"webpack-cli": "^3.3.6"
"typescript": "^3.6.4",
"webpack": "^4.41.2",
"webpack-bundle-analyzer": "^3.6.0",
"webpack-cli": "^3.3.9"
},
"homepage": "https://stanzajs.org",
"husky": {
@@ -80,7 +80,7 @@
"private": true,
"repository": {
"type": "git",
"url": "https://github.com/legastero/stanza.io.git"
"url": "https://github.com/legastero/stanza.git"
},
"scripts": {
"build": "ts-node scripts/build",
@@ -89,24 +89,10 @@
"compile": "tsc -p .",
"compile:module": "tsc -p . --outDir ./dist/es --target es2015 --module es2015",
"compile:rollup": "rollup -c rollup.config.js",
"compile:rollup-browser": "rollup -c rollup-browser.config.js",
"compile:rollup-react-native": "rollup -c rollup-react-native.config.js",
"compile:webpack": "webpack --mode production",
"license-check": "npx license-checker --production --excludePrivatePackages --summary",
"lint": "tslint -p .",
"test": "jest",
"validate": "npm ls"
},
"stanzajs_env_mappings": {
"browser": {
"./dist/es/lib/crypto/index.js": "./dist/es/lib/crypto/index-browser.js",
"./dist/es/lib/fetch/index.js": "./dist/es/lib/fetch/index-browser.js",
"./dist/es/lib/ws/index.js": "./dist/es/lib/ws/index-browser.js"
},
"react-native": {
"./dist/es/lib/crypto/index.js": "./dist/es/lib/crypto/index-react-native.js",
"./dist/es/lib/fetch/index.js": "./dist/es/lib/fetch/index-browser.js",
"./dist/es/lib/ws/index.js": "./dist/es/lib/ws/index-browser.js"
}
}
}

This file was deleted.

This file was deleted.

@@ -18,5 +18,5 @@ export default {
file: 'dist/es/index.module.js',
format: 'es'
},
plugins: [resolve()]
plugins: [resolve({ browser: true })]
};
@@ -8,23 +8,6 @@ function fileReplace(fileName: string, placeholder: string, value: string) {
FS.writeFileSync(fileName, originalFile.replace(placeholder, value));
}

interface Overrides {
[key: string]: string;
}
function writeOverrides(overrides?: Overrides) {
FS.writeFileSync(
'package.json',
JSON.stringify(
{
...Pkg,
browser: overrides
},
null,
4
) + '\n'
);
}

// Copy local package files
Child('npm run clean');
Child('npm run compile');
@@ -36,22 +19,9 @@ fileReplace('dist/es/Constants.js', '__STANZAJS_VERSION__', Pkg.version);

Child('npm run compile:rollup');

// Create browser specific module
writeOverrides(Pkg.stanzajs_env_mappings.browser);
Child('npm run compile:rollup-browser');

// Create react-native specific module
writeOverrides(Pkg.stanzajs_env_mappings['react-native']);
Child('npm run compile:rollup-react-native');

// Clean up overrides
writeOverrides(undefined);

Child('mkdir dist/npm');
Child('cp -r dist/cjs/* dist/npm/');
Child('cp dist/es/index.module.js dist/npm/module.js');
Child('cp dist/es/index-browser.module.js dist/npm/browser-module.js');
Child('cp dist/es/index-rn.module.js dist/npm/rn-module.js');
Child(`cp ${__dirname}/../*.md dist/npm`);
Child('npm run compile:webpack');

@@ -61,15 +31,14 @@ FS.writeFileSync(
JSON.stringify(
{
...Pkg,
browser: './browser-module.js',
browser: './module.js',
devDependencies: undefined,
main: './index.js',
module: './module.js',
private: false,
'react-native': './rn-module.js',
'react-native': './index.js',
scripts: undefined,
sideEffects: false,
stanzajs_env_mappings: undefined,
typings: './index'
},
null,
@@ -9,7 +9,7 @@

// tslint:disable no-bitwise

import { randomBytes } from './lib/crypto';
import { randomBytes } from 'stanza-shims';

const bth: string[] = [];
for (let i = 0; i < 256; ++i) {
@@ -1,4 +1,4 @@
import * as Hashes from '../lib/crypto';
import * as Hashes from 'stanza-shims';
import { octetCompare } from '../Utils';

import { DataForm, DataFormField, DiscoInfo, DiscoInfoIdentity } from '../protocol';
@@ -1,7 +1,7 @@
import { EventEmitter } from 'events';
import * as Hashes from 'stanza-shims';

import { JINGLE_INFO_CHECKSUM_5, JingleAction, JingleSessionRole } from '../Constants';
import * as Hashes from '../lib/crypto';
import { NS_JINGLE_FILE_TRANSFER_5 } from '../Namespaces';
import {
FileDescription,

This file was deleted.

0 comments on commit d5b26be

Please sign in to comment.
You can’t perform that action at this time.