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.
This PR contains the following updates:
^3.0.7
->^6.0.0
Release Notes
Aaronius/penpal
v6.2.2
Compare Source
Fixes #85 which is an issue where an error would occur under specific timing scenarios when the child iframe is removed from the DOM at about the same time it sends a SYN message. The error didn't cause operational issues, but would still be an uncaught error.
v6.2.1
Compare Source
Added some documentation to the readme regarding TypeScript usage.
v6.2.0
Compare Source
Added support for a wildcard as a value for
childOrigin
. This allows the parent to communicate within any child origin.Thanks @KutnerUri for the contribution!
v6.1.0
Compare Source
The
methods
object passed toconnectToParent
orconnectToChild
can now contain nested objects with function values. See https://github.com/Aaronius/penpal/pull/71 for more information.v6.0.1
Compare Source
v6.0.0
Compare Source
With a major release comes breaking changes. Here's what you need to know:
NotInIframe error removed
What
The
NotInIframe
error, which was thrown ifconnectToParent
was called from outside of an iframe, has been removed. Fixes #61.Why
Previously, if a call was made to
connectToParent
from outside of an iframe, Penpal would throw an error with theNotInIframe
error code. While this was a nice idea, it didn't play well with Cypress. Cypress by default attempts to "modify obstructive code". In other words, if any JavaScript attempts to perform framebusting, Cypress tries to modify the code since such techniques prevent Cypress from working properly. As it turns out, Penpal's check to see if it was running inside of an iframe was not performing framebusting, but Cypress would see it as obstructive code anyway and attempt to modify it, which would actually break testing with Cypress + Penpal entirely. The workaround wasn't great and, given that Penpal's check wasn't providing a lot of value, I decided it would be in consumers' interest to remove the check.ConnectionDestroyed error reduced in scope
What
Previously, Penpal would reject the connection promise with an error containing the
ConnectionDestroyed
error code if the consumer calledconnection.destroy
before a connection was made. Fixes #51.Why
When a consumer calls
destroy
, they are intentionally destroying the connection and shouldn't be forced to handle a rejected promise as a consequence. It's not an exceptional use case, so it does not merit a rejection. This change should lower development burden, as described in #51.The
ConnectionDestroyed
error is still thrown if a child or parent method is called after a connection has been destroyed.Exported types
What
This is not a breaking change. The following TypeScript types are now exported as named exports:
Connection
,AsyncMethodReturns
,CallSender
,Methods
, andPenpalError
types. Fixes #67.Why
TypeScript types could previously (and still can) be imported through a child path as follows:
but that made them less discoverable and the fact that they could be relied on was only implicit. They are now named exports on the top-level module, so they can now be imported as follows:
v5.3.0
Compare Source
connection
TypeScript type.Big thanks to @lpellegr for his work on these issues!
v5.2.1
Compare Source
Rather than creating copies of the typescript declarations for es5, I switched to leveraging the
types
field inpackage.json
to point to the typings that were generated when the typescript files were compiled to es6. Besides reducing the need for duplicate declarations, it's also advised by the TypeScript documentation.v5.2.0
Compare Source
Now publishing TypeScript typings alongside ES5-generated code.
v5.1.1
Compare Source
Removed add-module-exports babel plugin since it's unnecessary. This shouldn't have any effect on consumers.
v5.1.0
Compare Source
Prior to v5.0.0, I had transpiled Penpal code to es5 before packaging for npm. Starting with v5.0.0, I decided to only bundle for es6 with the hope that bundler support for es6 would be strong enough that packaging es5 would be unnecessary and consumers could configure their bundler to transpile penpal back to es5 if necessary. Due to popular demand and because bundlers can be a pain to configure to transpile penpal to es5, I added back transpilation to es5.
The npm package now includes both es6 and es5 code. If the consumer's bundler is capable of bundling es6 code, it should use the es6 code automatically. If it's not capable of bundling es6 code, then Penpal's es5 code will be used automatically instead.
This should not affect the runtime behavior of Penpal in any way.
v5.0.2
Compare Source
Fixes typescript generics to be correct for the returned proxy object (https://github.com/Aaronius/penpal/pull/50).
v5.0.1
Compare Source
child
orparent
) to be more strongly typed via TypeScript. (https://github.com/Aaronius/penpal/issues/47)v5.0.0
Compare Source
With a major release comes breaking changes. Here's what you need to know:
Importing
What
When using a bundler, import
connectToChild
as follow:and import
connectToParent
as follows:If you're importing error codes, import them as follows:
Why
Penpal no longer ships with ES5. The ES6 code is set up in such a way that your bundler of choice should properly tree shake unused code. Your bundler, when properly configured, should also perform any transpilation necessary for your browser targets.
EDIT July 8, 2020: As of v5.1.0, ES5 is again included in the npm package, alongside ES6. Bundlers should automatically use the appropriate version.
Regex Support for
parentOrigin
What
When using
connectToParent
, you can now specify a regular expression forparentOrigin
. By providing a regular expression, you can now load the iframe onto multiple, different domains while ensuring that communication is secured to those domains only.Why
This need has been raised several times in the past and was a fairly common use case. While this was not a breaking change, it did require significant changes to the handshake process as described in https://github.com/Aaronius/penpal/pull/32#issuecomment-613198637 and due to the higher risk of the change I decided to include it with other breaking changes in v5 rather than adding it to v4.
TypeScript
What
Penpal is now built using TypeScript, so if you're using TypeScript, you now get types for free!
Why
Consumers wanted TypeScript typings and I thought the positive qualities of TypeScript would enhance the Penpal development process.
v4.1.1
Compare Source
Fixed a small typo in the readme related to the new
childOrigin
option.v4.1.0
Compare Source
Added an optional
childOrigin
option toconnectToChild
to handle cases where the child origin can't correctly be resolved automatically.v4.0.0
Compare Source
With a major release comes breaking changes. Here's what you need to know:
Browser Support
What
Internet Explorer support has been dropped. As such, support for providing a promise implementation by setting
Penpal.Promise
has been removed.Why
Internet Explorer browser share worldwide is ~2.5%. Because Penpal was being transpiled for Internet Explorer, the lowest common denominator, all consumers had to pay the penalty through larger bundle sizes. I also needed to save my sanity while debugging. If you're one of the unlucky souls that still needs to support Internet Explorer, you should feel confident continuing to use version 3.x of Penpal.
Importing
What
When using a bundler, import
connectToChild
as follow:and import
connectToParent
as follows:If you're importing error codes, import them as follows:
Why
By only importing the functionality you need, you can keep your builds slimmer.
Iframe Creation
What
Previously, Penpal would typically create the iframe, set the
src
property, and add the iframe to the document on your behalf. This is no longer the case. You will need to create the iframe, set thesrc
property, and add the iframe to the document. Then, pass the iframe to Penpal.Consequently, the
url
andappendTo
options have been removed fromconnectToChild
while theiframe
option is now required. Theconnection
object returned fromconnectToChild
no longer contains aniframe
property since you already have direct access to the iframe you created.Why
The
connectToParent
API had become increasingly complex and was becoming even more complex with newly added support (new in v4!) for the iframesrcdoc
property. Having Penpal create the iframe wasn't providing sufficient value to overcome the additional complexity required to support it.Debugging
What
Rather than setting
Penpal.debug
, you can enable debugging by passing adebug
option toconnectToChild
orconnectToParent
.Why
Since you're now importing
connectToParent
andconnectToChild
directly when using a bundler, there is noPenpal
object.Error Codes
What
The
ERR_IFRAME_ALREADY_ATTACHED_TO_DOM
error code has been removed. A new error code,ERR_NO_IFRAME_SRC
, has been added. It will be thrown if the iframe provided to Penpal does not already have itssrc
orsrcdoc
property set.Why
Penpal is no longer responsible for appending the iframe to the document. You may append the iframe to the document before or after
connectToChild
has been called. The only requirement is thatconnectToChild
is called from the parent beforeconnectToParent
is called from the child.TypeScript Declarations
What
TypeScript declarations have been removed from the project.
Why
As outlined in the TypeScript documentation, when a project is not written using TypeScript, it is preferred to publish TypeScript declarations to the @types organization on npm instead of bundling them with the library. Another reason is that I don't use TypeScript generally, making it difficult to update the declarations accurately as changes are made in the library. If you liked the declarations that were available, I would encourage and appreciate it if you would add them to the @types npm org.
Support for
srcdoc
and data URIs.What
You don't actually have to change anything here, because neither of these things were previously supported. I just wanted to make you aware that, if it applies to you, you can now set the
src
property of the iframe using a data URI or leverage the iframe'ssrcdoc
property instead.Why
These use cases were becoming more common.
Configuration
📅 Schedule: Branch creation - "after 3am,before 9am" in timezone America/Los_Angeles, Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR has been generated by Mend Renovate. View repository job log here.