@gamelearn/arcade-components 1.35.5 → 1.35.6

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/README.md CHANGED
@@ -1,107 +1,107 @@
1
- # Arcade Components
2
- > librería de componentes para Arcade (aka engine 2.0)
3
-
4
- [![NPM](https://img.shields.io/npm/v/arcade-components.svg)](https://www.npmjs.com/package/arcade-components) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
5
-
6
- ## Install
7
-
8
- ```bash
9
- yarn add @gamelearn/arcade-components
10
- ```
11
-
12
- ## Usage
13
- ##
14
-
15
- ```jsx
16
- import React, { Component } from 'react';
17
-
18
- import { Button } from 'arcade-components';
19
-
20
- export default class App extends Component {
21
- render() {
22
- return (
23
- <div>
24
- <Button>Enjoy</Button>
25
- </div>
26
- );
27
- }
28
- }
29
-
30
- ```
31
-
32
- ## Generar version hotfix para arcade/master-stg
33
-
34
- Para generar una version hotfix nos vamos al commit que desplego la version que utiliza actualmente arcade/master-stg y creamos una rama sobre ella.
35
-
36
- Generamos los cambios o hacemos cherrypick de ellos si ya estan creados y una vez terminemos con los cambios tendremos que cambiar la version del package.json a una tal que asi :
37
-
38
- `"version": "1.3.5-fix-1",`
39
-
40
- Habiendo cambiado ya la version para publicarla ejecutamos:
41
- * `npm run publish-hotfix`
42
-
43
- Una vez publicada en npm ir a la versión master de arcade y sustituir la versión de arcade-components.
44
-
45
- ## Available Scripts
46
-
47
- Para ver Storybook en local
48
-
49
- ### `yarn start`
50
-
51
- Para compilar la librería a dist
52
-
53
- ### `yarn compile`
54
-
55
- Para dejar a babel observando cambios y ejecuntando auto-compilación puedes pasarle --watch
56
-
57
- `yarn compile --watch`
58
-
59
- ### `yarn generate <componentName>`
60
-
61
- Para añadir un componente nuevo se recomienda usar el generador automático que hara el scaffolding básico de dicho componente, coge el nombre como primer parámetro y si lo llamas sin parámetro te lo preguntará por el prompt.
62
-
63
- `yarn generate`
64
-
65
- ## How to link arcade-components in other repos (WIP)
66
-
67
- Para trabajar con arcade-components en local si necesidad de subir a git ni a npm no podemos trabajar con `yarn link` ya que da un error con los hooks de react.
68
-
69
- Cómo solución alternativa podemos instalar `yalc` que permite publicar el paquete en local e importarlo desde `arcade`.
70
-
71
- ```bash
72
- yarn global add yalc
73
- ```
74
- Si teneis problemas instalándolo en global :
75
- yarn global add yalc --prefix /usr/local
76
-
77
- Para generar el paquete en el store local:
78
-
79
- ```bash
80
- yarn
81
- yarn compile
82
- yalc publish o yarn yalc publish
83
- ```
84
-
85
- Si queremos escuchar los cambios y que se vayan publicando en el store de yalc se puede hacer directamente con:
86
-
87
- ```bash
88
- yarn watch
89
- ```
90
-
91
- Después, en el repositorio de `arcade` tendremos que linkar el paquete generado de la siguiente forma:
92
-
93
- ```bash
94
- yalc link @gamelearn/arcade-components
95
- ```
96
-
97
- Y voilá, ya podremos trabajar con arcade y arcade-components en local sin publicar nada.
98
-
99
- Una vez terminemos de trabajar con el paquete linkado en `arcade`, no nos olvidemos de borrar el link:
100
-
101
- ```bash
102
- yalc remove --all
103
- ```
104
-
105
- ## License
106
-
107
- UNLICENSED © [gamelearn](https://github.com/gamelearn)
1
+ # Arcade Components
2
+ > librería de componentes para Arcade (aka engine 2.0)
3
+
4
+ [![NPM](https://img.shields.io/npm/v/arcade-components.svg)](https://www.npmjs.com/package/arcade-components) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
5
+
6
+ ## Install
7
+
8
+ ```bash
9
+ yarn add @gamelearn/arcade-components
10
+ ```
11
+
12
+ ## Usage
13
+ ##
14
+
15
+ ```jsx
16
+ import React, { Component } from 'react';
17
+
18
+ import { Button } from 'arcade-components';
19
+
20
+ export default class App extends Component {
21
+ render() {
22
+ return (
23
+ <div>
24
+ <Button>Enjoy</Button>
25
+ </div>
26
+ );
27
+ }
28
+ }
29
+
30
+ ```
31
+
32
+ ## Generar version hotfix para arcade/master-stg
33
+
34
+ Para generar una version hotfix nos vamos al commit que desplego la version que utiliza actualmente arcade/master-stg y creamos una rama sobre ella.
35
+
36
+ Generamos los cambios o hacemos cherrypick de ellos si ya estan creados y una vez terminemos con los cambios tendremos que cambiar la version del package.json a una tal que asi :
37
+
38
+ `"version": "1.3.5-fix-1",`
39
+
40
+ Habiendo cambiado ya la version para publicarla ejecutamos:
41
+ * `npm run publish-hotfix`
42
+
43
+ Una vez publicada en npm ir a la versión master de arcade y sustituir la versión de arcade-components.
44
+
45
+ ## Available Scripts
46
+
47
+ Para ver Storybook en local
48
+
49
+ ### `yarn start`
50
+
51
+ Para compilar la librería a dist
52
+
53
+ ### `yarn compile`
54
+
55
+ Para dejar a babel observando cambios y ejecuntando auto-compilación puedes pasarle --watch
56
+
57
+ `yarn compile --watch`
58
+
59
+ ### `yarn generate <componentName>`
60
+
61
+ Para añadir un componente nuevo se recomienda usar el generador automático que hara el scaffolding básico de dicho componente, coge el nombre como primer parámetro y si lo llamas sin parámetro te lo preguntará por el prompt.
62
+
63
+ `yarn generate`
64
+
65
+ ## How to link arcade-components in other repos (WIP)
66
+
67
+ Para trabajar con arcade-components en local si necesidad de subir a git ni a npm no podemos trabajar con `yarn link` ya que da un error con los hooks de react.
68
+
69
+ Cómo solución alternativa podemos instalar `yalc` que permite publicar el paquete en local e importarlo desde `arcade`.
70
+
71
+ ```bash
72
+ yarn global add yalc
73
+ ```
74
+ Si teneis problemas instalándolo en global :
75
+ yarn global add yalc --prefix /usr/local
76
+
77
+ Para generar el paquete en el store local:
78
+
79
+ ```bash
80
+ yarn
81
+ yarn compile
82
+ yalc publish o yarn yalc publish
83
+ ```
84
+
85
+ Si queremos escuchar los cambios y que se vayan publicando en el store de yalc se puede hacer directamente con:
86
+
87
+ ```bash
88
+ yarn watch
89
+ ```
90
+
91
+ Después, en el repositorio de `arcade` tendremos que linkar el paquete generado de la siguiente forma:
92
+
93
+ ```bash
94
+ yalc link @gamelearn/arcade-components
95
+ ```
96
+
97
+ Y voilá, ya podremos trabajar con arcade y arcade-components en local sin publicar nada.
98
+
99
+ Una vez terminemos de trabajar con el paquete linkado en `arcade`, no nos olvidemos de borrar el link:
100
+
101
+ ```bash
102
+ yalc remove --all
103
+ ```
104
+
105
+ ## License
106
+
107
+ UNLICENSED © [gamelearn](https://github.com/gamelearn)
@@ -117,14 +117,6 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
117
117
  var voiceOver = currentLineData.voiceOver,
118
118
  decision = currentLineData.decision;
119
119
  var isFlex = currentLineData.flex;
120
- var listProps = {
121
- characters: currentCharacters,
122
- lodSettings: lodSettings,
123
- actors: actors,
124
- currentMessage: currentMessage || {},
125
- slots: !isVoiceOver ? currentLineData.slots : voiceOverSlots,
126
- flex: isFlex
127
- };
128
120
 
129
121
  var _useState13 = (0, _react.useState)([]),
130
122
  _useState14 = _slicedToArray(_useState13, 2),
@@ -146,15 +138,15 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
146
138
  var previousLineWasDecision = (0, _react.useCallback)(function () {
147
139
  if (isBranched) {
148
140
  // if we have edges, we need to check if the previous line was a decision
149
- var lastLine = findLastLineBranched();
150
- return lastLine === null || lastLine === void 0 ? void 0 : lastLine.decision;
151
- } else {
152
- // if there is no branching, the previous line is the previous one
153
- var _lastLine = lines[currentLine - 1] ? lines[currentLine - 1] : {};
141
+ var _lastLine = findLastLineBranched();
154
142
 
155
- return currentLine > 0 && (_lastLine === null || _lastLine === void 0 ? void 0 : _lastLine.decision);
156
- }
157
- }, [currentLine, isBranched, lines, lastNodeId, edges]);
143
+ return _lastLine === null || _lastLine === void 0 ? void 0 : _lastLine.decision;
144
+ } // if there is no branching, the previous line is the previous one
145
+
146
+
147
+ var lastLine = lines[currentLine - 1] ? lines[currentLine - 1] : {};
148
+ return currentLine > 0 && (lastLine === null || lastLine === void 0 ? void 0 : lastLine.decision);
149
+ }, [isBranched, findLastLineBranched, lines, currentLine]);
158
150
  var translate = (0, _react.useCallback)(function (id) {
159
151
  return emitEvent({
160
152
  type: 'translate',
@@ -181,7 +173,15 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
181
173
  }, [currentLineData, isVoiceOver]);
182
174
  var currentMessage = (0, _react.useMemo)(function () {
183
175
  return !isDecision ? getCurrentMessage() : {};
184
- }, [getCurrentMessage, isDecision]); // Recupera la antigua linea de la conversacion para conservar los personajes en voice-over
176
+ }, [getCurrentMessage, isDecision]);
177
+ var listProps = {
178
+ characters: currentCharacters,
179
+ lodSettings: lodSettings,
180
+ actors: actors,
181
+ currentMessage: currentMessage || {},
182
+ slots: !isVoiceOver ? currentLineData.slots : voiceOverSlots,
183
+ flex: isFlex
184
+ }; // Recupera la antigua linea de la conversacion para conservar los personajes en voice-over
185
185
 
186
186
  var leftWithSlots = lines.slice(0, currentLine + 1).reverse().find(function (line) {
187
187
  return line.slots;
@@ -306,7 +306,7 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
306
306
  } else {
307
307
  finishConversation();
308
308
  }
309
- }, [currentLineData.id, edges, finishConversation, lines]);
309
+ }, [currentLineData.id, edges, edgesHistory, finishConversation, lastNodeId, lines]);
310
310
  var handleClickNext = (0, _react.useCallback)(function (choice, reset) {
311
311
  var isLast = false;
312
312
  setTTsStart(false);
@@ -336,7 +336,7 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
336
336
  if (!isLast) {
337
337
  setStarted(true);
338
338
  }
339
- }, [currentLine, currentLineData.decision, finishConversation, handleBranchDirection, handleDecisionBranch, isBranched, lines.length, edgesHistory]);
339
+ }, [currentLine, currentLineData.decision, currentLineData.id, finishConversation, handleBranchDirection, handleDecisionBranch, isBranched, lines.length, edgesHistory]);
340
340
 
341
341
  var handleClickBack = function handleClickBack() {
342
342
  setStarted(false);
@@ -352,7 +352,7 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
352
352
  setStarted(true);
353
353
  };
354
354
 
355
- var isEndNode = function isEndNode() {
355
+ var isEndNode = (0, _react.useCallback)(function () {
356
356
  if (isBranched) {
357
357
  return currentLineData && currentLineData.type !== 'conversationalDecision' && !edges.find(function (edge) {
358
358
  return edge.fromId === currentLineData.id;
@@ -360,7 +360,7 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
360
360
  }
361
361
 
362
362
  return currentLine === lines.length - 1;
363
- };
363
+ }, [currentLine, currentLineData, edges, isBranched, lines.length]);
364
364
 
365
365
  var manualClickNext = function manualClickNext() {
366
366
  playSound('click-ui');
@@ -429,7 +429,7 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
429
429
  return function () {
430
430
  stop();
431
431
  };
432
- }, [currentMessage, start, stop, handleClickNext, currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType, autoplayCond, audioFailed, lines]); // Calculate start node
432
+ }, [currentMessage, start, stop, handleClickNext, currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType, autoplayCond, audioFailed, lines, isEndNode]); // Calculate start node
433
433
 
434
434
  (0, _react.useEffect)(function () {
435
435
  if (isBranched && !mounted) {
package/package.json CHANGED
@@ -1,114 +1,114 @@
1
- {
2
- "name": "@gamelearn/arcade-components",
3
- "author": "Gamelearn",
4
- "license": "unlicense",
5
- "version": "1.35.5",
6
- "main": "dist/index.js",
7
- "files": [
8
- "dist",
9
- "README.md"
10
- ],
11
- "repository": {
12
- "type": "git",
13
- "url": "https://github.com/gamelearn/arcade-components"
14
- },
15
- "dependencies": {
16
- "@babel/runtime": "^7.18.6",
17
- "@gamelearn/arcade-styles": "0.15.8",
18
- "@gamelearn/arcade-three-core": "1.17.1",
19
- "@react-three/drei": "9.4.3",
20
- "@react-three/fiber": "8.0.17",
21
- "@testing-library/jest-dom": "^5.16.4",
22
- "@testing-library/react": "^13.1.1",
23
- "@testing-library/user-event": "13.5.0",
24
- "global": "^4.4.0",
25
- "gsap": "^3.10.1",
26
- "hls.js": "0.12.4",
27
- "html-react-parser": "^1.4.0",
28
- "interactjs": "^1.10.11",
29
- "konva": "^7.2.5",
30
- "prop-types": "15.7.2",
31
- "react-konva": "^18.1.0",
32
- "react-konva-utils": "^0.3.0",
33
- "react-pdf": "5.2.0",
34
- "react-promise-suspense": "0.3.3",
35
- "react-typist": "^2.0.5",
36
- "three": "0.139.2",
37
- "web-vitals": "0.2.4"
38
- },
39
- "scripts": {
40
- "start": "npm run storybook",
41
- "clean": "rimraf dist",
42
- "watch": "npx nodemon -e js --ignore dist --exec \"yarn compile && yalc push --changed\"",
43
- "compile": "npm run clean && cross-env NODE_ENV=production babel src -d dist --ignore src/**/*.stories.js,src/**/*.test.js,src/setupTests.js",
44
- "test": "react-scripts test --watchAll=false",
45
- "test:watch": "react-scripts test",
46
- "eject": "react-scripts eject",
47
- "storybook": "start-storybook -p 6006 -s public",
48
- "build-storybook": "build-storybook -o build",
49
- "generate": "plop",
50
- "lint": "npx eslint src --ext js,json",
51
- "lint:fix": "npx eslint src --ext js,json --fix",
52
- "lint:quiet": "npx eslint src --ext js,json --quiet",
53
- "publish-hotfix": "yarn compile && npm publish && npm run version-tag",
54
- "version-tag": "P_VER=$(cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]') && git tag v$P_VER && git push origin v$P_VER"
55
- },
56
- "browserslist": {
57
- "production": [
58
- ">0.2%",
59
- "not dead",
60
- "not op_mini all"
61
- ],
62
- "development": [
63
- "last 1 chrome version",
64
- "last 1 firefox version",
65
- "last 1 safari version"
66
- ]
67
- },
68
- "devDependencies": {
69
- "@babel/cli": "7.12.10",
70
- "@babel/eslint-parser": "^7.15.8",
71
- "@babel/preset-env": "7.12.11",
72
- "@babel/preset-react": "7.12.10",
73
- "@gamelearn/version": "^1.3.1",
74
- "@react-three/test-renderer": "6.0.6",
75
- "@storybook/addon-actions": "6.1.11",
76
- "@storybook/addon-essentials": "6.1.11",
77
- "@storybook/addon-links": "6.1.11",
78
- "@storybook/addons": "^6.3.8",
79
- "@storybook/node-logger": "6.1.11",
80
- "@storybook/preset-create-react-app": "3.1.5",
81
- "@storybook/react": "6.1.11",
82
- "@storybook/theming": "^6.3.8",
83
- "babel-loader": "8.1.0",
84
- "cross-env": "7.0.3",
85
- "eslint-config-airbnb": "^18.2.1",
86
- "eslint-config-prettier": "^8.3.0",
87
- "eslint-plugin-json-format": "^2.0.1",
88
- "eslint-plugin-prettier": "^4.0.0",
89
- "husky": "4.3.0",
90
- "nodemon": "^2.0.13",
91
- "plop": "^2.7.4",
92
- "prettier": "^2.5.0",
93
- "react": "18.0.0",
94
- "react-dom": "18.0.0",
95
- "react-scripts": "4.0.1",
96
- "rimraf": "3.0.2"
97
- },
98
- "jest": {
99
- "transformIgnorePatterns": [
100
- "node_modules/(?!(three)/)"
101
- ],
102
- "moduleNameMapper": {
103
- "^react-pdf$": "react-pdf/dist/umd/entry.jest",
104
- "^react-konva-utils$": "react-pdf/dist/umd/entry.jest"
105
- }
106
- },
107
- "husky": {
108
- "hooks": {
109
- "prepare-commit-msg": "bash node_modules/@gamelearn/version/scripts/update_version.sh -p hooks.config ${HUSKY_GIT_PARAMS}",
110
- "post-commit": "bash node_modules/@gamelearn/version/scripts/after_version_update.sh -p hooks.config",
111
- "post-merge": "bash node_modules/@gamelearn/version/scripts/after_version_update.sh -p hooks.config"
112
- }
113
- }
114
- }
1
+ {
2
+ "name": "@gamelearn/arcade-components",
3
+ "author": "Gamelearn",
4
+ "license": "unlicense",
5
+ "version": "1.35.6",
6
+ "main": "dist/index.js",
7
+ "files": [
8
+ "dist",
9
+ "README.md"
10
+ ],
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "https://github.com/gamelearn/arcade-components"
14
+ },
15
+ "dependencies": {
16
+ "@babel/runtime": "^7.18.6",
17
+ "@gamelearn/arcade-styles": "0.15.8",
18
+ "@gamelearn/arcade-three-core": "1.17.1",
19
+ "@react-three/drei": "9.4.3",
20
+ "@react-three/fiber": "8.0.17",
21
+ "@testing-library/jest-dom": "^5.16.4",
22
+ "@testing-library/react": "^13.1.1",
23
+ "@testing-library/user-event": "13.5.0",
24
+ "global": "^4.4.0",
25
+ "gsap": "^3.10.1",
26
+ "hls.js": "0.12.4",
27
+ "html-react-parser": "^1.4.0",
28
+ "interactjs": "^1.10.11",
29
+ "konva": "^7.2.5",
30
+ "prop-types": "15.7.2",
31
+ "react-konva": "^18.1.0",
32
+ "react-konva-utils": "^0.3.0",
33
+ "react-pdf": "5.2.0",
34
+ "react-promise-suspense": "0.3.3",
35
+ "react-typist": "^2.0.5",
36
+ "three": "0.139.2",
37
+ "web-vitals": "0.2.4"
38
+ },
39
+ "scripts": {
40
+ "start": "npm run storybook",
41
+ "clean": "rimraf dist",
42
+ "watch": "npx nodemon -e js --ignore dist --exec \"yarn compile && yalc push --changed\"",
43
+ "compile": "npm run clean && cross-env NODE_ENV=production babel src -d dist --ignore src/**/*.stories.js,src/**/*.test.js,src/setupTests.js",
44
+ "test": "react-scripts test --watchAll=false",
45
+ "test:watch": "react-scripts test",
46
+ "eject": "react-scripts eject",
47
+ "storybook": "start-storybook -p 6006 -s public",
48
+ "build-storybook": "build-storybook -o build",
49
+ "generate": "plop",
50
+ "lint": "npx eslint src --ext js,json",
51
+ "lint:fix": "npx eslint src --ext js,json --fix",
52
+ "lint:quiet": "npx eslint src --ext js,json --quiet",
53
+ "publish-hotfix": "yarn compile && npm publish && npm run version-tag",
54
+ "version-tag": "P_VER=$(cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]') && git tag v$P_VER && git push origin v$P_VER"
55
+ },
56
+ "browserslist": {
57
+ "production": [
58
+ ">0.2%",
59
+ "not dead",
60
+ "not op_mini all"
61
+ ],
62
+ "development": [
63
+ "last 1 chrome version",
64
+ "last 1 firefox version",
65
+ "last 1 safari version"
66
+ ]
67
+ },
68
+ "devDependencies": {
69
+ "@babel/cli": "7.12.10",
70
+ "@babel/eslint-parser": "^7.15.8",
71
+ "@babel/preset-env": "7.12.11",
72
+ "@babel/preset-react": "7.12.10",
73
+ "@gamelearn/version": "^1.3.1",
74
+ "@react-three/test-renderer": "6.0.6",
75
+ "@storybook/addon-actions": "6.1.11",
76
+ "@storybook/addon-essentials": "6.1.11",
77
+ "@storybook/addon-links": "6.1.11",
78
+ "@storybook/addons": "^6.3.8",
79
+ "@storybook/node-logger": "6.1.11",
80
+ "@storybook/preset-create-react-app": "3.1.5",
81
+ "@storybook/react": "6.1.11",
82
+ "@storybook/theming": "^6.3.8",
83
+ "babel-loader": "8.1.0",
84
+ "cross-env": "7.0.3",
85
+ "eslint-config-airbnb": "^18.2.1",
86
+ "eslint-config-prettier": "^8.3.0",
87
+ "eslint-plugin-json-format": "^2.0.1",
88
+ "eslint-plugin-prettier": "^4.0.0",
89
+ "husky": "4.3.0",
90
+ "nodemon": "^2.0.13",
91
+ "plop": "^2.7.4",
92
+ "prettier": "^2.5.0",
93
+ "react": "18.0.0",
94
+ "react-dom": "18.0.0",
95
+ "react-scripts": "4.0.1",
96
+ "rimraf": "3.0.2"
97
+ },
98
+ "jest": {
99
+ "transformIgnorePatterns": [
100
+ "node_modules/(?!(three)/)"
101
+ ],
102
+ "moduleNameMapper": {
103
+ "^react-pdf$": "react-pdf/dist/umd/entry.jest",
104
+ "^react-konva-utils$": "react-pdf/dist/umd/entry.jest"
105
+ }
106
+ },
107
+ "husky": {
108
+ "hooks": {
109
+ "prepare-commit-msg": "bash node_modules/@gamelearn/version/scripts/update_version.sh -p hooks.config ${HUSKY_GIT_PARAMS}",
110
+ "post-commit": "bash node_modules/@gamelearn/version/scripts/after_version_update.sh -p hooks.config",
111
+ "post-merge": "bash node_modules/@gamelearn/version/scripts/after_version_update.sh -p hooks.config"
112
+ }
113
+ }
114
+ }