-
Notifications
You must be signed in to change notification settings - Fork 31
chore: Add combined browser package. #871
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
Merged
Changes from 6 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b443439
chore: Scaffold combined browser package.
kinyoklion 4a0e99f
Readme updates.
kinyoklion 423fd0d
Bundle.
kinyoklion e5aac90
Root tsconfug update.
kinyoklion 410059f
Set a reasonable size limit.
kinyoklion 82c3756
Top level readme
kinyoklion 0046035
Update package versions.
kinyoklion 0c63e9f
Remove temporary export code.
kinyoklion d38facd
Update readme names.
kinyoklion 3ce5a69
Merge branch 'main' into rlamb/add-combined-browser-package
kinyoklion 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
36 changes: 36 additions & 0 deletions
36
.github/ISSUE_TEMPLATE/package-sdk-combined-browser--bug_report.md
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 @@ | ||
| --- | ||
| name: '@launchdarkly/browser Bug Report' | ||
| about: Create a report to help us improve | ||
| title: '' | ||
| labels: 'package: sdk/combined-browser, bug' | ||
| assignees: '' | ||
| --- | ||
|
|
||
| **Is this a support request?** | ||
| This issue tracker is maintained by LaunchDarkly SDK developers and is intended for feedback on the code in this library. If you're not sure whether the problem you are having is specifically related to this library, or to the LaunchDarkly service overall, it may be more appropriate to contact the LaunchDarkly support team; they can help to investigate the problem and will consult the SDK team if necessary. You can submit a support request by going [here](https://support.launchdarkly.com/) and clicking "submit a request", or by emailing [email protected]. | ||
|
|
||
| Note that issues filed on this issue tracker are publicly accessible. Do not provide any private account information on your issues. If your problem is specific to your account, you should submit a support request as described above. | ||
|
|
||
| **Describe the bug** | ||
| A clear and concise description of what the bug is. | ||
|
|
||
| **To reproduce** | ||
| Steps to reproduce the behavior. | ||
|
|
||
| **Expected behavior** | ||
| A clear and concise description of what you expected to happen. | ||
|
|
||
| **Logs** | ||
| If applicable, add any log output related to your problem. | ||
|
|
||
| **SDK version** | ||
| The version of this SDK that you are using. | ||
|
|
||
| **Language version, developer tools** | ||
| For instance, Go 1.11 or Ruby 2.5.3. If you are using a language that requires a separate compiler, such as C, please include the name and version of the compiler too. | ||
|
|
||
| **OS/platform** | ||
| For instance, Ubuntu 16.04, Windows 10, or Android 4.0.3. If your code is running in a browser, please also include the browser type and version. | ||
|
|
||
| **Additional context** | ||
| Add any other context about the problem here. |
19 changes: 19 additions & 0 deletions
19
.github/ISSUE_TEMPLATE/package-sdk-combined-browser--feature_request.md
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,19 @@ | ||
| --- | ||
| name: '@launchdarkly/browser Feature Request' | ||
| about: Create a report to help us improve | ||
| title: '' | ||
| labels: 'package: sdk/combined-browser, feature' | ||
| assignees: '' | ||
| --- | ||
|
|
||
| **Is your feature request related to a problem? Please describe.** | ||
| A clear and concise description of what the problem is. Ex. I would love to see the SDK [...does something new...] | ||
|
|
||
| **Describe the solution you'd like** | ||
| A clear and concise description of what you want to happen. | ||
|
|
||
| **Describe alternatives you've considered** | ||
| A clear and concise description of any alternative solutions or features you've considered. | ||
|
|
||
| **Additional context** | ||
| Add any other context about the feature request here. |
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,44 @@ | ||
| name: sdk/combined-browser | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main, 'feat/**'] | ||
| paths-ignore: | ||
| - '**.md' #Do not need to run CI for markdown changes. | ||
| pull_request: | ||
| branches: [main, 'feat/**'] | ||
| paths-ignore: | ||
| - '**.md' | ||
|
|
||
| jobs: | ||
| build-test-browser: | ||
| permissions: | ||
| pull-requests: write | ||
| runs-on: ubuntu-latest | ||
|
|
||
| strategy: | ||
| matrix: | ||
| # Node versions to run on. | ||
| version: [18, 21] | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: ${{ matrix.version }} | ||
| registry-url: 'https://registry.npmjs.org' | ||
| - id: shared | ||
| name: Shared CI Steps | ||
| uses: ./actions/ci | ||
| with: | ||
| workspace_name: '@launchdarkly/browser' | ||
| workspace_path: packages/sdk/combined-browser | ||
| - name: Check package size | ||
| if: github.event_name == 'pull_request' && matrix.version == '21' | ||
| uses: ./actions/package-size | ||
| with: | ||
| github_token: ${{ secrets.GITHUB_TOKEN }} | ||
| target_file: 'packages/sdk/combined-browser/dist/index.js' | ||
| package_name: '@launchdarkly/browser' | ||
| pr_number: ${{ github.event.number }} | ||
| size_limit: 200000 |
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
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
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
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
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
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
Empty file.
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,13 @@ | ||
| Copyright 2025 Catamorphic, Co. | ||
|
|
||
| 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. |
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,61 @@ | ||
| # LaunchDarkly JavaScript SDK for Browsers with included Observability. | ||
|
|
||
| [![NPM][combined-browser-sdk-npm-badge]][combined-browser-sdk-npm-link] | ||
| [![Actions Status][combined-browser-sdk-ci-badge]][combined-browser-sdk-ci] | ||
| [![Documentation][combined-browser-sdk-ghp-badge]][combined-browser-sdk-ghp-link] | ||
| [![NPM][combined-browser-sdk-dm-badge]][combined-browser-sdk-npm-link] | ||
| [![NPM][combined-browser-sdk-dt-badge]][combined-browser-sdk-npm-link] | ||
|
|
||
| # ⛔️⛔️⛔️⛔️ | ||
|
|
||
| > [!CAUTION] | ||
| > This library is a alpha version and should not be considered ready for production use while this message is visible. | ||
| # ☝️☝️☝️☝️☝️☝️ | ||
|
|
||
| <!-- | ||
| ## Install | ||
| ```shell | ||
| # npm | ||
| npm i @launchdarkly/browser | ||
| # yarn | ||
| yarn add -D @launchdarkly/browser | ||
| ``` | ||
| --> | ||
|
|
||
| ## Getting started | ||
|
|
||
| Refer to the [SDK documentation](https://docs.launchdarkly.com/sdk/client-side/javascript#getting-started) for instructions on getting started with using the SDK. | ||
|
|
||
| Note: _If you are using JavaScript in a non-combined-browser environment, please check our other SDK packages in [js-core](https://github.com/launchdarkly/js-core)_ | ||
| Please note that the JavaScript SDK has two special requirements in terms of your LaunchDarkly environment. First, in terms of the credentials for your environment that appear on your [Account Settings](https://app.launchdarkly.com/settings/projects) dashboard, the JavaScript SDK uses the "Client-side ID"-- not the "SDK key" or the "Mobile key". Second, for any feature flag that you will be using in JavaScript code, you must check the "Make this flag available to client-side SDKs" box on that flag's Settings page. | ||
|
|
||
| ## Verifying SDK build provenance with the SLSA framework | ||
|
|
||
| LaunchDarkly uses the [SLSA framework](https://slsa.dev/spec/v1.0/about) (Supply-chain Levels for Software Artifacts) to help developers make their supply chain more secure by ensuring the authenticity and build integrity of our published SDK packages. To learn more, see the [provenance guide](PROVENANCE.md). | ||
|
|
||
| ## About LaunchDarkly | ||
|
|
||
| - LaunchDarkly is a continuous delivery platform that provides feature flags as a service and allows developers to iterate quickly and safely. We allow you to easily flag your features and manage them from the LaunchDarkly dashboard. With LaunchDarkly, you can: | ||
| - Roll out a new feature to a subset of your users (like a group of users who opt-in to a beta tester group), gathering feedback and bug reports from real-world use cases. | ||
| - Gradually roll out a feature to an increasing percentage of users, and track the effect that the feature has on key metrics (for instance, how likely is a user to complete a purchase if they have feature A versus feature B?). | ||
| - Turn off a feature that you realize is causing performance problems in production, without needing to re-deploy, or even restart the application with a changed configuration file. | ||
| - Grant access to certain features based on user attributes, like payment plan (eg: users on the ‘gold’ plan get access to more features than users in the ‘silver’ plan). | ||
| - Disable parts of your application to facilitate maintenance, without taking everything offline. | ||
| - LaunchDarkly provides feature flag SDKs for a wide variety of languages and technologies. Read [our documentation](https://docs.launchdarkly.com/sdk) for a complete list. | ||
| - Explore LaunchDarkly | ||
| - [launchdarkly.com](https://www.launchdarkly.com/ 'LaunchDarkly Main Website') for more information | ||
| - [docs.launchdarkly.com](https://docs.launchdarkly.com/ 'LaunchDarkly Documentation') for our documentation and SDK reference guides | ||
| - [apidocs.launchdarkly.com](https://apidocs.launchdarkly.com/ 'LaunchDarkly API Documentation') for our API documentation | ||
| - [blog.launchdarkly.com](https://blog.launchdarkly.com/ 'LaunchDarkly Blog Documentation') for the latest product updates | ||
|
|
||
| [combined-browser-sdk-ci-badge]: https://github.com/launchdarkly/js-core/actions/workflows/combined-browser.yml/badge.svg | ||
| [combined-browser-sdk-ci]: https://github.com/launchdarkly/js-core/actions/workflows/combined-browser.yml | ||
| [combined-browser-sdk-npm-badge]: https://img.shields.io/npm/v/@launchdarkly/browser.svg?style=flat-square | ||
| [combined-browser-sdk-npm-link]: https://www.npmjs.com/package/@launchdarkly/browser | ||
| [combined-browser-sdk-ghp-badge]: https://img.shields.io/static/v1?label=GitHub+Pages&message=API+reference&color=00add8 | ||
| [combined-browser-sdk-ghp-link]: https://launchdarkly.github.io/js-core/packages/sdk/combined-browser/docs/ | ||
| [combined-browser-sdk-dm-badge]: https://img.shields.io/npm/dm/@launchdarkly/browser.svg?style=flat-square | ||
| [combined-browser-sdk-dt-badge]: https://img.shields.io/npm/dt/@launchdarkly/browser.svg?style=flat-square |
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,4 @@ | ||
| // Placeholder test to ensure the test suite is working` | ||
| it('runs tests', () => { | ||
| expect(true).toBe(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,16 @@ | ||
| { | ||
| "verbose": true, | ||
| "testEnvironment": "jest-environment-jsdom", | ||
| "testPathIgnorePatterns": ["./dist", "./src"], | ||
| "testMatch": ["**.test.ts"], | ||
| "setupFiles": ["./setup-jest.js"], | ||
| "transform": { | ||
| "^.+\\.ts$": [ | ||
| "ts-jest", | ||
| { | ||
| "tsConfig": "tsconfig.test.json" | ||
| } | ||
| ], | ||
| "^.+.tsx?$": ["ts-jest", {}] | ||
| } | ||
| } |
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,74 @@ | ||
| { | ||
| "name": "@launchdarkly/browser", | ||
| "version": "0.0.0", | ||
| "description": "LaunchDarkly SDK for JavaScript in Browsers with Observability", | ||
| "homepage": "https://github.com/launchdarkly/js-core/tree/main/packages/sdk/combined-browser", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/launchdarkly/js-core.git" | ||
| }, | ||
| "license": "Apache-2.0", | ||
| "packageManager": "[email protected]", | ||
| "keywords": [ | ||
| "launchdarkly", | ||
| "feature flags", | ||
| "feature toggles", | ||
| "feature management", | ||
| "sdk" | ||
| ], | ||
| "type": "module", | ||
| "main": "./dist/index.cjs", | ||
| "module": "./dist/index.js", | ||
| "types": "./dist/index.d.ts", | ||
| "exports": { | ||
| ".": { | ||
| "require": { | ||
| "types": "./dist/index.d.cts", | ||
| "require": "./dist/index.cjs" | ||
| }, | ||
| "import": { | ||
| "types": "./dist/index.d.ts", | ||
| "import": "./dist/index.js" | ||
| } | ||
| } | ||
| }, | ||
| "files": [ | ||
| "dist" | ||
| ], | ||
| "scripts": { | ||
| "clean": "rimraf dist", | ||
| "build": "tsup", | ||
| "lint": "eslint . --ext .ts,.tsx", | ||
| "prettier": "prettier --write '**/*.@(js|ts|tsx|json|css)' --ignore-path ../../../.prettierignore", | ||
| "test": "npx jest --runInBand", | ||
| "coverage": "yarn test --coverage", | ||
| "check": "yarn prettier && yarn lint && yarn build && yarn test" | ||
| }, | ||
| "dependencies": { | ||
| "@launchdarkly/js-client-sdk": "0.7.0", | ||
| "@launchdarkly/observability": "0.1.13", | ||
| "@launchdarkly/session-replay": "0.1.13" | ||
kinyoklion marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| }, | ||
| "devDependencies": { | ||
| "@jest/globals": "^29.7.0", | ||
| "@trivago/prettier-plugin-sort-imports": "^4.1.1", | ||
| "@types/jest": "^29.5.11", | ||
| "@typescript-eslint/eslint-plugin": "^6.20.0", | ||
| "@typescript-eslint/parser": "^6.20.0", | ||
| "eslint": "^8.45.0", | ||
| "eslint-config-airbnb-base": "^15.0.0", | ||
| "eslint-config-airbnb-typescript": "^17.1.0", | ||
| "eslint-config-prettier": "^8.8.0", | ||
| "eslint-plugin-import": "^2.27.5", | ||
| "eslint-plugin-jest": "^27.6.3", | ||
| "eslint-plugin-prettier": "^5.0.0", | ||
| "jest": "^29.7.0", | ||
| "jest-environment-jsdom": "29.7.0", | ||
| "prettier": "^3.0.0", | ||
| "rimraf": "^5.0.5", | ||
| "ts-jest": "^29.1.1", | ||
| "tsup": "^8.3.5", | ||
| "typedoc": "0.25.0", | ||
| "typescript": "^5.5.3" | ||
| } | ||
| } | ||
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,24 @@ | ||
| const { TextEncoder, TextDecoder } = require('node:util'); | ||
| const crypto = require('node:crypto'); | ||
|
|
||
| global.TextEncoder = TextEncoder; | ||
|
|
||
| Object.assign(window, { TextDecoder, TextEncoder }); | ||
|
|
||
| // Based on: | ||
| // https://stackoverflow.com/a/71750830 | ||
|
|
||
| Object.defineProperty(global.self, 'crypto', { | ||
| value: { | ||
| getRandomValues: (arr) => crypto.randomBytes(arr.length), | ||
| subtle: { | ||
| digest: (algorithm, data) => { | ||
| return new Promise((resolve) => | ||
| resolve( | ||
| crypto.createHash(algorithm.toLowerCase().replace('-', '')).update(data).digest(), | ||
| ), | ||
| ); | ||
| }, | ||
| }, | ||
| }, | ||
| }); |
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.
Can be un-commented once packages are published.