-
Notifications
You must be signed in to change notification settings - Fork 930
Create experiment modularized FM SDK #3822
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from 9 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
6a4a669
FM Modualization
zwu52 31fa5a1
Update dependecies to exp
zwu52 6b04715
update app dependency
zwu52 d777e33
Update README.md
zwu52 de78923
Integrate w/ API checker
zwu52 724bba9
Removing deps that are already included in the top level
zwu52 1c49b44
Mod Change
zwu52 36e7586
Merge branch 'master' of https://github.com/firebase/firebase-js-sdk …
zwu52 3d8a351
Update
zwu52 e4b967f
Add js doc
zwu52 4308cd3
Create release roll up
zwu52 69d9d1b
Add messaging to firebase-exp/
zwu52 3fdb6d9
Fix typing error
zwu52 370575c
Try fix type error
zwu52 0028246
Rmove moduale declartion
zwu52 f41f23a
fix
zwu52 96ceea6
Remove unused deps
zwu52 9847c41
updates dep versions
zwu52 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
|
@@ -11,4 +11,4 @@ | |
}, | ||
"typescript.tsdk": "node_modules/typescript/lib", | ||
"files.associations": { "*.json": "jsonc" } | ||
} | ||
} |
This file contains hidden or 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,32 @@ | ||
## API Report File for "@firebase/messaging-exp" | ||
|
||
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). | ||
|
||
```ts | ||
|
||
import { FirebaseApp } from '@firebase/app-types-exp'; | ||
import { FirebaseMessaging } from '@firebase/messaging-types-exp'; | ||
import { MessagePayload } from '@firebase/messaging-types-exp'; | ||
import { NextFn } from '@firebase/util'; | ||
import { Observer } from '@firebase/util'; | ||
import { Unsubscribe } from '@firebase/util'; | ||
|
||
// @public (undocumented) | ||
export function deleteToken(messaging: FirebaseMessaging): Promise<boolean>; | ||
|
||
// @public (undocumented) | ||
export function getMessaging(app: FirebaseApp): FirebaseMessaging; | ||
|
||
// @public (undocumented) | ||
export function getToken(messaging: FirebaseMessaging, options?: { | ||
vapidKey?: string; | ||
swReg?: ServiceWorkerRegistration; | ||
}): Promise<string>; | ||
|
||
// @public (undocumented) | ||
export function onMessage(messaging: FirebaseMessaging, nextOrObserver: NextFn<MessagePayload> | Observer<MessagePayload>): Unsubscribe; | ||
|
||
|
||
// (No @packageDocumentation comment for this package) | ||
|
||
``` |
This file contains hidden or 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,26 @@ | ||
/** | ||
* @license | ||
* Copyright 2020 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
module.exports = { | ||
extends: '../../config/.eslintrc.js', | ||
parserOptions: { | ||
project: 'tsconfig.json', | ||
// to make vscode-eslint work with monorepo | ||
// https://github.com/typescript-eslint/typescript-eslint/issues/251#issuecomment-463943250 | ||
tsconfigRootDir: __dirname | ||
} | ||
}; |
This file contains hidden or 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 @@ | ||
# @firebase/messaging | ||
|
||
This is the Firebase Cloud Messaging component of the Firebase JS SDK. | ||
|
||
**This package is not intended for direct usage, and should only be used via the officially supported [firebase](https://www.npmjs.com/package/firebase) package.** |
This file contains hidden or 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 @@ | ||
{ | ||
"extends": "../../config/api-extractor.json", | ||
// Point it to your entry point d.ts file. | ||
"mainEntryPointFilePath": "<projectFolder>/dist/index.d.ts", | ||
"dtsRollup": { | ||
"enabled": true | ||
} | ||
} |
This file contains hidden or 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,32 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
const karmaBase = require('../../config/karma.base'); | ||
|
||
const files = [`src/**/*.test.ts`]; | ||
|
||
module.exports = function (config) { | ||
const karmaConfig = { | ||
...karmaBase, | ||
files, | ||
frameworks: ['mocha'] | ||
}; | ||
|
||
config.set(karmaConfig); | ||
}; | ||
|
||
module.exports.files = files; |
This file contains hidden or 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,57 @@ | ||
{ | ||
"name": "@firebase/messaging-exp", | ||
"private": true, | ||
"version": "0.0.900", | ||
"description": "", | ||
"author": "Firebase <[email protected]> (https://firebase.google.com/)", | ||
"main": "dist/index.cjs.js", | ||
"module": "dist/index.esm.js", | ||
"esm2017": "dist/index.esm2017.js", | ||
"sw": "dist/index.sw.esm5.js", | ||
"files": [ | ||
"dist" | ||
], | ||
"scripts": { | ||
"lint": "eslint -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'", | ||
"lint:fix": "eslint --fix -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'", | ||
"build": "rollup -c && yarn api-report", | ||
"build:deps": "lerna run --scope @firebase/'{app-exp,messaging-exp}' --include-dependencies build", | ||
"dev": "rollup -c -w", | ||
"test": "run-p test:karma type-check lint ", | ||
"test:integration": "run-p test:karma type-check lint && cd ../../integration/messaging && npm run-script test", | ||
"test:ci": "node ../../scripts/run_tests_in_ci.js", | ||
"test:karma": "karma start --single-run", | ||
"test:debug": "karma start --browsers=Chrome --auto-watch", | ||
"prepare": "yarn build", | ||
"api-report": "api-extractor run --local --verbose", | ||
"type-check": "tsc --noEmit" | ||
}, | ||
"license": "Apache-2.0", | ||
"peerDependencies": { | ||
"@firebase/app-exp": "0.x", | ||
"@firebase/app-types-exp": "0.x" | ||
}, | ||
"dependencies": { | ||
"@firebase/component": "0.1.19", | ||
"@firebase/installations-exp": "0.x", | ||
zwu52 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"@firebase/messaging-types-exp": "0.0.900", | ||
"@firebase/util": "0.3.2", | ||
"idb": "3.0.2", | ||
"tslib": "^1.11.1" | ||
}, | ||
"devDependencies": { | ||
"rollup-plugin-json": "^4.0.0", | ||
zwu52 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"rollup-plugin-typescript2": "0.27.0", | ||
"ts-essentials": "^6.0.7", | ||
zwu52 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"typescript": "3.8.3" | ||
}, | ||
"repository": { | ||
"directory": "packages/messaging", | ||
"type": "git", | ||
"url": "https://github.com/firebase/firebase-js-sdk.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/firebase/firebase-js-sdk/issues" | ||
}, | ||
"typings": "dist/index.d.ts" | ||
} |
This file contains hidden or 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,85 @@ | ||
/** | ||
* @license | ||
* Copyright 2018 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import json from 'rollup-plugin-json'; | ||
import pkg from './package.json'; | ||
import typescript from 'typescript'; | ||
import typescriptPlugin from 'rollup-plugin-typescript2'; | ||
|
||
const deps = Object.keys( | ||
Object.assign({}, pkg.peerDependencies, pkg.dependencies) | ||
); | ||
|
||
/** | ||
* ES5 Builds | ||
*/ | ||
const es5BuildPlugins = [ | ||
typescriptPlugin({ | ||
typescript | ||
}), | ||
json() | ||
]; | ||
|
||
const es5Builds = [ | ||
// window builds | ||
{ | ||
input: 'src/index.ts', | ||
output: [ | ||
{ file: pkg.main, format: 'cjs', sourcemap: true }, | ||
{ file: pkg.module, format: 'es', sourcemap: true } | ||
], | ||
plugins: es5BuildPlugins, | ||
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) | ||
}, | ||
|
||
// sw builds | ||
{ | ||
input: 'src/index.sw.ts', | ||
output: [{ file: pkg.sw, format: 'es', sourcemap: true }], | ||
plugins: es5BuildPlugins, | ||
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) | ||
} | ||
]; | ||
|
||
/** | ||
* ES2017 Builds | ||
*/ | ||
const es2017BuildPlugins = [ | ||
typescriptPlugin({ | ||
typescript, | ||
tsconfigOverride: { | ||
compilerOptions: { | ||
target: 'es2017' | ||
} | ||
} | ||
}), | ||
json({ preferConst: true }) | ||
]; | ||
|
||
const es2017Builds = [ | ||
{ | ||
input: 'src/index.ts', | ||
output: { | ||
file: pkg.esm2017, | ||
format: 'es', | ||
sourcemap: true | ||
}, | ||
plugins: es2017BuildPlugins, | ||
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) | ||
} | ||
]; | ||
export default [...es5Builds, ...es2017Builds]; |
This file contains hidden or 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,65 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { | ||
FirebaseMessaging, | ||
MessagePayload | ||
} from '@firebase/messaging-types-exp'; | ||
import { NextFn, Observer, Unsubscribe } from '@firebase/util'; | ||
|
||
import { FirebaseApp } from '@firebase/app-types-exp'; | ||
import { MessagingService } from './messaging-service'; | ||
import { Provider } from '@firebase/component'; | ||
import { deleteToken as _deleteToken } from './api/deleteToken'; | ||
import { _getProvider } from '@firebase/app-exp'; | ||
import { getToken as _getToken } from './api/getToken'; | ||
import { onBackgroundMessage as _onBackgroundMessage } from './api/onBackgroundMessage'; | ||
import { onMessage as _onMessage } from './api/onMessage'; | ||
|
||
export function getMessaging(app: FirebaseApp): FirebaseMessaging { | ||
const messagingProvider: Provider<'messaging-exp'> = _getProvider( | ||
app, | ||
'messaging-exp' | ||
); | ||
|
||
return messagingProvider.getImmediate(); | ||
} | ||
|
||
export async function getToken( | ||
messaging: FirebaseMessaging, | ||
options?: { vapidKey?: string; swReg?: ServiceWorkerRegistration } | ||
): Promise<string> { | ||
return _getToken(messaging as MessagingService, options); | ||
} | ||
|
||
export function deleteToken(messaging: FirebaseMessaging): Promise<boolean> { | ||
return _deleteToken(messaging as MessagingService); | ||
} | ||
|
||
export function onMessage( | ||
messaging: FirebaseMessaging, | ||
nextOrObserver: NextFn<MessagePayload> | Observer<MessagePayload> | ||
): Unsubscribe { | ||
return _onMessage(messaging as MessagingService, nextOrObserver); | ||
} | ||
|
||
export function onBackgroundMessage( | ||
messaging: FirebaseMessaging, | ||
nextOrObserver: NextFn<MessagePayload> | Observer<MessagePayload> | ||
): Unsubscribe { | ||
return _onBackgroundMessage(messaging as MessagingService, nextOrObserver); | ||
} |
This file contains hidden or 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,36 @@ | ||
/** | ||
* @license | ||
* Copyright 2020 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { ERROR_FACTORY, ErrorCode } from '../util/errors'; | ||
|
||
import { MessagingService } from '../messaging-service'; | ||
import { deleteTokenInternal } from '../internals/token-manager'; | ||
import { registerDefaultSw } from '../helpers/registerDefaultSw'; | ||
|
||
export async function deleteToken( | ||
messaging: MessagingService | ||
): Promise<boolean> { | ||
if (!navigator) { | ||
throw ERROR_FACTORY.create(ErrorCode.AVAILABLE_IN_WINDOW); | ||
} | ||
|
||
if (!messaging.swRegistration) { | ||
await registerDefaultSw(messaging); | ||
} | ||
|
||
return deleteTokenInternal(messaging); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you are planning to do this in another PR but to get documentation, the JSdoc comments need to be added in
src/api.ts