Skip to content
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

Update dependencies and cleanup repo #30

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
{
"presets": [
["env", {
"targets": {
"browsers": ["last 2 versions", "iOS >=10", "ie >= 10"]
[
"env",
{
"targets": {
"browsers": [ "last 2 versions", "iOS >= 10", "ie >= 10" ]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure on this list, but this might need to align with the terra-supported browserlist. Likely an issue for another PR. https://github.com/cerner/browserslist-config-terra

}
}
}]
]
],
"plugins": [
"array-includes",
"transform-object-assign",
"transform-runtime",
"transform-object-rest-spread",
"transform-class-properties"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we adding this plugin?

]
}
8 changes: 8 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
node_modules
build
builds
scripts
config
lib
dist
*.config.*
26 changes: 12 additions & 14 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
// When you write javascript you should follow these soft rules and best practices
// https://github.com/airbnb/javascript

// This is a link to best practices and enforcer settings for eslint
// https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb

// Use this file as a starting point for your project's .eslintrc.
{
"extends": "airbnb",
"parser": "babel-eslint",
"plugins": [
"import",
"compat"
],
"env": {
"browser": true,
"node": true,
"jquery": true,
"commonjs": true,
"es6": true
"jest": true
},
"extends": ["airbnb"],
"rules": {
"no-unused-vars": 0,
"max-len": 0
"import/no-extraneous-dependencies": ["error", {"devDependencies": ["**/test/*", "**/*.jest.*", "**/*.test.*"]}],
"compat/compat": "error" // error when using features that are not supported in the browsers we target in .browserslistrc
},
"settings": {
"polyfills": ["promises"]
}
}
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Set default code owners for all files in repo
* @cerner/xfc
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8.9.2
lts/carbon
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
language: node_js
script:
- npm test
- npm run lint-js
- yarn run test
- yarn run lint
2 changes: 2 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Cerner Corporation
- Greg Howdeshell [@poloka]
- Matt Schile [@mschile]
- Sam Milligan [@grneggandsam]
- Cody Price [@dev-cprice]

[@mhemesath]: https://github.com/mhemesath
[@kafkahw]: https://github.com/kafkahw
Expand All @@ -15,3 +16,4 @@ Cerner Corporation
[@poloka]: https://github.com/poloka
[@mschile]: https://github.com/mschile
[@grneggandsam]: https://github.com/grneggandsam
[@dev-cprice]: https://github.com/dev-cprice
2 changes: 1 addition & 1 deletion NOTICE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2017 Cerner Innovation, Inc.
Copyright 2018 Cerner Innovation, Inc.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this needs to be 2017-2019


Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
26 changes: 17 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ This project handles securely embedding web content into a 3rd party domain. Out
* Event dispatching from embedded content into a framework

## Usage

Include `xfc.js` in your project.

Ensure `process.env.NODE_ENV` is set correctly in the build enviornment. Logging is only enabled in non-production environments. The environment can be set in webpack using the [DefinePlugin](https://webpack.js.org/guides/production-build/)
Expand All @@ -29,6 +30,7 @@ module.exports = {
```

### Setting Up A Consumer

The consumer is the application which is embedding the 3rd party applications within it.

```js
Expand Down Expand Up @@ -57,8 +59,8 @@ To load a new page within the existing frame, simply call `load` method with the
frame.load(newURL)
```


#### Iframe Resizing Config

By default, the height of iframe will automatically resize based on the height of the embedded content. This behavior can be changed by passing an extra option (`resizeConfig`) into `mount` method.

```js
Expand All @@ -79,8 +81,8 @@ XFC.Consumer.mount(document.body, 'http://localprovider.com:8080/example/provide
| customCalculationMethod | function | null | When specified, XFC will use the given method to update iframe's size when necessary (e.g. dom changes, window resized, etc.)<br><br> NOTE: context `this` is provided as iframe to this method, so in the method you can access the iframe by accessing `this` |
| targetSelectors | string | null | When the embedded page contains elements styled with `position: absolute`, the iframe resizing logic won't calculate the height of the embedded page correctly because those elements are removed from normal document flow.<br><br>In this case, targetSelectors can be used to specify those absolute positioned elements so that they will be taken into consideration when calculating the height of the embedded page. Multiple selectors may be specified by separating them using commas.<br><br>If not specified, normal resizing logic will be used.<br><br> NOTE: this attribute can be also specified from Provider's side, e.g. `XFC.Provider.init({targetSelectors: '#target'})`|


### Setting Custom Attributes on Iframe

Sometimes, it's useful for developers to add more attributes onto mounted iframes. A common use case, for instance, is adding `allow` attribute to `<iframe>` tag for cross-origin iframes in Chrome 64+ (See reference [here][3]). In those cases, we can pass an extra option called `iframeAttrs` into `mount` method as follows.

```js
Expand All @@ -89,7 +91,6 @@ XFC.Consumer.mount(document.body, 'http://localprovider.com:8080/example/provide

Here `iframeAttrs` is an object that contains entries, each of them being an entry of attribute's name and value.


### Monitoring Embedded App Lifecycles

Application lifecycles go through 3 stages as they load:
Expand All @@ -105,6 +106,7 @@ These statuses are communicated to the consumer application environment in 2 way
* A custom application event originating from the embedded iFrame.

#### Styling Cross Frame Containers Based On Status

The cross frame container ```data-status``` attribute can be used as a styling hook to hide containers until they have authorized

```css
Expand All @@ -121,6 +123,7 @@ The cross frame container ```data-status``` attribute can be used as a styling h
```

### Listening for Lifecycle Events

Event listeners can be set up to listen for lifecycle changes to a cross frame container.
The target of the event will be the embedded application frame which is an instance of EventEmitter.

Expand All @@ -147,6 +150,7 @@ frame.on('xfc.unload', function(detail) {
```

### Fullscreen Events

A provider application may request to launch another provider app fullscreen.

```js
Expand All @@ -158,6 +162,7 @@ frame.on('xfc.fullscreen', function(url) {
```

### Sending custom events to a provider

Each frame of the consumer can send custom events to its embedded provider through its _trigger_ method.

```js
Expand All @@ -166,8 +171,8 @@ Each frame of the consumer can send custom events to its embedded provider throu
frame.trigger('fetchDetail', {id: 10});
```


## Setting Up A Provider

The provider is the application which is embedded by the consumer.

```js
Expand Down Expand Up @@ -208,6 +213,7 @@ XFC.Provider.init({
```

### Launching Fullscreen

An application may request to launch a pagelet fullscreen within the consumer application.

```js
Expand All @@ -216,6 +222,7 @@ XFC.Provider.fullscreen('http://localconsumer.com:8080/workflow')
```

### Sending custom events to its frame

Provider can send custom events to the frame where it's embedded through _trigger_ method.

```js
Expand All @@ -234,22 +241,23 @@ XFC.Provider.httpError({code: 500, message: 'Internal Server Error'});
```

## Browser Support
All supported browsers are defined in [here][1] with browserslist [queries][2].

All supported browsers are defined in [here][1] with browserslist [queries][2].

## Development

Add localconsumer.com to```/etc/hosts```.
Add localprovider.com to```/etc/hosts```.

Install dependencies and start the server.
```
npm install
npm run dev

```bash
yarn install

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets keep the npm references

yarn run dev
```

Navigate to http://localconsumer.com:8080/example


[1]: ./.babelrc#L5
[2]: https://github.com/ai/browserslist#queries
[3]: https://dev.chromium.org/Home/chromium-security/deprecating-permissions-in-cross-origin-iframes
Loading