Skip to content

Commit

Permalink
Merge pull request #1861 from ably/push-plugin-cdn
Browse files Browse the repository at this point in the history
Add Push plugin to cdn
  • Loading branch information
VeskeR authored Sep 11, 2024
2 parents f3ca8ec + a80ff5f commit 7d6d512
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 5 deletions.
7 changes: 5 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,11 @@ module.exports = function (grunt) {
grunt.registerTask('build:push', function () {
var done = this.async();

esbuild
.build(esbuildConfig.pushPluginConfig)
Promise.all([
esbuild.build(esbuildConfig.pushPluginConfig),
esbuild.build(esbuildConfig.pushPluginCdnConfig),
esbuild.build(esbuildConfig.minifiedPushPluginCdnConfig),
])
.then(() => {
done(true);
})
Expand Down
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Include the Ably library in your HTML:
<script src="https://cdn.ably.com/lib/ably.min-1.js"></script>
```

The Ably client library follows [Semantic Versioning](http://semver.org/). To lock into a major or minor version of the client library, you can specify a specific version number such as https://cdn.ably.com/lib/ably.min-1.js for all v1._ versions, or https://cdn.ably.com/lib/ably.min-1.0.js for all v1.0._ versions, or you can lock into a single release with https://cdn.ably.com/lib/ably.min-1.0.9.js. Note you can load the non-minified version by omitting `min-` from the URL such as https://cdn.ably.com/lib/ably-1.0.js. See https://github.com/ably/ably-js/tags for a list of tagged releases.
The Ably client library follows [Semantic Versioning](http://semver.org/). To lock into a major or minor version of the client library, you can specify a specific version number such as https://cdn.ably.com/lib/ably.min-1.js for all v1._ versions, or https://cdn.ably.com/lib/ably.min-1.0.js for all v1.0._ versions, or you can lock into a single release with https://cdn.ably.com/lib/ably.min-1.0.9.js. Note you can load the non-minified version by omitting `.min` from the URL such as https://cdn.ably.com/lib/ably-1.0.js. See https://github.com/ably/ably-js/tags for a list of tagged releases.

For usage, jump to [Using the Realtime API](#using-the-realtime-api) or [Using the REST API](#using-the-rest-api).

Expand Down Expand Up @@ -567,6 +567,23 @@ await channel.push.unsubscribeClient();
Push activation works with the [Modular variant](#modular-tree-shakable-variant) of the library, but requires you to be using the Rest plugin.
Alternatively, you can load the Push plugin directly in your HTML using `script` tag (in case you can't use a package manager):
```html
<script src="https://cdn.ably.com/lib/push.umd.min-2.js"></script>
```
When loaded this way, the Push plugin will be available on the global object via the `AblyPushPlugin` property, so you will need to pass it to the Ably instance as follows:
```javascript
const client = new Ably.Rest({
...options,
plugins: { Push: AblyPushPlugin },
});
```
The Push plugin is developed as part of the Ably client library, so it is available for the same versions as the Ably client library itself. It also means that it follows the same semantic versioning rules as they were defined for [the Ably client library](#for-browsers). For example, to lock into a major or minor version of the Push plugin, you can specify a specific version number such as https://cdn.ably.com/lib/push.umd.min-2.js for all v2._ versions, or https://cdn.ably.com/lib/push.umd.min-2.3.js for all v2.3._ versions, or you can lock into a single release with https://cdn.ably.com/lib/push.umd.min-2.3.2.js. Note you can load the non-minified version by omitting `.min` from the URL such as https://cdn.ably.com/lib/push.umd-2.js.
For more information on publishing push notifcations over Ably, see the [Ably push documentation](https://ably.com/docs/push).
## Delta Plugin
Expand Down
17 changes: 17 additions & 0 deletions grunt/esbuild/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,27 @@ const pushPluginConfig = {
external: ['ulid'],
};

const pushPluginCdnConfig = {
...createBaseConfig(),
entryPoints: ['src/plugins/push/index.ts'],
plugins: [umdWrapper.default({ libraryName: 'AblyPushPlugin', amdNamedModule: false })],
outfile: 'build/push.umd.js',
};

const minifiedPushPluginCdnConfig = {
...createBaseConfig(),
entryPoints: ['src/plugins/push/index.ts'],
plugins: [umdWrapper.default({ libraryName: 'AblyPushPlugin', amdNamedModule: false })],
outfile: 'build/push.umd.min.js',
minify: true,
};

module.exports = {
webConfig,
minifiedWebConfig,
modularConfig,
nodeConfig,
pushPluginConfig,
pushPluginCdnConfig,
minifiedPushPluginCdnConfig,
};
4 changes: 2 additions & 2 deletions scripts/cdn_deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ async function run() {
let config = {
// The S3 Bucket to upload into
bucket: S3_DEFAULT_BUCKET,
// The root folder inside the S3 bucket where the files should be places
// The root folder inside the S3 bucket where the files should be placed
root: S3_DEFAULT_ROOT,
// Local path to start from
path: '.',
Expand All @@ -21,7 +21,7 @@ async function run() {
// Comma separated directories (relative to `path`) to exclude from upload
excludeDirs: 'node_modules,.git',
// Regex to match files against for upload
fileRegex: '^ably?(\\.min)?\\.js$',
fileRegex: '^(ably|push\\.umd)?(\\.min)?\\.js$',
...argv,
};

Expand Down

0 comments on commit 7d6d512

Please sign in to comment.