@financial-times/dotcom-ui-polyfill-service 7.3.1 → 7.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@financial-times/dotcom-ui-polyfill-service",
3
- "version": "7.3.1",
3
+ "version": "7.3.3",
4
4
  "description": "",
5
5
  "main": "server.js",
6
6
  "browser": "browser.js",
@@ -24,7 +24,11 @@
24
24
  "npm": "7.x || 8.x"
25
25
  },
26
26
  "files": [
27
- "dist/"
27
+ "dist/",
28
+ "src/",
29
+ "browser.js",
30
+ "component.js",
31
+ "styles.scss"
28
32
  ],
29
33
  "repository": {
30
34
  "type": "git",
@@ -38,4 +42,4 @@
38
42
  "devDependencies": {
39
43
  "check-engine": "^1.10.1"
40
44
  }
41
- }
45
+ }
@@ -0,0 +1,18 @@
1
+ import * as subject from '../polyfillServiceURLs'
2
+
3
+ describe('dotcom-ui-polyfill-service', () => {
4
+ it('provides both core and enhanced URLs', () => {
5
+ expect(typeof subject.core()).toBe('string')
6
+ expect(typeof subject.enhanced()).toBe('string')
7
+ })
8
+
9
+ it('joins all of the configured features', () => {
10
+ expect(subject.core()).toMatch(/features=HTMLPictureElement/)
11
+ expect(subject.enhanced()).toMatch(/features=default%2Ces5%2Ces2015/)
12
+ })
13
+
14
+ it('appends the source to each URL', () => {
15
+ expect(subject.core()).toMatch(/source=next/)
16
+ expect(subject.enhanced()).toMatch(/source=next/)
17
+ })
18
+ })
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './polyfillServiceURLs'
@@ -0,0 +1,103 @@
1
+ import querystring from 'querystring'
2
+
3
+ // Please see https://polyfill.io/v3/url-builder/ for information about which
4
+ // features are available and how they may be used.
5
+
6
+ const polyfillsCore = ['HTMLPictureElement']
7
+
8
+ const polyfillsEnhanced = [
9
+ // What Andrew Betts decided is "default":
10
+ /*
11
+ Array.from
12
+ Array.isArray
13
+ Array.of
14
+ Array.prototype.every
15
+ Array.prototype.fill
16
+ Array.prototype.filter
17
+ Array.prototype.forEach
18
+ Array.prototype.indexOf
19
+ Array.prototype.lastIndexOf
20
+ Array.prototype.map
21
+ Array.prototype.reduce
22
+ Array.prototype.reduceRight
23
+ Array.prototype.some
24
+ CustomEvent
25
+ DOMTokenList
26
+ Date.now
27
+ Date.prototype.toISOString
28
+ DocumentFragment.prototype.append
29
+ DocumentFragment.prototype.prepend
30
+ Element.prototype.after
31
+ Element.prototype.append
32
+ Element.prototype.before
33
+ Element.prototype.classList
34
+ Element.prototype.cloneNode
35
+ Element.prototype.closest
36
+ Element.prototype.matches
37
+ Element.prototype.prepend
38
+ Element.prototype.remove
39
+ Element.prototype.replaceWith
40
+ Element
41
+ Event.focusin
42
+ Event.hashchange
43
+ Event
44
+ Function.prototype.bind
45
+ JSON
46
+ Map
47
+ Node.prototype.contains
48
+ Number.isNaN
49
+ Object.assign
50
+ Object.create
51
+ Object.defineProperties
52
+ Object.defineProperty
53
+ Object.getOwnPropertyDescriptor
54
+ Object.getOwnPropertyNames
55
+ Object.getPrototypeOf
56
+ Object.keys
57
+ Promise
58
+ Set
59
+ String.prototype.endsWith
60
+ String.prototype.includes
61
+ String.prototype.startsWith
62
+ String.prototype.trim
63
+ URL
64
+ Window
65
+ XMLHttpRequest
66
+ atob
67
+ document.querySelector
68
+ document.visibilityState
69
+ document
70
+ location.origin
71
+ requestAnimationFrame
72
+ ~html5-elements
73
+ */
74
+ 'default',
75
+
76
+ // ECMAScript presets
77
+ 'es5',
78
+ 'es2015',
79
+ 'es2016',
80
+ 'es2017',
81
+
82
+ // Web browser features
83
+ 'EventSource',
84
+ 'fetch',
85
+ 'HTMLPictureElement',
86
+ 'IntersectionObserver',
87
+ 'NodeList.prototype.forEach'
88
+ ]
89
+
90
+ export const core = () => {
91
+ return formatURL(polyfillsCore)
92
+ }
93
+
94
+ export const enhanced = () => {
95
+ return formatURL(polyfillsEnhanced)
96
+ }
97
+
98
+ function formatURL(features: string[]): string {
99
+ const serviceURL = 'https://polyfill.io/v3/polyfill.min.js'
100
+ const queryString = querystring.stringify({ features: features.join(','), source: 'next' })
101
+
102
+ return `${serviceURL}?${queryString}`
103
+ }