-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #88 from Telegram-Web-Apps/feature/restore-compone…
…nts-state Feature/restore components state
- Loading branch information
Showing
218 changed files
with
5,554 additions
and
2,655 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@twa.js/sdk-react": minor | ||
"@twa.js/sdk-solid": minor | ||
--- | ||
|
||
Implement CloudStorage utilities |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@twa.js/bridge": minor | ||
--- | ||
|
||
Implement new method - request. It allows calling specified methods and capturing specified events. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@twa.js/utils": patch | ||
--- | ||
|
||
Move some utilities related to colors, events handling and some types to separate packages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"eslint-config-custom": minor | ||
"jest-config-custom": minor | ||
--- | ||
|
||
Add new rules to eslint config. Jest config now uses babel-jest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
"@twa.js/event-emitter": patch | ||
"@twa.js/util-types": patch | ||
"@twa.js/parsing": patch | ||
"@twa.js/colors": patch | ||
--- | ||
|
||
Release package. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@twa.js/init-data": patch | ||
--- | ||
|
||
Switch to new package parsing utilities |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@twa.js/sdk": minor | ||
--- | ||
|
||
Implement new CloudStorage component. Implement 6.9 methods. Make components restore from the session storage. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ | |
"rollup-preset-solid": "^2.0.1", | ||
"ts-jest": "^29.1.1", | ||
"tslib": "^2.6.0", | ||
"turbo": "^1.9.7", | ||
"turbo": "^1.10.14", | ||
"typescript": "^5.1.6" | ||
}, | ||
"packageManager": "[email protected]", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { createDomEmitter } from './createDomEmitter.js'; | ||
|
||
interface CreateWindowOptions { | ||
innerWidth?: number; | ||
innerHeight?: number; | ||
env?: 'iframe'; | ||
} | ||
|
||
export type WindowSpy = jest.SpyInstance<Window & typeof globalThis>; | ||
|
||
/** | ||
* Mocks window and returns created spy. | ||
* @param options - additional options. | ||
*/ | ||
export function createWindow(options: CreateWindowOptions = {}): WindowSpy { | ||
const { innerWidth, innerHeight, env } = options; | ||
const postMessageSpy = jest.fn(); | ||
const wnd = { | ||
innerHeight, | ||
innerWidth, | ||
...createDomEmitter(), | ||
...(env === 'iframe' ? { | ||
top: 1, | ||
self: 2, | ||
parent: { postMessage: postMessageSpy }, | ||
} : {}), | ||
}; | ||
|
||
return jest.spyOn(window, 'window', 'get').mockImplementation(() => wnd as any); | ||
} | ||
|
||
// export function mockWindow( | ||
// options: MockWindowOptions = {}, | ||
// ): jest.SpyInstance<Window & typeof globalThis> { | ||
// const { innerWidth, innerHeight, env } = options; | ||
// const spy = jest.spyOn(window, 'window', 'get'); | ||
// const postMessageSpy = jest.fn(); | ||
// | ||
// beforeEach(() => { | ||
// const wnd = { | ||
// innerHeight, | ||
// innerWidth, | ||
// ...createDomEmitter(), | ||
// ...(env === 'iframe' ? { | ||
// top: 1, | ||
// self: 2, | ||
// parent: { postMessage: postMessageSpy }, | ||
// } : {}), | ||
// }; | ||
// spy.mockImplementation(() => wnd as any); | ||
// }); | ||
// | ||
// afterEach(() => { | ||
// postMessageSpy.mockReset(); | ||
// spy.mockReset(); | ||
// }); | ||
// | ||
// return spy; | ||
// } |
11 changes: 11 additions & 0 deletions
11
packages/bridge/__tests__/__utils__/dispatchWindowMessageEvent.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* Uses window.dispatchEvent function with specified message event | ||
* to dispatch event to imitate its creation by Telegram. | ||
* @param eventType - event name. | ||
* @param eventData - event payload. | ||
*/ | ||
export function dispatchWindowMessageEvent(eventType: string, eventData?: unknown): void { | ||
window.dispatchEvent(new MessageEvent('message', { | ||
data: JSON.stringify({ eventType, eventData }), | ||
})); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.