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

Import XFC as ES6 module #27

Merged
merged 7 commits into from
Oct 3, 2020
Merged
Show file tree
Hide file tree
Changes from 5 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
33 changes: 31 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,38 @@ In order to run any SMART app in Cerner's MPage view (iframe), the following pro

This library uses [xfc](https://github.com/cerner/xfc) to solve [Clickjacking](https://www.owasp.org/index.php/Clickjacking) problem for all browsers.

## Availability
## Installation

Copy link
Member

Choose a reason for hiding this comment

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

Could you add a heading for NPM Module(Recommended)

This is an npm project and can be installed with the following:
```shell
npm install cerner-smart-embeddable-lib
```

Include it to your project with the following:
```js
import 'cerner-smart-embeddable-lib';
```

The minified & transpiled files are also available in the `dist/` directory and can be used with a `<script>` tag.
Copy link
Member

Choose a reason for hiding this comment

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

This could be under a new heading Script Include (NOT recommended) since you can't turn off XFC logging and it would conflict with MPages integration.


It is suggested to import the module (as opposed to including the pre-minified file from `dist/`) as it will allow Webpack to define `process.env.NODE_ENV` which will enable or disable XFC logging. Per the [XFC Readme](https://github.com/cerner/xfc#usage), logging is only enabled in non-production environments. The environment can be set in webpack using the DefinePlugin:

```js
// webpack.config.js
const webpack = require('webpack');

module.exports = {
/*...*/
plugins:[
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production')
})
]
};
```

Warning: Disable XFC logging if using [F-Twelve](https://github.com/cerner/f-twelve/). F-Twelve writes to the DOM every time `console.log` is called and (when logging is enabled) XFC calls `console.log` every time the DOM is written to. This causes the browser to endlessly loop and freeze. It is safe to use both concurrently if XFC logging is disabled.
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps bold the Warning: part


This project is an npm project. The minified & transpiled files are also available in the `dist/` directory.

## Dependency

Expand Down
12 changes: 4 additions & 8 deletions lib/js/cerner-smart-embeddable-lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ Object.defineProperty(exports, "__esModule", {
value: true
});

var _provider = require('xfc/src/provider');

var _provider2 = _interopRequireDefault(_provider);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _xfc = require('xfc');

/**
* Wrapper object to initialize the provider's content
Expand All @@ -20,7 +16,7 @@ var CernerSmartEmbeddableLib = {
* Initializes the provider wrapper object with ACLs.
*/
init: function init() {
_provider2.default.init({
_xfc.Provider.init({
acls: ['https://embedded.cerner.com', 'https://embedded.sandboxcerner.com', 'https://embedded.devcerner.com']
});
},
Expand All @@ -36,14 +32,14 @@ var CernerSmartEmbeddableLib = {
* message with the height detail.
*/
setFrameHeight: function setFrameHeight(h) {
_provider2.default.trigger('iframeCustomResizer', { height: h });
_xfc.Provider.trigger('iframeCustomResizer', { height: h });
},
/**
* Listen for iframeCustomResizer message.
* Calculate the frame height in px and set the height.
*/
listenForCustomFrameHeight: function listenForCustomFrameHeight() {
_provider2.default.on('iframeCustomResizer', function () {
_xfc.Provider.on('iframeCustomResizer', function () {
var height = window.CernerSmartEmbeddableLib.calcFrameHeight() + 'px';
CernerSmartEmbeddableLib.setFrameHeight(height);
});
Expand Down
2 changes: 1 addition & 1 deletion src/js/cerner-smart-embeddable-lib.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* global window */

import Provider from 'xfc/src/provider';
import { Provider } from 'xfc';

/**
* Wrapper object to initialize the provider's content
Expand Down
2 changes: 1 addition & 1 deletion test/spec/smart-embedded-content_spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import SmartEmbeddedContent from 'js/cerner-smart-embeddable-lib'
import Provider from 'xfc/src/provider';
import { Provider } from 'xfc';

describe('CernerSmartEmbeddableLib', () => {
describe('init', () => {
Expand Down