nuxt-telegram-mini-app 0.0.2 → 0.0.3
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/.github/dependabot.yml +6 -0
- package/README.md +45 -5
- package/app/composables/telegram.ts +370 -36
- package/app/pages/components.vue +283 -32
- package/app/types/telegram-webapp.ts +157 -3
- package/app/utils/color.ts +29 -5
- package/nuxt.config.ts +1 -1
- package/package.json +17 -17
- package/tests/pages.spec.ts +9 -12
- package/tests/telegram.spec.ts +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-telegram-mini-app",
|
|
3
3
|
"description": "Structure and configurations for building a Telegram Mini App using Nuxt and TailWind, hosted on Netlify.",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.3",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "nuxt build",
|
|
@@ -21,26 +21,26 @@
|
|
|
21
21
|
"url": "https://github.com/patricktobias86"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@nuxt/eslint": "^1.
|
|
25
|
-
"@nuxt/fonts": "^0.
|
|
26
|
-
"@nuxt/icon": "^2.
|
|
27
|
-
"eslint": "^
|
|
28
|
-
"nuxt": "^4.
|
|
29
|
-
"vue": "^3.5.
|
|
30
|
-
"vue-router": "^
|
|
24
|
+
"@nuxt/eslint": "^1.16.0",
|
|
25
|
+
"@nuxt/fonts": "^0.14.0",
|
|
26
|
+
"@nuxt/icon": "^2.2.3",
|
|
27
|
+
"eslint": "^10.4.1",
|
|
28
|
+
"nuxt": "^4.4.8",
|
|
29
|
+
"vue": "^3.5.35",
|
|
30
|
+
"vue-router": "^5.1.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@nuxtjs/tailwindcss": "^6.14.0",
|
|
34
|
-
"@types/node": "^
|
|
35
|
-
"@vitest/coverage-v8": "^
|
|
36
|
-
"@vue/test-utils": "^2.4.
|
|
37
|
-
"happy-dom": "^
|
|
38
|
-
"jsdom": "^
|
|
39
|
-
"typescript": "^
|
|
40
|
-
"vitest": "^
|
|
34
|
+
"@types/node": "^25.9.2",
|
|
35
|
+
"@vitest/coverage-v8": "^4.1.8",
|
|
36
|
+
"@vue/test-utils": "^2.4.11",
|
|
37
|
+
"happy-dom": "^20.10.2",
|
|
38
|
+
"jsdom": "^29.1.1",
|
|
39
|
+
"typescript": "^6.0.3",
|
|
40
|
+
"vitest": "^4.1.8"
|
|
41
41
|
},
|
|
42
42
|
"publishConfig": {
|
|
43
43
|
"access": "public",
|
|
44
44
|
"registry": "https://registry.npmjs.org"
|
|
45
|
-
|
|
46
|
-
}
|
|
45
|
+
}
|
|
46
|
+
}
|
package/tests/pages.spec.ts
CHANGED
|
@@ -2,10 +2,12 @@ import { describe, it, expect, beforeEach, vi } from 'vitest'
|
|
|
2
2
|
import { createRouter, createWebHistory } from 'vue-router'
|
|
3
3
|
import { mount } from '@vue/test-utils'
|
|
4
4
|
import { defineComponent, h, ref, computed } from 'vue'
|
|
5
|
+
import { useMainButton, useInitData, useThemeParams } from '~/composables/telegram'
|
|
6
|
+
import { toHex } from '~/utils/color'
|
|
5
7
|
|
|
6
8
|
// Mock global process
|
|
7
9
|
Object.defineProperty(globalThis, 'process', {
|
|
8
|
-
value: { client: true }
|
|
10
|
+
value: { client: true, env: { NODE_ENV: 'test' } }
|
|
9
11
|
})
|
|
10
12
|
|
|
11
13
|
// Mock Nuxt composables
|
|
@@ -21,8 +23,8 @@ vi.mock('#app', () => ({
|
|
|
21
23
|
})
|
|
22
24
|
}))
|
|
23
25
|
|
|
24
|
-
vi.mock('vue-router', () => {
|
|
25
|
-
const actual = vi.importActual('vue-router')
|
|
26
|
+
vi.mock('vue-router', async () => {
|
|
27
|
+
const actual = await vi.importActual<typeof import('vue-router')>('vue-router')
|
|
26
28
|
return {
|
|
27
29
|
...actual,
|
|
28
30
|
useRouter: () => ({
|
|
@@ -366,23 +368,21 @@ describe('Page Components', () => {
|
|
|
366
368
|
it('should initialize Telegram composables correctly', () => {
|
|
367
369
|
const TestPage = defineComponent({
|
|
368
370
|
setup() {
|
|
369
|
-
const { useMainButton, useInitData, useThemeParams } = require('~/composables/telegram')
|
|
370
|
-
|
|
371
371
|
const main = useMainButton()
|
|
372
372
|
const init = useInitData()
|
|
373
373
|
const theme = useThemeParams()
|
|
374
374
|
|
|
375
375
|
return {
|
|
376
|
-
mainButtonText: main.text,
|
|
376
|
+
mainButtonText: main.text.value,
|
|
377
377
|
userName: init.user.value?.first_name,
|
|
378
|
-
bgColor: theme.backgroundColor
|
|
378
|
+
bgColor: theme.backgroundColor.value
|
|
379
379
|
}
|
|
380
380
|
},
|
|
381
381
|
template: `
|
|
382
382
|
<div>
|
|
383
|
-
<p>Button: {{ mainButtonText
|
|
383
|
+
<p>Button: {{ mainButtonText }}</p>
|
|
384
384
|
<p>User: {{ userName }}</p>
|
|
385
|
-
<p>BG: {{ bgColor
|
|
385
|
+
<p>BG: {{ bgColor }}</p>
|
|
386
386
|
</div>
|
|
387
387
|
`
|
|
388
388
|
})
|
|
@@ -399,9 +399,6 @@ describe('Page Components', () => {
|
|
|
399
399
|
it('should use theme colors correctly', () => {
|
|
400
400
|
const TestPage = defineComponent({
|
|
401
401
|
setup() {
|
|
402
|
-
const { useThemeParams } = require('~/composables/telegram')
|
|
403
|
-
const { toHex } = require('~/utils/color')
|
|
404
|
-
|
|
405
402
|
const theme = useThemeParams()
|
|
406
403
|
|
|
407
404
|
return {
|
package/tests/telegram.spec.ts
CHANGED
|
@@ -97,7 +97,7 @@ describe('telegram composables', () => {
|
|
|
97
97
|
|
|
98
98
|
// Test that text changes work
|
|
99
99
|
main.setParams({ text: 'Updated' })
|
|
100
|
-
expect(main.text.value).toBe('
|
|
100
|
+
expect(main.text.value).toBe('Updated')
|
|
101
101
|
|
|
102
102
|
main.unmount()
|
|
103
103
|
expect(main.mounted.value).toBe(false)
|