@nethesis/phone-island 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.eslintrc.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "env": {
3
+ "browser": true,
4
+ "es2021": true,
5
+ "jest": true
6
+ },
7
+ "extends": [
8
+ "eslint:recommended",
9
+ "plugin:react/recommended",
10
+ "plugin:@typescript-eslint/recommended",
11
+ "prettier",
12
+ "plugin:storybook/recommended"
13
+ ],
14
+ "parser": "@typescript-eslint/parser",
15
+ "parserOptions": {
16
+ "ecmaFeatures": {
17
+ "jsx": true
18
+ },
19
+ "ecmaVersion": "latest",
20
+ "sourceType": "module"
21
+ },
22
+ "plugins": [
23
+ "react",
24
+ "react-hooks",
25
+ "@typescript-eslint",
26
+ "prettier"
27
+ ],
28
+ "rules": {
29
+ "react/react-in-jsx-scope": "off",
30
+ "camelcase": "error",
31
+ "spaced-comment": "error",
32
+ "quotes": ["error", "single"],
33
+ "no-duplicate-imports": "error",
34
+ "react/display-name": false
35
+ },
36
+ "settings": {
37
+ "import/resolver": {
38
+ "typescript": {}
39
+ }
40
+ }
41
+ }
package/.prettierrc ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "semi": false,
3
+ "tabWidth": 2,
4
+ "printWidth": 100,
5
+ "singleQuote": true,
6
+ "trailingComma": "all",
7
+ "jsxSingleQuote": true,
8
+ "bracketSpacing": true
9
+ }
@@ -0,0 +1,20 @@
1
+ module.exports = {
2
+ stories: ['../src/**/*.stories.@(ts|tsx|js|jsx)'],
3
+ addons: [
4
+ '@storybook/addon-links',
5
+ '@storybook/addon-essentials',
6
+ '@storybook/addon-actions',
7
+ {
8
+ name: '@storybook/addon-postcss',
9
+ options: {
10
+ postcssLoaderOptions: {
11
+ implementation: require('postcss'),
12
+ },
13
+ },
14
+ },
15
+ ],
16
+ // https://storybook.js.org/docs/react/configure/typescript#mainjs-configuration
17
+ typescript: {
18
+ check: true // type-check stories during Storybook build
19
+ }
20
+ }
@@ -0,0 +1,11 @@
1
+ import '../src/index.css';
2
+
3
+ export const parameters = {
4
+ actions: { argTypesRegex: "^on[A-Z].*" },
5
+ controls: {
6
+ matchers: {
7
+ color: /(background|color)$/i,
8
+ date: /Date$/,
9
+ },
10
+ },
11
+ }
package/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # Scaffolding
2
+
3
+ - **widget-build** - contains the build of the widget version
4
+ - **widget-example** - contains the usage example of the built widget
5
+ - **dist** - contains the component lib build
6
+ - **src/index.ts** - is the entry point for the component lib and exports the React component
7
+ - **src/index.widget.tsx** - is the entry point for the widget that is built as a single js and css file
8
+
9
+ # Development
10
+
11
+ Install deps
12
+ ```
13
+ npm install
14
+ ```
15
+
16
+ Run Storybook
17
+ ```
18
+ npm run dev
19
+ ```
20
+ The main component can be developed using Storybook. Inside the story is rendered the component exported by the final component library.
21
+
22
+ Tailwind CSS is enable by default.
23
+
24
+ # Import locally
25
+
26
+ Run build and start watch
27
+
28
+ ```
29
+ npm run watch
30
+ ```
31
+
32
+ Go to the project directory
33
+
34
+ ```
35
+ cd <local-project>
36
+ ```
37
+
38
+ Link the ```./dist``` directory
39
+
40
+ ```
41
+ npm link <path-to-phone-island/dist>
42
+ ```
43
+
44
+ # Build
45
+
46
+ Build component library
47
+
48
+ ```
49
+ npm run build
50
+ ```
51
+ Build widget
52
+ ```
53
+ npm run build:widget
54
+ ```
55
+ Serve the widget
56
+ ```
57
+ npm run serve:widget
58
+ ```
59
+
60
+ As you can see the app/component can be built in two ways.
61
+
62
+ - The component library built with Rollup
63
+ - The widget files built with Parcel
64
+
package/decs.d.ts ADDED
@@ -0,0 +1 @@
1
+ declare module 'janus-gateway'
package/package.json ADDED
@@ -0,0 +1,95 @@
1
+ {
2
+ "name": "@nethesis/phone-island",
3
+ "author": "Nethesis",
4
+ "version": "0.2.0",
5
+ "private": false,
6
+ "dependencies": {
7
+ "@swc/helpers": "^0.4.12",
8
+ "@testing-library/jest-dom": "^5.11.4",
9
+ "@testing-library/react": "^11.1.0",
10
+ "@testing-library/user-event": "^12.1.10",
11
+ "react": "^17.0.1",
12
+ "react-dom": "^17.0.1",
13
+ "react-scripts": "5.0.1",
14
+ "socket.io-client": "^4.5.3",
15
+ "webrtc-adapter": "^8.2.0"
16
+ },
17
+ "scripts": {
18
+ "start": "react-scripts start",
19
+ "dev": "start-storybook -p 6006 -s public",
20
+ "test": "react-scripts test",
21
+ "watch": "rm -rf ./dist && npm run build:css && rollup -w -c",
22
+ "build": "rm -rf ./dist && npm run build:css && rollup -c",
23
+ "build:css": "NODE_ENV=production npx tailwindcss -o ./dist/index.css --minify",
24
+ "build:widget": "parcel build ./src/index.widget.tsx --dist-dir dist-widget --no-source-maps",
25
+ "serve:widget": "rm -rf ./widget-example/static/* && cp -rf ./dist-widget/* ./widget-example/static && npx http-server ./widget-example -o -c-1",
26
+ "build-storybook": "build-storybook -s public",
27
+ "publish": "np --no-tests"
28
+ },
29
+ "eslintConfig": {
30
+ "extends": [
31
+ "react-app",
32
+ "react-app/jest"
33
+ ],
34
+ "overrides": [
35
+ {
36
+ "files": [
37
+ "**/*.stories.*"
38
+ ],
39
+ "rules": {
40
+ "import/no-anonymous-default-export": "off"
41
+ }
42
+ }
43
+ ]
44
+ },
45
+ "browserslist": {
46
+ "production": [
47
+ ">0.2%",
48
+ "not dead",
49
+ "not op_mini all"
50
+ ],
51
+ "development": [
52
+ "last 1 chrome version",
53
+ "last 1 firefox version",
54
+ "last 1 safari version"
55
+ ]
56
+ },
57
+ "devDependencies": {
58
+ "@babel/core": "^7.20.2",
59
+ "@babel/preset-env": "^7.20.2",
60
+ "@parcel/transformer-typescript-types": "^2.8.0",
61
+ "@rollup/plugin-babel": "^6.0.2",
62
+ "@rollup/plugin-commonjs": "^23.0.2",
63
+ "@rollup/plugin-node-resolve": "^15.0.1",
64
+ "@rollup/plugin-typescript": "^9.0.2",
65
+ "@storybook/addon-actions": "^6.5.13",
66
+ "@storybook/addon-essentials": "^6.5.13",
67
+ "@storybook/addon-interactions": "^6.5.13",
68
+ "@storybook/addon-links": "^6.5.13",
69
+ "@storybook/addon-postcss": "^2.0.0",
70
+ "@storybook/builder-webpack5": "^6.5.13",
71
+ "@storybook/manager-webpack5": "^6.5.13",
72
+ "@storybook/node-logger": "^6.5.13",
73
+ "@storybook/preset-create-react-app": "^4.1.2",
74
+ "@storybook/react": "^6.5.13",
75
+ "@storybook/testing-library": "^0.0.13",
76
+ "@types/jest": "^29.2.2",
77
+ "@types/react": "^18.0.25",
78
+ "@types/react-dom": "^18.0.8",
79
+ "autoprefixer": "^10.4.13",
80
+ "babel": "^6.23.0",
81
+ "babel-plugin-named-exports-order": "^0.0.2",
82
+ "buffer": "^5.7.1",
83
+ "np": "^7.6.2",
84
+ "parcel": "^2.0.0",
85
+ "postcss": "^8.4.18",
86
+ "prop-types": "^15.8.1",
87
+ "rollup": "^2.79.1",
88
+ "rollup-plugin-generate-package-json": "^3.2.0",
89
+ "rollup-plugin-postcss": "^4.0.2",
90
+ "rollup-plugin-terser": "^7.0.2",
91
+ "tailwindcss": "^3.2.2",
92
+ "typescript": "^4.8.4",
93
+ "webpack": "^5.74.0"
94
+ }
95
+ }
@@ -0,0 +1,5 @@
1
+ module.exports = {
2
+ plugins: {
3
+ tailwindcss: {}
4
+ }
5
+ }
Binary file
@@ -0,0 +1,18 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
6
+ <meta name="theme-color" content="#000000" />
7
+ <meta name="description" content="Web site created using create-react-app" />
8
+
9
+ <title>React App</title>
10
+ </head>
11
+ <body>
12
+ <noscript>You need to enable JavaScript to run this app.</noscript>
13
+ <code>
14
+ <p>Start developing the component running the following command in your terminal:</p>
15
+ <h2>npm run dev</h2>
16
+ </code>
17
+ </body>
18
+ </html>
@@ -0,0 +1,59 @@
1
+ import resolve from '@rollup/plugin-node-resolve'
2
+ import commonjs from '@rollup/plugin-commonjs'
3
+ import typescript from '@rollup/plugin-typescript'
4
+ import postcss from 'rollup-plugin-postcss'
5
+ import babel from '@rollup/plugin-babel'
6
+ import { terser } from 'rollup-plugin-terser'
7
+ import { getFiles } from './scripts/buildUtils'
8
+ import generatePackageJson from 'rollup-plugin-generate-package-json'
9
+
10
+ export default {
11
+ input: ['./src/index.ts', ...getFiles('./src/components', ['.js', '.ts', '.jsx', '.tsx'])],
12
+ output: [
13
+ {
14
+ format: 'cjs',
15
+ dir: 'dist',
16
+ sourcemap: true,
17
+ preserveModules: true,
18
+ preserveModulesRoot: 'src',
19
+ exports: 'named',
20
+ },
21
+ ],
22
+ plugins: [
23
+ resolve({
24
+ browser: true,
25
+ }),
26
+ commonjs(),
27
+ typescript({
28
+ tsconfig: './tsconfig.json',
29
+ declaration: true,
30
+ declarationDir: 'dist',
31
+ exclude: [
32
+ 'src/*.widget.{js,jsx,ts,tsx}',
33
+ 'src/stories/**',
34
+ 'src/tests/**',
35
+ 'node_modules',
36
+ 'dist',
37
+ 'lib/janus.js',
38
+ ],
39
+ }),
40
+ babel({
41
+ include: ['**.js', 'node_modules/**'],
42
+ babelHelpers: 'bundled',
43
+ presets: ['@babel/preset-env'],
44
+ }),
45
+ postcss(),
46
+ terser(),
47
+ generatePackageJson({
48
+ baseContents: (pkg) => ({
49
+ name: pkg.name,
50
+ author: pkg.author,
51
+ dependencies: pkg.dependencies,
52
+ private: pkg.private,
53
+ main: './index.js',
54
+ types: './index.d.ts',
55
+ }),
56
+ }),
57
+ ],
58
+ external: ['react', 'react-dom', 'react-scripts'],
59
+ }
@@ -0,0 +1,28 @@
1
+ /* eslint-disable import/prefer-default-export */
2
+ const fs = require('fs');
3
+
4
+ export const getFiles = (entry, extensions = [], excludeExtensions = []) => {
5
+ let fileNames = [];
6
+ const dirs = fs.readdirSync(entry);
7
+
8
+ dirs.forEach((dir) => {
9
+ const path = `${entry}/${dir}`;
10
+
11
+ if (fs.lstatSync(path).isDirectory()) {
12
+ fileNames = [
13
+ ...fileNames,
14
+ ...getFiles(path, extensions, excludeExtensions),
15
+ ];
16
+
17
+ return;
18
+ }
19
+
20
+ if (!excludeExtensions.some((exclude) => dir.endsWith(exclude))
21
+ && extensions.some((ext) => dir.endsWith(ext))
22
+ ) {
23
+ fileNames.push(path);
24
+ }
25
+ });
26
+
27
+ return fileNames;
28
+ };