ember-browser-services 3.0.5 → 4.0.2

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.
Files changed (67) hide show
  1. package/CHANGELOG.md +250 -0
  2. package/README.md +6 -2
  3. package/addon-main.cjs +5 -0
  4. package/dist/_app_/services/browser/document.js +1 -0
  5. package/dist/_app_/services/browser/local-storage.js +1 -0
  6. package/dist/_app_/services/browser/navigator.js +1 -0
  7. package/dist/_app_/services/browser/session-storage.js +1 -0
  8. package/dist/_app_/services/browser/window.js +1 -0
  9. package/dist/index.d.ts +2 -0
  10. package/dist/index.d.ts.map +1 -0
  11. package/dist/index.js +2 -0
  12. package/dist/index.js.map +1 -0
  13. package/{declarations/utils/proxy-service.d.ts → dist/services/browser/-proxy-service.d.ts} +3 -2
  14. package/{addon/utils/proxy-service.ts → dist/services/browser/-proxy-service.js} +20 -40
  15. package/dist/services/browser/-proxy-service.js.map +1 -0
  16. package/dist/services/browser/document.d.ts +7 -0
  17. package/dist/services/browser/document.js +7 -0
  18. package/dist/services/browser/document.js.map +1 -0
  19. package/{declarations → dist}/services/browser/local-storage.d.ts +1 -2
  20. package/{addon/services/browser/local-storage.ts → dist/services/browser/local-storage.js} +4 -9
  21. package/dist/services/browser/local-storage.js.map +1 -0
  22. package/dist/services/browser/navigator.d.ts +7 -0
  23. package/dist/services/browser/navigator.js +7 -0
  24. package/dist/services/browser/navigator.js.map +1 -0
  25. package/{declarations → dist}/services/browser/session-storage.d.ts +1 -2
  26. package/{addon/services/browser/session-storage.ts → dist/services/browser/session-storage.js} +4 -9
  27. package/dist/services/browser/session-storage.js.map +1 -0
  28. package/{declarations → dist}/services/browser/window.d.ts +1 -2
  29. package/dist/services/browser/window.js +16 -0
  30. package/dist/services/browser/window.js.map +1 -0
  31. package/{declarations → dist}/test-support/-private/web-storage.d.ts +4 -4
  32. package/{addon-test-support/-private/web-storage.ts → dist/test-support/-private/web-storage.js} +12 -9
  33. package/dist/test-support/-private/web-storage.js.map +1 -0
  34. package/dist/test-support/index.d.ts +13 -0
  35. package/{addon-test-support/index.ts → dist/test-support/index.js} +20 -40
  36. package/dist/test-support/index.js.map +1 -0
  37. package/dist/test-support/window-mock-augments.d.ts +2 -0
  38. package/{addon-test-support/window-mock-augments.ts → dist/test-support/window-mock-augments.js} +14 -15
  39. package/dist/test-support/window-mock-augments.js.map +1 -0
  40. package/dist/types.d.ts +17 -0
  41. package/dist/types.js +2 -0
  42. package/dist/types.js.map +1 -0
  43. package/package.json +96 -135
  44. package/LICENSE.md +0 -9
  45. package/addon/services/browser/document.ts +0 -21
  46. package/addon/services/browser/navigator.ts +0 -21
  47. package/addon/services/browser/window.ts +0 -27
  48. package/addon/tsconfig.json +0 -11
  49. package/addon/tsconfig.tsbuildinfo +0 -1
  50. package/addon/types.ts +0 -25
  51. package/addon-test-support/tsconfig.json +0 -16
  52. package/addon-test-support/tsconfig.tsbuildinfo +0 -1
  53. package/app/services/browser/document.js +0 -1
  54. package/app/services/browser/local-storage.js +0 -1
  55. package/app/services/browser/navigator.js +0 -1
  56. package/app/services/browser/session-storage.js +0 -1
  57. package/app/services/browser/window.js +0 -1
  58. package/config/build/tsconfig.compiler-options.ember.json +0 -14
  59. package/config/build/tsconfig.compiler-options.json +0 -54
  60. package/config/ember-try.js +0 -98
  61. package/config/environment.js +0 -5
  62. package/declarations/services/browser/document.d.ts +0 -16
  63. package/declarations/services/browser/navigator.d.ts +0 -16
  64. package/declarations/test-support/index.d.ts +0 -15
  65. package/declarations/test-support/window-mock-augments.d.ts +0 -1
  66. package/declarations/types.d.ts +0 -16
  67. package/index.js +0 -14
package/CHANGELOG.md ADDED
@@ -0,0 +1,250 @@
1
+ ## [4.0.2](https://github.com/CrowdStrike/ember-browser-services/compare/v4.0.1...v4.0.2) (2022-06-08)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **package:** app-re-exports included non-public file ([f2c7ef1](https://github.com/CrowdStrike/ember-browser-services/commit/f2c7ef11c13d2364c79cc0996b2ea0a54b2f6a02))
7
+
8
+ ## [4.0.1](https://github.com/CrowdStrike/ember-browser-services/compare/v4.0.0...v4.0.1) (2022-06-07)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **package:** addon-main specified incorrect path ([61e99ab](https://github.com/CrowdStrike/ember-browser-services/commit/61e99abb11c1c3cede8c9beb916d60f7650fbc0d))
14
+ * **package:** exports field did not specify test-support ([83a303f](https://github.com/CrowdStrike/ember-browser-services/commit/83a303f56f7ccfa2db92c4dc1cfbec982235ab3d))
15
+ * **package:** typesVersions was woefully incorrect ([3538f00](https://github.com/CrowdStrike/ember-browser-services/commit/3538f0072272604aa3cf460fb7ca47bd2233a9e7))
16
+
17
+ # [4.0.0](https://github.com/CrowdStrike/ember-browser-services/compare/v3.0.5...v4.0.0) (2022-06-07)
18
+
19
+
20
+ ### chore
21
+
22
+ * run `npx ember-addon-migrator` ([74bc722](https://github.com/CrowdStrike/ember-browser-services/commit/74bc722aca8fa0787b01b55be7bad58b9b873b9c))
23
+
24
+
25
+ ### BREAKING CHANGES
26
+
27
+ * this addon now requires ember-auto-import@v2
28
+
29
+ ## [3.0.5](https://github.com/CrowdStrike/ember-browser-services/compare/v3.0.4...v3.0.5) (2022-05-16)
30
+
31
+
32
+ ### Bug Fixes
33
+
34
+ * **package:** opt in to which files to include on npm, instead of the inverse ([f0d2dd9](https://github.com/CrowdStrike/ember-browser-services/commit/f0d2dd917e1453fdd3b146b5741d70aa033431fb))
35
+
36
+ ## [3.0.4](https://github.com/CrowdStrike/ember-browser-services/compare/v3.0.3...v3.0.4) (2022-04-21)
37
+
38
+
39
+ ### Bug Fixes
40
+
41
+ * **deps:** update dependency ember-cli-typescript to ^5.1.0 ([d2dd804](https://github.com/CrowdStrike/ember-browser-services/commit/d2dd8047b1850568a942fa6799838316974ab762))
42
+
43
+ ## [3.0.3](https://github.com/CrowdStrike/ember-browser-services/compare/v3.0.2...v3.0.3) (2022-02-18)
44
+
45
+
46
+ ### Bug Fixes
47
+
48
+ * **deps:** update dependency ember-window-mock to ^0.8.1 ([19d60dc](https://github.com/CrowdStrike/ember-browser-services/commit/19d60dc40c6bef507d93b1f1195888e3274cf1f3))
49
+
50
+ ## [3.0.2](https://github.com/CrowdStrike/ember-browser-services/compare/v3.0.1...v3.0.2) (2022-02-04)
51
+
52
+
53
+ ### Bug Fixes
54
+
55
+ * **deps:** update dependency ember-cli-typescript to v5 ([c02ec71](https://github.com/CrowdStrike/ember-browser-services/commit/c02ec71729073af33ee2b8242cf764806c21396f))
56
+
57
+ ## [3.0.1](https://github.com/CrowdStrike/ember-browser-services/compare/v3.0.0...v3.0.1) (2022-01-31)
58
+
59
+
60
+ ### Bug Fixes
61
+
62
+ * **deps:** update dependency ember-window-mock to ^0.8.0 ([a717bde](https://github.com/CrowdStrike/ember-browser-services/commit/a717bdeb01674ba69c649ed807b851281af58a90))
63
+
64
+ # [3.0.0](https://github.com/CrowdStrike/ember-browser-services/compare/v2.1.4...v3.0.0) (2022-01-20)
65
+
66
+
67
+ ### Bug Fixes
68
+
69
+ * **deps:** update dependency ember-cli-babel to ^7.26.11 ([5381024](https://github.com/CrowdStrike/ember-browser-services/commit/538102488b54da3db067bd56df2447249b29d5bd))
70
+
71
+
72
+ ### chore
73
+
74
+ * drop support for classic ember ([353195f](https://github.com/CrowdStrike/ember-browser-services/commit/353195f4baff841392ec9f730fbf94ba131d5bed))
75
+ * drop support for node 12 ([05d3a3b](https://github.com/CrowdStrike/ember-browser-services/commit/05d3a3b0760aabb749c4c4a6fcf501028c3eac5f))
76
+
77
+
78
+ ### BREAKING CHANGES
79
+
80
+ * ember octane is two years old
81
+ and is all that is supported. This addon may still work with
82
+ classic ember, but it will not be tested against (to help
83
+ simplify this addon's C.I. configuration)
84
+ * node 12 is no longer supported
85
+
86
+ ## [2.1.4](https://github.com/CrowdStrike/ember-browser-services/compare/v2.1.3...v2.1.4) (2021-12-17)
87
+
88
+
89
+ ### Bug Fixes
90
+
91
+ * **deps:** update dependency ember-cli-babel to ^7.26.10 ([3c2f6d6](https://github.com/CrowdStrike/ember-browser-services/commit/3c2f6d6f94ccf9f46a4cdd55653d38ceeb7e3018))
92
+
93
+ ## [2.1.3](https://github.com/CrowdStrike/ember-browser-services/compare/v2.1.2...v2.1.3) (2021-12-16)
94
+
95
+
96
+ ### Bug Fixes
97
+
98
+ * **deps:** update dependency ember-cli-babel to ^7.26.8 ([82d4fe6](https://github.com/CrowdStrike/ember-browser-services/commit/82d4fe6e2b3d19a78f06b54dece915364435f822))
99
+
100
+ ## [2.1.2](https://github.com/CrowdStrike/ember-browser-services/compare/v2.1.1...v2.1.2) (2021-12-15)
101
+
102
+
103
+ ### Bug Fixes
104
+
105
+ * **deps:** update dependency ember-cli-babel to ^7.26.7 ([1ba87de](https://github.com/CrowdStrike/ember-browser-services/commit/1ba87def8c8153e19ced80b335dfb000e3972a76))
106
+
107
+ ## [2.1.1](https://github.com/CrowdStrike/ember-browser-services/compare/v2.1.0...v2.1.1) (2021-12-06)
108
+
109
+
110
+ ### Bug Fixes
111
+
112
+ * **deps:** update dependency ember-cli-htmlbars to ^6.0.1 ([ee02fa1](https://github.com/CrowdStrike/ember-browser-services/commit/ee02fa1d7b190ed51ccc69fb12f87b7ac1f6717f))
113
+
114
+ # [2.1.0](https://github.com/CrowdStrike/ember-browser-services/compare/v2.0.2...v2.1.0) (2021-11-23)
115
+
116
+
117
+ ### Features
118
+
119
+ * support session-storage ([ffaf626](https://github.com/CrowdStrike/ember-browser-services/commit/ffaf6263080546c2dab2f5c62db40166dfc6f3a1))
120
+
121
+ ## [2.0.2](https://github.com/CrowdStrike/ember-browser-services/compare/v2.0.1...v2.0.2) (2021-11-18)
122
+
123
+
124
+ ### Bug Fixes
125
+
126
+ * **deps:** update dependency ember-cli-htmlbars to v6 ([a3115e3](https://github.com/CrowdStrike/ember-browser-services/commit/a3115e396af97177ce4b3824718ea18648ee0c60))
127
+
128
+ ## [2.0.1](https://github.com/CrowdStrike/ember-browser-services/compare/v2.0.0...v2.0.1) (2021-11-18)
129
+
130
+
131
+ ### Bug Fixes
132
+
133
+ * **support:** expand and fix support ([dcd8dd6](https://github.com/CrowdStrike/ember-browser-services/commit/dcd8dd68b2c0170456e82e999513bea6beecbafa))
134
+
135
+ # [2.0.0](https://github.com/CrowdStrike/ember-browser-services/compare/v1.1.8...v2.0.0) (2021-09-09)
136
+
137
+
138
+ ### Features
139
+
140
+ * utilize ember-window-mock for the underlying provider ([659f20f](https://github.com/CrowdStrike/ember-browser-services/commit/659f20f702873c942d6476301730107c71a566c4))
141
+
142
+
143
+ ### BREAKING CHANGES
144
+
145
+ * invalid hrefs will throw an error
146
+
147
+ ## [1.1.8](https://github.com/CrowdStrike/ember-browser-services/compare/v1.1.7...v1.1.8) (2021-08-31)
148
+
149
+
150
+ ### Bug Fixes
151
+
152
+ * **npm:** remove unneeded files from npm package ([ee0914c](https://github.com/CrowdStrike/ember-browser-services/commit/ee0914cc9e35db88dbd42ba1f0abdc73faa8c733))
153
+
154
+ ## [1.1.7](https://github.com/CrowdStrike/ember-browser-services/compare/v1.1.6...v1.1.7) (2021-08-31)
155
+
156
+
157
+ ### Bug Fixes
158
+
159
+ * **deps:** update dependency ember-cli-babel to ^7.26.6 ([37cf27f](https://github.com/CrowdStrike/ember-browser-services/commit/37cf27ffb7322152d6c3c347f8ac7e41e6416ce9))
160
+ * **deps:** update dependency ember-cli-typescript to ^4.2.1 ([ab1ab86](https://github.com/CrowdStrike/ember-browser-services/commit/ab1ab869df805acaea7045d5af2cd925fc1a55c7))
161
+
162
+ ## [1.1.6](https://github.com/CrowdStrike/ember-browser-services/compare/v1.1.5...v1.1.6) (2021-04-17)
163
+
164
+
165
+ ### Bug Fixes
166
+
167
+ * **navigator:** add app re-export ([7a9db4d](https://github.com/CrowdStrike/ember-browser-services/commit/7a9db4dc9afa62f5b3a20754747897f53aadf746))
168
+
169
+ ## [1.1.5](https://github.com/CrowdStrike/ember-browser-services/compare/v1.1.4...v1.1.5) (2021-04-17)
170
+
171
+
172
+ ### Bug Fixes
173
+
174
+ * **deps:** update dependency ember-cli-htmlbars to ^5.7.1 ([f4062bf](https://github.com/CrowdStrike/ember-browser-services/commit/f4062bfc2b417ef524c2ce28ba82d81cbbdb6e83))
175
+
176
+ ## [1.1.4](https://github.com/CrowdStrike/ember-browser-services/compare/v1.1.3...v1.1.4) (2021-03-15)
177
+
178
+
179
+ ### Bug Fixes
180
+
181
+ * **deps:** update dependency ember-cli-htmlbars to ^5.6.5 ([f60cc89](https://github.com/CrowdStrike/ember-browser-services/commit/f60cc89ad048429ae0a58890030a9b488b096d49))
182
+
183
+ ## [1.1.3](https://github.com/CrowdStrike/ember-browser-services/compare/v1.1.2...v1.1.3) (2021-03-09)
184
+
185
+
186
+ ### Bug Fixes
187
+
188
+ * **deps:** update dependency ember-cli-htmlbars to ^5.6.4 ([35d3b07](https://github.com/CrowdStrike/ember-browser-services/commit/35d3b07a99e4dc69889d29d87f25816be0bb3570))
189
+
190
+ ## [1.1.2](https://github.com/CrowdStrike/ember-browser-services/compare/v1.1.1...v1.1.2) (2021-02-27)
191
+
192
+
193
+ ### Bug Fixes
194
+
195
+ * **deps:** update dependency ember-cli-htmlbars to ^5.6.2 ([60820b8](https://github.com/CrowdStrike/ember-browser-services/commit/60820b8c5e9ce2d07b24565518b322d3e89088eb))
196
+
197
+ ## [1.1.1](https://github.com/CrowdStrike/ember-browser-services/compare/v1.1.0...v1.1.1) (2021-02-26)
198
+
199
+
200
+ ### Bug Fixes
201
+
202
+ * **deps:** update dependency ember-cli-htmlbars to ^5.6.0 ([455b0b3](https://github.com/CrowdStrike/ember-browser-services/commit/455b0b351218da31322c3ad12f9aee384c115fb5))
203
+
204
+ # [1.1.0](https://github.com/CrowdStrike/ember-browser-services/compare/v1.0.2...v1.1.0) (2021-02-22)
205
+
206
+
207
+ ### Features
208
+
209
+ * add normal object-style stubbing to the navigator ([3e50c60](https://github.com/CrowdStrike/ember-browser-services/commit/3e50c600dcce24ffeb9513b048dbfb42b464a9bf))
210
+ * add support for the navigator ([dc34355](https://github.com/CrowdStrike/ember-browser-services/commit/dc3435520823e4354daab32c6122b523d7a68697))
211
+
212
+ ## [1.0.2](https://github.com/CrowdStrike/ember-browser-services/compare/v1.0.1...v1.0.2) (2021-02-16)
213
+
214
+
215
+ ### Bug Fixes
216
+
217
+ * **deps:** update dependency ember-cli-babel to ^7.24.0 ([e84ab13](https://github.com/CrowdStrike/ember-browser-services/commit/e84ab13407e6b6b1832d57e4b606dccdbdac0513))
218
+
219
+ ## [1.0.1](https://github.com/CrowdStrike/ember-browser-services/compare/v1.0.0...v1.0.1) (2021-02-13)
220
+
221
+
222
+ ### Bug Fixes
223
+
224
+ * **ci:** disable persist-credentials option to actions/checkout ([c5fd21c](https://github.com/CrowdStrike/ember-browser-services/commit/c5fd21ce5a869828530dcad6216a6288c8c96662))
225
+
226
+ # 1.0.0 (2021-02-13)
227
+
228
+
229
+ ### Bug Fixes
230
+
231
+ * package.json scripts ([acdb13c](https://github.com/CrowdStrike/ember-browser-services/commit/acdb13c5fdfc7037d9f9a735b7a63903cfe059da))
232
+ * specify 'main' for the release branch for semantic release ([02c533a](https://github.com/CrowdStrike/ember-browser-services/commit/02c533a3e1ef97e638b605829f50a03e9608653d))
233
+ * update workflow configuration to reference branch 'main' ([2bcdac9](https://github.com/CrowdStrike/ember-browser-services/commit/2bcdac9f3bc87aa96b6e6f39d8de2db6311175f5))
234
+
235
+
236
+ ### chore
237
+
238
+ * drop support for node 10 ([e7a5550](https://github.com/CrowdStrike/ember-browser-services/commit/e7a55503f34affa76e9fa9111d3678f73c56f90c))
239
+
240
+
241
+ ### Features
242
+
243
+ * automatic releases based on conventional commits ([c43a9f2](https://github.com/CrowdStrike/ember-browser-services/commit/c43a9f21a8a397d7f2ad331f883edafb194b4cc8))
244
+ * copy over files - initial implementation ([6b02e23](https://github.com/CrowdStrike/ember-browser-services/commit/6b02e23712ee505ee3c184a31accf9322328b602))
245
+ * support all properties on Location ([c5329bb](https://github.com/CrowdStrike/ember-browser-services/commit/c5329bbf80b913e29e6e71cb58d4ea1174ba7893))
246
+
247
+
248
+ ### BREAKING CHANGES
249
+
250
+ * node 10 support dropped
package/README.md CHANGED
@@ -15,6 +15,8 @@ looking at the documentation.
15
15
 
16
16
  ## Installation
17
17
 
18
+ pnpm add ember-browser-services
19
+ # or
18
20
  yarn add ember-browser-services
19
21
  # or
20
22
  npm install ember-browser-services
@@ -23,8 +25,10 @@ looking at the documentation.
23
25
 
24
26
  ## Compatibility
25
27
 
26
- * Ember.js v3.12 or above
27
- * Node.js v10 or above
28
+ * Ember.js v3.12 or above
29
+ * ember-auto-import v2 or above
30
+ * typescript v4.5 or above
31
+ * embroider max-compat and strict modes
28
32
 
29
33
  ## Usage
30
34
 
package/addon-main.cjs ADDED
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+
3
+ const { addonV1Shim } = require('@embroider/addon-shim');
4
+
5
+ module.exports = addonV1Shim(__dirname);
@@ -0,0 +1 @@
1
+ export { default } from "ember-browser-services/services/browser/document.js";
@@ -0,0 +1 @@
1
+ export { default } from "ember-browser-services/services/browser/local-storage.js";
@@ -0,0 +1 @@
1
+ export { default } from "ember-browser-services/services/browser/navigator.js";
@@ -0,0 +1 @@
1
+ export { default } from "ember-browser-services/services/browser/session-storage.js";
@@ -0,0 +1 @@
1
+ export { default } from "ember-browser-services/services/browser/window.js";
@@ -0,0 +1,2 @@
1
+ export { DocumentService, LocalStorageService, NavigatorService, SessionStorageService, WindowService } from "./types";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,gGAMN,gBAAgB"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,5 +1,5 @@
1
1
  import Service from '@ember/service';
2
- import type { Class } from 'ember-browser-services/types';
2
+ import { Class } from "../../types";
3
3
  /**
4
4
  * Allows Services to behave as Proxy objects for real objects, such as
5
5
  * window, document, navigator, Worker, etc.
@@ -13,4 +13,5 @@ import type { Class } from 'ember-browser-services/types';
13
13
  *
14
14
  * @param {Object | Class} browserObject - the api to wrap a service around.
15
15
  */
16
- export declare function proxyService<BrowserAPI>(ObjectToProxy: BrowserAPI | Class<BrowserAPI>): typeof Service & BrowserAPI;
16
+ declare function proxyService<BrowserAPI>(ObjectToProxy: BrowserAPI | Class<BrowserAPI>): typeof Service & BrowserAPI;
17
+ export { proxyService };
@@ -1,7 +1,5 @@
1
1
  import Service from '@ember/service';
2
2
 
3
- import type { Class } from 'ember-browser-services/types';
4
-
5
3
  /**
6
4
  * Allows Services to behave as Proxy objects for real objects, such as
7
5
  * window, document, navigator, Worker, etc.
@@ -15,19 +13,15 @@ import type { Class } from 'ember-browser-services/types';
15
13
  *
16
14
  * @param {Object | Class} browserObject - the api to wrap a service around.
17
15
  */
18
- export function proxyService<BrowserAPI>(
19
- ObjectToProxy: BrowserAPI | Class<BrowserAPI>
20
- ): typeof Service & BrowserAPI {
21
- type ProxyKey = BrowserAPI | Service;
22
- type CreateMethod = typeof Service['create'];
23
16
 
17
+ function proxyService(ObjectToProxy) {
24
18
  // extending the types for the static method create is too hard / impossible
25
19
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
26
- let UnTypedService = Service as any;
20
+ let UnTypedService = Service;
27
21
 
28
- function instanceHandlerFor(browserObject: BrowserAPI) {
22
+ function instanceHandlerFor(browserObject) {
29
23
  return {
30
- get<K extends keyof ProxyKey>(targetInstance: Service, prop: K, receiver: unknown) {
24
+ get(targetInstance, prop, receiver) {
31
25
  if (prop in targetInstance) {
32
26
  return Reflect.get(targetInstance, prop, receiver);
33
27
  }
@@ -43,63 +37,49 @@ export function proxyService<BrowserAPI>(
43
37
 
44
38
  return value;
45
39
  },
46
- set<K extends keyof ProxyKey>(
47
- targetInstance: Service,
48
- prop: K,
49
- value: BrowserAPI[K],
50
- receiver: unknown
51
- ) {
40
+
41
+ set(targetInstance, prop, value, receiver) {
52
42
  if (prop in targetInstance) {
53
43
  Reflect.set(targetInstance, prop, value, receiver);
54
44
  }
55
45
 
56
46
  browserObject[prop] = value;
57
-
58
47
  return true;
59
- },
48
+ }
49
+
60
50
  };
61
51
  }
62
52
 
63
- function isConstructable(proxyTo: BrowserAPI | Class<BrowserAPI>): proxyTo is Class<BrowserAPI> {
53
+ function isConstructable(proxyTo) {
64
54
  return typeof proxyTo === 'function';
65
- }
66
-
67
- // We have to untype the Service, because...
55
+ } // We have to untype the Service, because...
68
56
  // this is nuts:
69
57
  // https://github.com/DefinitelyTyped/DefinitelyTyped/blob/da0e5b5/types/ember__object/core.d.ts#L82-L94
70
58
  //
71
59
  // it's also all private, and the ember-TS team apparently didn't think people would want to do this :D
60
+
61
+
72
62
  class ProxyCreator extends UnTypedService {
73
63
  // https://github.com/emberjs/ember.js/blob/master/packages/%40ember/service/index.js#L66-L74
74
64
  // https://github.com/emberjs/ember.js/blob/f85cefe9855b2521b02800d4bb2b68da7db2a214/packages/%40ember/service/index.js#L68-L72
75
65
  static isServiceFactory = true;
76
66
 
77
- static create(injections: Parameters<CreateMethod>): ReturnType<CreateMethod> {
78
- let serviceInstance = class ProxiedService extends Service {
79
- // @private
80
- declare __browser_object__: BrowserAPI;
81
- /*
82
- * We cannot create the base Service, we must use a new one.
83
- * If we don't, we are unable to run tests in a legacy qunit environment
84
- * due to "writableChains" issues.
85
- *
86
- * https://github.com/emberjs/ember.js/pull/15347/files#diff-7e13eecefe753df1d82ce67b32bc4366R361
87
- *
88
- * */
89
- }.create(injections);
90
-
67
+ static create(injections) {
68
+ let serviceInstance = class ProxiedService extends Service {}.create(injections);
91
69
  let browserObject = isConstructable(ObjectToProxy) ? new ObjectToProxy() : ObjectToProxy;
92
-
93
70
  serviceInstance.__browser_object__ = browserObject;
94
-
95
71
  return new Proxy(serviceInstance, instanceHandlerFor(browserObject));
96
72
  }
97
73
 
98
- constructor(...args: unknown[]) {
74
+ constructor(...args) {
99
75
  super(...args);
100
76
  throw new Error('ProxyCreator is not new-able');
101
77
  }
78
+
102
79
  }
103
80
 
104
- return ProxyCreator as unknown as typeof Service & BrowserAPI;
81
+ return ProxyCreator;
105
82
  }
83
+
84
+ export { proxyService };
85
+ //# sourceMappingURL=-proxy-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"-proxy-service.js","sources":["../../../src/services/browser/-proxy-service.ts"],"sourcesContent":["import Service from '@ember/service';\n\nimport type { Class } from '../../types';\n\n/**\n * Allows Services to behave as Proxy objects for real objects, such as\n * window, document, navigator, Worker, etc.\n *\n * useful for consistently accessing unmockable objects and then replacing them\n * with fakes in testing.\n *\n * would it be worth recursively wrapping in a proxy for any reason?\n *\n * NOTE: This only works for one layer deep of properties\n *\n * @param {Object | Class} browserObject - the api to wrap a service around.\n */\nexport function proxyService<BrowserAPI>(\n ObjectToProxy: BrowserAPI | Class<BrowserAPI>\n): typeof Service & BrowserAPI {\n type ProxyKey = BrowserAPI | Service;\n type CreateMethod = typeof Service['create'];\n\n // extending the types for the static method create is too hard / impossible\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let UnTypedService = Service as any;\n\n function instanceHandlerFor(browserObject: BrowserAPI) {\n return {\n get<K extends keyof ProxyKey>(targetInstance: Service, prop: K, receiver: unknown) {\n if (prop in targetInstance) {\n return Reflect.get(targetInstance, prop, receiver);\n }\n\n let value = browserObject[prop];\n\n if (typeof value === 'function') {\n // prevents the error \"Illegal Invocation\"\n // which can sometimes happen due to losing the \"this\" depending on\n // the invocation context at the call site\n return value.bind(browserObject);\n }\n\n return value;\n },\n set<K extends keyof ProxyKey>(\n targetInstance: Service,\n prop: K,\n value: BrowserAPI[K],\n receiver: unknown\n ) {\n if (prop in targetInstance) {\n Reflect.set(targetInstance, prop, value, receiver);\n }\n\n browserObject[prop] = value;\n\n return true;\n },\n };\n }\n\n function isConstructable(proxyTo: BrowserAPI | Class<BrowserAPI>): proxyTo is Class<BrowserAPI> {\n return typeof proxyTo === 'function';\n }\n\n // We have to untype the Service, because...\n // this is nuts:\n // https://github.com/DefinitelyTyped/DefinitelyTyped/blob/da0e5b5/types/ember__object/core.d.ts#L82-L94\n //\n // it's also all private, and the ember-TS team apparently didn't think people would want to do this :D\n class ProxyCreator extends UnTypedService {\n // https://github.com/emberjs/ember.js/blob/master/packages/%40ember/service/index.js#L66-L74\n // https://github.com/emberjs/ember.js/blob/f85cefe9855b2521b02800d4bb2b68da7db2a214/packages/%40ember/service/index.js#L68-L72\n static isServiceFactory = true;\n\n static create(injections: Parameters<CreateMethod>): ReturnType<CreateMethod> {\n let serviceInstance = class ProxiedService extends Service {\n // @private\n declare __browser_object__: BrowserAPI;\n /*\n * We cannot create the base Service, we must use a new one.\n * If we don't, we are unable to run tests in a legacy qunit environment\n * due to \"writableChains\" issues.\n *\n * https://github.com/emberjs/ember.js/pull/15347/files#diff-7e13eecefe753df1d82ce67b32bc4366R361\n *\n * */\n }.create(injections);\n\n let browserObject = isConstructable(ObjectToProxy) ? new ObjectToProxy() : ObjectToProxy;\n\n serviceInstance.__browser_object__ = browserObject;\n\n return new Proxy(serviceInstance, instanceHandlerFor(browserObject));\n }\n\n constructor(...args: unknown[]) {\n super(...args);\n throw new Error('ProxyCreator is not new-able');\n }\n }\n\n return ProxyCreator as unknown as typeof Service & BrowserAPI;\n}\n"],"names":["proxyService","ObjectToProxy","UnTypedService","Service","instanceHandlerFor","browserObject","get","targetInstance","prop","receiver","Reflect","value","bind","set","isConstructable","proxyTo","ProxyCreator","isServiceFactory","create","injections","serviceInstance","ProxiedService","__browser_object__","Proxy","constructor","args","Error"],"mappings":";;AAIA;;;;;;;;;;;;;;AAaM,SAAUA,YAAV,CACJC,aADI,EACyC;AAK7C;AACA;EACA,IAAIC,cAAc,GAAGC,OAArB,CAAA;;EAEA,SAASC,kBAAT,CAA4BC,aAA5B,EAAqD;IACnD,OAAO;AACLC,MAAAA,GAAG,CAA2BC,cAA3B,EAAoDC,IAApD,EAA6DC,QAA7D,EAA8E;QAC/E,IAAID,IAAI,IAAID,cAAZ,EAA4B;UAC1B,OAAOG,OAAO,CAACJ,GAAR,CAAYC,cAAZ,EAA4BC,IAA5B,EAAkCC,QAAlC,CAAP,CAAA;AACD,SAAA;;AAED,QAAA,IAAIE,KAAK,GAAGN,aAAa,CAACG,IAAD,CAAzB,CAAA;;AAEA,QAAA,IAAI,OAAOG,KAAP,KAAiB,UAArB,EAAiC;AAC/B;AACA;AACA;AACA,UAAA,OAAOA,KAAK,CAACC,IAAN,CAAWP,aAAX,CAAP,CAAA;AACD,SAAA;;AAED,QAAA,OAAOM,KAAP,CAAA;OAfG;;MAiBLE,GAAG,CACDN,cADC,EAEDC,IAFC,EAGDG,KAHC,EAIDF,QAJC,EAIgB;QAEjB,IAAID,IAAI,IAAID,cAAZ,EAA4B;UAC1BG,OAAO,CAACG,GAAR,CAAYN,cAAZ,EAA4BC,IAA5B,EAAkCG,KAAlC,EAAyCF,QAAzC,CAAA,CAAA;AACD,SAAA;;AAEDJ,QAAAA,aAAa,CAACG,IAAD,CAAb,GAAsBG,KAAtB,CAAA;AAEA,QAAA,OAAO,IAAP,CAAA;AACD,OAAA;;KA9BH,CAAA;AAgCD,GAAA;;EAED,SAASG,eAAT,CAAyBC,OAAzB,EAAgE;IAC9D,OAAO,OAAOA,OAAP,KAAmB,UAA1B,CAAA;AACD,GA9C4C;AAiD7C;AACA;AACA;AACA;;;EACA,MAAMC,YAAN,SAA2Bd,cAA3B,CAAyC;AACvC;AACA;IACuB,OAAhBe,gBAAgB,GAAG,IAAH,CAAA;;IAEV,OAANC,MAAM,CAACC,UAAD,EAAqC;AAChD,MAAA,IAAIC,eAAe,GAAG,MAAMC,cAAN,SAA6BlB,OAA7B,CAAoC,EAApC,CAWpBe,MAXoB,CAWbC,UAXa,CAAtB,CAAA;MAaA,IAAId,aAAa,GAAGS,eAAe,CAACb,aAAD,CAAf,GAAiC,IAAIA,aAAJ,EAAjC,GAAuDA,aAA3E,CAAA;MAEAmB,eAAe,CAACE,kBAAhB,GAAqCjB,aAArC,CAAA;MAEA,OAAO,IAAIkB,KAAJ,CAAUH,eAAV,EAA2BhB,kBAAkB,CAACC,aAAD,CAA7C,CAAP,CAAA;AACD,KAAA;;IAEDmB,WAAY,CAAA,GAAGC,IAAf,EAA8B;AAC5B,MAAA,KAAA,CAAM,GAAGA,IAAT,CAAA,CAAA;AACA,MAAA,MAAM,IAAIC,KAAJ,CAAU,8BAAV,CAAN,CAAA;AACD,KAAA;;AA7BsC,GAAA;;AAgCzC,EAAA,OAAOV,YAAP,CAAA;AACD;;;;"}
@@ -0,0 +1,7 @@
1
+ declare const DocumentProxyService: typeof import("@ember/service").default & Document;
2
+ declare module '@ember/service' {
3
+ interface Registry {
4
+ 'browser/document': typeof DocumentProxyService;
5
+ }
6
+ }
7
+ export { DocumentProxyService as default };
@@ -0,0 +1,7 @@
1
+ import '@ember/service';
2
+ import { proxyService } from './-proxy-service.js';
3
+
4
+ const DocumentProxyService = proxyService(document);
5
+
6
+ export { DocumentProxyService as default };
7
+ //# sourceMappingURL=document.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document.js","sources":["../../../src/services/browser/document.ts"],"sourcesContent":["import '@ember/service';\n\nimport { proxyService } from './-proxy-service';\n\nconst DocumentProxyService = proxyService(document);\n\n/**\n * In order to have thorough testing, we should only interact with the document\n * (and other browser APIs) via a service.\n *\n * We can control, mock, and override the services, but we can't do so with\n * the browser APIs.\n *\n */\nexport default DocumentProxyService;\n\ndeclare module '@ember/service' {\n interface Registry {\n 'browser/document': typeof DocumentProxyService;\n }\n}\n"],"names":["DocumentProxyService","proxyService","document"],"mappings":";;;AAIA,MAAMA,oBAAoB,GAAGC,YAAY,CAACC,QAAD;;;;"}
@@ -1,4 +1,3 @@
1
- import '@ember/service';
2
1
  /**
3
2
  * In order to have thorough testing, we should only interact with the local storage
4
3
  * (and other browser APIs) via a service.
@@ -8,9 +7,9 @@ import '@ember/service';
8
7
  *
9
8
  */
10
9
  declare const LocalStorageProxyService: typeof import("@ember/service").default & Storage;
11
- export default LocalStorageProxyService;
12
10
  declare module '@ember/service' {
13
11
  interface Registry {
14
12
  'browser/local-storage': typeof LocalStorageProxyService;
15
13
  }
16
14
  }
15
+ export { LocalStorageProxyService as default };
@@ -1,6 +1,5 @@
1
1
  import '@ember/service';
2
-
3
- import { proxyService } from 'ember-browser-services/utils/proxy-service';
2
+ import { proxyService } from './-proxy-service.js';
4
3
 
5
4
  /**
6
5
  * In order to have thorough testing, we should only interact with the local storage
@@ -10,12 +9,8 @@ import { proxyService } from 'ember-browser-services/utils/proxy-service';
10
9
  * the browser APIs.
11
10
  *
12
11
  */
13
- const LocalStorageProxyService = proxyService(localStorage);
14
12
 
15
- export default LocalStorageProxyService;
13
+ const LocalStorageProxyService = proxyService(localStorage);
16
14
 
17
- declare module '@ember/service' {
18
- interface Registry {
19
- 'browser/local-storage': typeof LocalStorageProxyService;
20
- }
21
- }
15
+ export { LocalStorageProxyService as default };
16
+ //# sourceMappingURL=local-storage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"local-storage.js","sources":["../../../src/services/browser/local-storage.ts"],"sourcesContent":["import '@ember/service';\n\nimport { proxyService } from './-proxy-service';\n\n/**\n * In order to have thorough testing, we should only interact with the local storage\n * (and other browser APIs) via a service.\n *\n * We can control, mock, and override the services, but we can't do so with\n * the browser APIs.\n *\n */\nconst LocalStorageProxyService = proxyService(localStorage);\n\nexport default LocalStorageProxyService;\n\ndeclare module '@ember/service' {\n interface Registry {\n 'browser/local-storage': typeof LocalStorageProxyService;\n }\n}\n"],"names":["LocalStorageProxyService","proxyService","localStorage"],"mappings":";;;AAIA;;;;;;;;;AAQA,MAAMA,wBAAwB,GAAGC,YAAY,CAACC,YAAD;;;;"}
@@ -0,0 +1,7 @@
1
+ declare const NavigatorProxyService: typeof import("@ember/service").default & Navigator;
2
+ declare module '@ember/service' {
3
+ interface Registry {
4
+ 'browser/navigator': typeof NavigatorProxyService;
5
+ }
6
+ }
7
+ export { NavigatorProxyService as default };
@@ -0,0 +1,7 @@
1
+ import '@ember/service';
2
+ import { proxyService } from './-proxy-service.js';
3
+
4
+ const NavigatorProxyService = proxyService(navigator);
5
+
6
+ export { NavigatorProxyService as default };
7
+ //# sourceMappingURL=navigator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigator.js","sources":["../../../src/services/browser/navigator.ts"],"sourcesContent":["import '@ember/service';\n\nimport { proxyService } from './-proxy-service';\n\nconst NavigatorProxyService = proxyService(navigator);\n\n/**\n * In order to have thorough testing, we should only interact with the navigator\n * (and other browser APIs) via a service.\n *\n * We can control, mock, and override the services, but we can't do so with\n * the browser APIs.\n *\n */\nexport default NavigatorProxyService;\n\ndeclare module '@ember/service' {\n interface Registry {\n 'browser/navigator': typeof NavigatorProxyService;\n }\n}\n"],"names":["NavigatorProxyService","proxyService","navigator"],"mappings":";;;AAIA,MAAMA,qBAAqB,GAAGC,YAAY,CAACC,SAAD;;;;"}
@@ -1,4 +1,3 @@
1
- import '@ember/service';
2
1
  /**
3
2
  * In order to have thorough testing, we should only interact with the session storage
4
3
  * (and other browser APIs) via a service.
@@ -8,9 +7,9 @@ import '@ember/service';
8
7
  *
9
8
  */
10
9
  declare const SessionStorageProxyService: typeof import("@ember/service").default & Storage;
11
- export default SessionStorageProxyService;
12
10
  declare module '@ember/service' {
13
11
  interface Registry {
14
12
  'browser/session-storage': typeof SessionStorageProxyService;
15
13
  }
16
14
  }
15
+ export { SessionStorageProxyService as default };
@@ -1,6 +1,5 @@
1
1
  import '@ember/service';
2
-
3
- import { proxyService } from 'ember-browser-services/utils/proxy-service';
2
+ import { proxyService } from './-proxy-service.js';
4
3
 
5
4
  /**
6
5
  * In order to have thorough testing, we should only interact with the session storage
@@ -10,12 +9,8 @@ import { proxyService } from 'ember-browser-services/utils/proxy-service';
10
9
  * the browser APIs.
11
10
  *
12
11
  */
13
- const SessionStorageProxyService = proxyService(sessionStorage);
14
12
 
15
- export default SessionStorageProxyService;
13
+ const SessionStorageProxyService = proxyService(sessionStorage);
16
14
 
17
- declare module '@ember/service' {
18
- interface Registry {
19
- 'browser/session-storage': typeof SessionStorageProxyService;
20
- }
21
- }
15
+ export { SessionStorageProxyService as default };
16
+ //# sourceMappingURL=session-storage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-storage.js","sources":["../../../src/services/browser/session-storage.ts"],"sourcesContent":["import '@ember/service';\n\nimport { proxyService } from './-proxy-service';\n\n/**\n * In order to have thorough testing, we should only interact with the session storage\n * (and other browser APIs) via a service.\n *\n * We can control, mock, and override the services, but we can't do so with\n * the browser APIs.\n *\n */\nconst SessionStorageProxyService = proxyService(sessionStorage);\n\nexport default SessionStorageProxyService;\n\ndeclare module '@ember/service' {\n interface Registry {\n 'browser/session-storage': typeof SessionStorageProxyService;\n }\n}\n"],"names":["SessionStorageProxyService","proxyService","sessionStorage"],"mappings":";;;AAIA;;;;;;;;;AAQA,MAAMA,0BAA0B,GAAGC,YAAY,CAACC,cAAD;;;;"}
@@ -1,4 +1,3 @@
1
- import '@ember/service';
2
1
  /**
3
2
  * In order to have thorough testing, we should only interact with the window
4
3
  * (and other browser APIs) via a service.
@@ -8,7 +7,6 @@ import '@ember/service';
8
7
  *
9
8
  */
10
9
  declare const WindowProxyService: typeof import("@ember/service").default & Window & typeof globalThis;
11
- export default WindowProxyService;
12
10
  declare global {
13
11
  interface Window {
14
12
  requirejs: (path: string) => {
@@ -21,3 +19,4 @@ declare module '@ember/service' {
21
19
  'browser/window': typeof WindowProxyService;
22
20
  }
23
21
  }
22
+ export { WindowProxyService as default };
@@ -0,0 +1,16 @@
1
+ import '@ember/service';
2
+ import { proxyService } from './-proxy-service.js';
3
+
4
+ /**
5
+ * In order to have thorough testing, we should only interact with the window
6
+ * (and other browser APIs) via a service.
7
+ *
8
+ * We can control, mock, and override the services, but we can't do so with
9
+ * the browser APIs.
10
+ *
11
+ */
12
+
13
+ const WindowProxyService = proxyService(window);
14
+
15
+ export { WindowProxyService as default };
16
+ //# sourceMappingURL=window.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"window.js","sources":["../../../src/services/browser/window.ts"],"sourcesContent":["import '@ember/service';\n\nimport { proxyService } from './-proxy-service';\n\n/**\n * In order to have thorough testing, we should only interact with the window\n * (and other browser APIs) via a service.\n *\n * We can control, mock, and override the services, but we can't do so with\n * the browser APIs.\n *\n */\nconst WindowProxyService = proxyService(window);\n\nexport default WindowProxyService;\n\ndeclare global {\n interface Window {\n requirejs: (path: string) => { default: never };\n }\n}\n\ndeclare module '@ember/service' {\n interface Registry {\n 'browser/window': typeof WindowProxyService;\n }\n}\n"],"names":["WindowProxyService","proxyService","window"],"mappings":";;;AAIA;;;;;;;;;AAQA,MAAMA,kBAAkB,GAAGC,YAAY,CAACC,MAAD;;;;"}