-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* master: Return decoyed elements where possible and reject on timeout Handle arbitrary number of decoy activations Give memoize a generic type Update dependencies Add environment detection 2.1.2 Don't assume we have a 2nd child node Include ABC Everyday application in getApplication docs. Clarify in README that decoy keys can be any [a-z] string, and that multiple decoys can be activated as a result of a single `requestDOMPermit`. Retain the `DECOY_KEYS` enum as a list of known keys but relax the type restrictions on key arguments from `DECOY_KEYS` to `string`. 2.1.1 Add ABC Everyday application to README Change PL's partial hostname for preview tier detection, to include feature branches which don't have "preview." in their hostnames Add Presentation Layer's ABC Everyday application 2.1.0 Update dependencies Add whenOdysseyLoaded promise
- Loading branch information
Showing
8 changed files
with
7,288 additions
and
3,840 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 |
---|---|---|
|
@@ -8,3 +8,4 @@ node_modules | |
bin | ||
dist | ||
example/public/bundle.js | ||
.envrc |
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 @@ | ||
_ |
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 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
npm run lint | ||
npm run test |
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,9 @@ | ||
*.log | ||
.DS_Store | ||
node_modules | ||
*.test.* | ||
.gitignore | ||
.husky | ||
.tsconfig.json | ||
dist | ||
.envrc |
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 |
---|---|---|
|
@@ -52,6 +52,7 @@ console.log(APPLICATIONS); | |
// P2: 'p2', // Phase 2 | ||
// PLA: 'pla', // Presentation Layer ABC AMP | ||
// PLC: 'plc', // Presentation Layer Core | ||
// PLE: 'ple', // Presentation Layer Everyday | ||
// PLN: 'pln', // Presentation Layer News Web | ||
// } | ||
console.log(GENERATIONS); | ||
|
@@ -69,7 +70,7 @@ console.log(TIERS); | |
|
||
### `getApplication(): string | null` | ||
|
||
Return the environment's **application** (Phase 1 Mobile; Phase 1 Standard; Phase 2; Presentation Layer ABC AMP; Presentation Layer Core; Presentation Layer News Web) as a string value from the `APPLICATIONS` enum, or `null` if the application couldn't be determined. | ||
Return the environment's **application** (Phase 1 Mobile; Phase 1 Standard; Phase 2; Presentation Layer ABC AMP; Presentation Layer Core; Presentation Layer Everyday; Presentation Layer News Web) as a string value from the `APPLICATIONS` enum, or `null` if the application couldn't be determined. | ||
|
||
```js | ||
import { APPLICATIONS, getApplication } from '@abcnews/env-utils'; | ||
|
@@ -123,20 +124,26 @@ This is advised before modifying the DOM on Presentation Layer generation applic | |
|
||
DOM modification is usually safe on older generation applications, but permits should be requested anyway, for the sake of consistency. | ||
|
||
The `key` argument is used by Presentation Layer to activate its respective `<Decoy>` component. | ||
The `key` argument is used by Presentation Layer to activate its respective `<Decoy>` components. | ||
|
||
An optional `onRevokeHandler` argument can be passed, which will be called if Presentation Layer chooses to deactivate the `<Decoy>` and restore its orignal DOM. | ||
An optional `onRevokeHandler` argument can be passed, which will be called if Presentation Layer chooses to deactivate `<Decoy>`s and restore their orignal DOM. | ||
|
||
Note: `key` values may be any `[a-z]` string, but the Presentation Layer News Web application provides several pre-determined values, which this library exposes as `DECOY_KEYS`. | ||
|
||
```js | ||
import { DECOY_KEYS, requestDOMPermit } from '@abcnews/env-utils'; | ||
|
||
requestDOMPermit(DECOY_KEYS.PAGE, () => { | ||
// It is no longer safe to modify the DOM tree below the <Decoy key="page"> PL compoonent | ||
// It is no longer safe to modify the DOM tree below <Decoy listenKey="page"> PL compoonents | ||
}).then(() => { | ||
// It is now safe to modify the DOM tree below the <Decoy key="page"> PL compoonent | ||
// It is now safe to modify the DOM tree below <Decoy listenKey="page"> PL compoonents | ||
}); | ||
``` | ||
|
||
The returned promise resolves differently depending on the `GENERATION` on which it's running. On Presentation Layer sites the promise will resolve with an array of `HTMLElement` references for all the nodes where the decoy was activated. On prior generations, it will resolve with `true`. | ||
|
||
The promise will be rejected after 5 seconds if all expected decoys haven't been activated. Additionally, the library will attempt to undo any successful activations by sending another request to PL to deactivate decoys with the given key. | ||
|
||
## Authors | ||
|
||
- Colin Gourlay ([[email protected]](mailto:[email protected])) |
Oops, something went wrong.