Skip to content

Commit 2d36eb6

Browse files
authored
Merge pull request #330 from Airtable/v0.11.6
v0.11.6
2 parents 560b466 + b468d8f commit 2d36eb6

File tree

9 files changed

+39
-20
lines changed

9 files changed

+39
-20
lines changed

CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1+
# v0.11.6
2+
* Remove behavior of including `AIRTABLE_API_KEY` in airtable.browser.js via envify
3+
* Add web worker compatibility
4+
15
# v0.11.5
26
* Update select() and list() to support to use POST endpoint when GET url length would exceed Airtable's 16k character limit
3-
* Update select() and list() to explicitly choose to use GET or POST endpoint via new 'method' arg
7+
* Update select() and list() to explicitly choose to use GET or POST endpoint via new 'method' arg
48

59
# v0.11.4
610
* Add support for returnFieldsByFieldId param.
711

812
# v0.11.3
9-
* Adds a UMD build to use for browser-targeted builds. This fixes an issue where other apps that
13+
* Add a UMD build to use for browser-targeted builds. This fixes an issue where other apps that
1014
use airtable.js as a dependency were bundling code that expects to run in a node environment when
1115
building for a browser enviornment.
1216

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ There are three configurable options available:
4747

4848
* `apiKey` - your secret API token. Visit [/create/tokens](https://airtable.com/create/tokens) to create a personal access token. [OAuth access tokens](https://airtable.com/developers/web/guides/oauth-integrations) can also be used.
4949
* `endpointUrl` - the API endpoint to hit. You might want to override
50-
it if you are using an API proxy (e.g. runscope.net) to debug your API calls. (`AIRTABLE_ENDPOINT_URL`)
50+
it if you are using an API proxy (e.g. runscope.net) to debug your API calls. (`AIRTABLE_ENDPOINT_URL`)
5151
* `requestTimeout` - the timeout in milliseconds for requests. The default is 5 minutes (`300000`)
5252

5353
You can set the options globally via `Airtable.configure`:

build/airtable.browser.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ require=(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c=
22
"use strict";
33
// istanbul ignore file
44
var AbortController;
5-
if (typeof window === 'undefined') {
5+
var browserGlobal = typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : null; // self is the global in web workers
6+
if (!browserGlobal) {
67
AbortController = require('abort-controller');
78
}
89
else if ('signal' in new Request('')) {
9-
AbortController = window.AbortController;
10+
AbortController = browserGlobal.AbortController;
1011
}
1112
else {
1213
/* eslint-disable @typescript-eslint/no-var-requires */
@@ -326,7 +327,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
326327
};
327328
// istanbul ignore file
328329
var node_fetch_1 = __importDefault(require("node-fetch"));
329-
module.exports = typeof window === 'undefined' ? node_fetch_1.default : window.fetch.bind(window);
330+
var browserGlobal = typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : null; // self is the global in web workers
331+
module.exports = !browserGlobal ? node_fetch_1.default : browserGlobal.fetch.bind(browserGlobal);
330332

331333
},{"node-fetch":20}],8:[function(require,module,exports){
332334
"use strict";
@@ -443,7 +445,7 @@ module.exports = objectToQueryParamString;
443445

444446
},{"lodash/isArray":79,"lodash/isNil":85,"lodash/keys":93}],12:[function(require,module,exports){
445447
"use strict";
446-
module.exports = "0.11.5";
448+
module.exports = "0.11.6";
447449

448450
},{}],13:[function(require,module,exports){
449451
"use strict";
@@ -3718,9 +3720,9 @@ var Airtable = /** @class */ (function () {
37183720
};
37193721
Airtable.default_config = function () {
37203722
return {
3721-
endpointUrl: undefined || 'https://api.airtable.com',
3723+
endpointUrl: "" || 'https://api.airtable.com',
37223724
apiVersion: '0.1.0',
3723-
apiKey: undefined,
3725+
apiKey: "",
37243726
noRetryIfRateLimited: false,
37253727
requestTimeout: 300 * 1000,
37263728
};

gruntfile.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@ module.exports = function(grunt) {
2121
transform: [
2222
[
2323
'envify',
24+
// IMPORTANT: mask out environment variables that should never be shipped to the browser
2425
{
2526
_: 'purge',
27+
AIRTABLE_ENDPOINT_URL: '',
28+
AIRTABLE_API_KEY: '',
2629
npm_package_version: pkg.version,
2730
},
2831
],
@@ -42,8 +45,11 @@ module.exports = function(grunt) {
4245
transform: [
4346
[
4447
'envify',
48+
// IMPORTANT: mask out environment variables that should never be shipped to the browser
4549
{
4650
_: 'purge',
51+
AIRTABLE_ENDPOINT_URL: '',
52+
AIRTABLE_API_KEY: '',
4753
npm_package_version: pkg.version,
4854
},
4955
],

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "airtable",
3-
"version": "0.11.5",
3+
"version": "0.11.6",
44
"license": "MIT",
55
"homepage": "https://github.com/airtable/airtable.js",
66
"repository": "git://github.com/airtable/airtable.js.git",

src/abort-controller.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
// istanbul ignore file
22
let AbortController: new () => AbortController;
3-
if (typeof window === 'undefined') {
3+
const browserGlobal =
4+
typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : null; // self is the global in web workers
5+
if (!browserGlobal) {
46
AbortController = require('abort-controller');
57
} else if ('signal' in new Request('')) {
6-
AbortController = window.AbortController;
8+
AbortController = browserGlobal.AbortController;
79
} else {
810
/* eslint-disable @typescript-eslint/no-var-requires */
911
const polyfill = require('abortcontroller-polyfill/dist/cjs-ponyfill');

src/fetch.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
// istanbul ignore file
22
import nodeFetch from 'node-fetch';
33

4-
export = typeof window === 'undefined' ? (nodeFetch as typeof fetch) : window.fetch.bind(window);
4+
const browserGlobal =
5+
typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : null; // self is the global in web workers
6+
7+
export = !browserGlobal ? (nodeFetch as typeof fetch) : browserGlobal.fetch.bind(browserGlobal);

test/test_files/airtable.browser.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ require=(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c=
22
"use strict";
33
// istanbul ignore file
44
var AbortController;
5-
if (typeof window === 'undefined') {
5+
var browserGlobal = typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : null; // self is the global in web workers
6+
if (!browserGlobal) {
67
AbortController = require('abort-controller');
78
}
89
else if ('signal' in new Request('')) {
9-
AbortController = window.AbortController;
10+
AbortController = browserGlobal.AbortController;
1011
}
1112
else {
1213
/* eslint-disable @typescript-eslint/no-var-requires */
@@ -326,7 +327,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
326327
};
327328
// istanbul ignore file
328329
var node_fetch_1 = __importDefault(require("node-fetch"));
329-
module.exports = typeof window === 'undefined' ? node_fetch_1.default : window.fetch.bind(window);
330+
var browserGlobal = typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : null; // self is the global in web workers
331+
module.exports = !browserGlobal ? node_fetch_1.default : browserGlobal.fetch.bind(browserGlobal);
330332

331333
},{"node-fetch":20}],8:[function(require,module,exports){
332334
"use strict";
@@ -443,7 +445,7 @@ module.exports = objectToQueryParamString;
443445

444446
},{"lodash/isArray":79,"lodash/isNil":85,"lodash/keys":93}],12:[function(require,module,exports){
445447
"use strict";
446-
module.exports = "0.11.5";
448+
module.exports = "0.11.6";
447449

448450
},{}],13:[function(require,module,exports){
449451
"use strict";
@@ -3718,9 +3720,9 @@ var Airtable = /** @class */ (function () {
37183720
};
37193721
Airtable.default_config = function () {
37203722
return {
3721-
endpointUrl: undefined || 'https://api.airtable.com',
3723+
endpointUrl: "" || 'https://api.airtable.com',
37223724
apiVersion: '0.1.0',
3723-
apiKey: undefined,
3725+
apiKey: "",
37243726
noRetryIfRateLimited: false,
37253727
requestTimeout: 300 * 1000,
37263728
};

0 commit comments

Comments
 (0)