@jetthai/cuora 1.1.281-dev-1 → 1.1.281-dev4

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/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [1.1.281-dev4](https://github.com/jetthai/cuora-module/compare/v1.1.281-dev3...v1.1.281-dev4) (2024-06-20)
6
+
7
+ ### [1.1.281-dev3](https://github.com/jetthai/cuora-module/compare/v1.1.128-dev-2...v1.1.281-dev3) (2024-06-20)
8
+
9
+ ### [1.1.128-dev-2](https://github.com/jetthai/cuora-module/compare/v1.1.281-dev-1...v1.1.128-dev-2) (2024-06-20)
10
+
5
11
  ### [1.1.281-dev-1](https://github.com/jetthai/cuora-module/compare/v1.1.281...v1.1.281-dev-1) (2024-06-20)
6
12
 
7
13
  ### [1.1.281](https://github.com/jetthai/cuora-module/compare/v1.1.280...v1.1.281) (2024-06-18)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.1.281-dev-1",
3
+ "version": "1.1.281-dev4",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
@@ -286,7 +286,18 @@ export default function (request) {
286
286
  services: {
287
287
  fetchConfig: async (context, event) => {
288
288
  const [site, layout] = await Promise.all([request.send(api.getConfig({ appSecret })), request.send(api.getLayoutConfig({ appSecret }))])
289
- return { siteConfig: JSON.parse(window.atob(site.config)), layoutConfig: layout.config }
289
+ const base64Url = site.config.split('.')[0]
290
+ const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/')
291
+ const decodeResult = decodeURIComponent(
292
+ window
293
+ .atob(base64)
294
+ .split('')
295
+ .map((c) => {
296
+ return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2)
297
+ })
298
+ .join('')
299
+ )
300
+ return { siteConfig: JSON.parse(decodeResult), layoutConfig: layout.config }
290
301
  },
291
302
  fetchFeeds: async (context, event) => {
292
303
  return await request.send(api.feeds({ appSecret }))
@@ -110,6 +110,10 @@ export default function (request) {
110
110
  target: '.loaded',
111
111
  actions: ['setAmount', 'clearCalculation'],
112
112
  },
113
+ INPUT_AMOUNT: {
114
+ target: '.loaded',
115
+ actions: ['inputAmount', 'clearCalculation'],
116
+ },
113
117
  CALCULATE: {
114
118
  target: '.debouncing',
115
119
  actions: 'clearCalculation',
@@ -151,6 +155,9 @@ export default function (request) {
151
155
  amount: event.data,
152
156
  }
153
157
  }),
158
+ inputAmount: assign((context, event) => {
159
+ return { amount: preciseAdd(`${parseFloat(context.amount || 0)}`, `${parseFloat(event.data)}`) }
160
+ }),
154
161
  setAddress: assign((context, event) => {
155
162
  return {
156
163
  sourceAddress: event.data,
@@ -218,3 +225,15 @@ export default function (request) {
218
225
  }
219
226
  )
220
227
  }
228
+
229
+ function preciseAdd(a, b) {
230
+ let aStr = a.toString()
231
+ let bStr = b.toString()
232
+
233
+ let aDecimalPlaces = aStr.split('.')[1] ? aStr.split('.')[1].length : 0
234
+ let bDecimalPlaces = bStr.split('.')[1] ? bStr.split('.')[1].length : 0
235
+
236
+ let factor = Math.pow(10, Math.max(aDecimalPlaces, bDecimalPlaces))
237
+
238
+ return (Math.round(a * factor) + Math.round(b * factor)) / factor
239
+ }
@@ -135,10 +135,17 @@ export default function (request) {
135
135
  target: '.debouncing',
136
136
  actions: 'clearKeyword',
137
137
  },
138
- SET_TAG_ID: {
139
- target: 'fetchingGames',
140
- actions: 'setTagId',
141
- },
138
+ SET_TAG_ID: [
139
+ {
140
+ target: 'fetchingGames',
141
+ actions: ['setTagId', 'setKeyword'],
142
+ cond: 'isGameTagMode',
143
+ },
144
+ {
145
+ target: 'fetchingGames',
146
+ actions: 'setTagId',
147
+ },
148
+ ],
142
149
  PRESS_ENTER: {
143
150
  target: 'fetchingGamesByKeyword',
144
151
  },
@@ -273,6 +280,9 @@ export default function (request) {
273
280
  isInitialized: (context, event) => {
274
281
  return context.initialized
275
282
  },
283
+ isGameTagMode: (context, event) => {
284
+ return event.data.isGameTagMode
285
+ },
276
286
  },
277
287
  services: {
278
288
  fetchTags: async (context, event) => {