ember-browser-services 3.0.3 → 4.0.0
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/CHANGELOG.md +3 -200
- package/README.md +6 -2
- package/addon-main.cjs +6 -0
- package/dist/_app_/services/browser/-proxy-service.js +1 -0
- package/dist/_app_/services/browser/document.js +1 -0
- package/dist/_app_/services/browser/local-storage.js +1 -0
- package/dist/_app_/services/browser/navigator.js +1 -0
- package/dist/_app_/services/browser/session-storage.js +1 -0
- package/dist/_app_/services/browser/window.js +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/{declarations/utils/proxy-service.d.ts → dist/services/browser/-proxy-service.d.ts} +3 -2
- package/{addon/utils/proxy-service.ts → dist/services/browser/-proxy-service.js} +20 -40
- package/dist/services/browser/-proxy-service.js.map +1 -0
- package/dist/services/browser/document.d.ts +7 -0
- package/dist/services/browser/document.js +7 -0
- package/dist/services/browser/document.js.map +1 -0
- package/{declarations → dist}/services/browser/local-storage.d.ts +1 -2
- package/{addon/services/browser/local-storage.ts → dist/services/browser/local-storage.js} +4 -9
- package/dist/services/browser/local-storage.js.map +1 -0
- package/dist/services/browser/navigator.d.ts +7 -0
- package/dist/services/browser/navigator.js +7 -0
- package/dist/services/browser/navigator.js.map +1 -0
- package/{declarations → dist}/services/browser/session-storage.d.ts +1 -2
- package/{addon/services/browser/session-storage.ts → dist/services/browser/session-storage.js} +4 -9
- package/dist/services/browser/session-storage.js.map +1 -0
- package/{declarations → dist}/services/browser/window.d.ts +1 -2
- package/dist/services/browser/window.js +16 -0
- package/dist/services/browser/window.js.map +1 -0
- package/{declarations → dist}/test-support/-private/web-storage.d.ts +4 -4
- package/{addon-test-support/-private/web-storage.ts → dist/test-support/-private/web-storage.js} +12 -9
- package/dist/test-support/-private/web-storage.js.map +1 -0
- package/dist/test-support/index.d.ts +13 -0
- package/{addon-test-support/index.ts → dist/test-support/index.js} +20 -40
- package/dist/test-support/index.js.map +1 -0
- package/dist/test-support/window-mock-augments.d.ts +2 -0
- package/{addon-test-support/window-mock-augments.ts → dist/test-support/window-mock-augments.js} +14 -15
- package/dist/test-support/window-mock-augments.js.map +1 -0
- package/dist/types.d.ts +17 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +90 -132
- package/.remarkignore +0 -7
- package/LICENSE.md +0 -9
- package/addon/services/browser/document.ts +0 -21
- package/addon/services/browser/navigator.ts +0 -21
- package/addon/services/browser/window.ts +0 -27
- package/addon/tsconfig.json +0 -11
- package/addon/tsconfig.tsbuildinfo +0 -1
- package/addon/types.ts +0 -25
- package/addon-test-support/tsconfig.json +0 -16
- package/addon-test-support/tsconfig.tsbuildinfo +0 -1
- package/app/services/browser/document.js +0 -1
- package/app/services/browser/local-storage.js +0 -1
- package/app/services/browser/navigator.js +0 -1
- package/app/services/browser/session-storage.js +0 -1
- package/app/services/browser/window.js +0 -1
- package/commitlint.config.js +0 -3
- package/config/build/tsconfig.compiler-options.ember.json +0 -14
- package/config/build/tsconfig.compiler-options.json +0 -54
- package/config/environment.js +0 -5
- package/declarations/services/browser/document.d.ts +0 -16
- package/declarations/services/browser/navigator.d.ts +0 -16
- package/declarations/test-support/index.d.ts +0 -15
- package/declarations/test-support/window-mock-augments.d.ts +0 -1
- package/declarations/types.d.ts +0 -16
- package/index.js +0 -14
- package/tsconfig.compiler-options.json +0 -6
- package/tsconfig.json +0 -12
- package/types/dummy/index.d.ts +0 -1
- package/types/global.d.ts +0 -6
package/{addon-test-support/-private/web-storage.ts → dist/test-support/-private/web-storage.js}
RENAMED
@@ -1,31 +1,34 @@
|
|
1
1
|
import Service from '@ember/service';
|
2
2
|
|
3
|
-
type FakeWebStorage = Record<string, string>;
|
4
|
-
|
5
3
|
/**
|
6
4
|
* Mimics the Web Storage API, as used by localStorage and sessionStorage.
|
7
5
|
*
|
8
6
|
*/
|
7
|
+
|
9
8
|
class FakeWebStorageService extends Service {
|
10
|
-
fakeWebStorage
|
9
|
+
fakeWebStorage = {};
|
11
10
|
|
12
|
-
setItem(key
|
11
|
+
setItem(key, value) {
|
13
12
|
// Everything in Web Storage is a string
|
14
13
|
this.fakeWebStorage[key] = `${value}`;
|
15
14
|
}
|
16
15
|
|
17
|
-
getItem(key
|
16
|
+
getItem(key) {
|
18
17
|
return this.fakeWebStorage[key] || null;
|
19
18
|
}
|
20
19
|
|
21
|
-
removeItem(key
|
20
|
+
removeItem(key) {
|
22
21
|
delete this.fakeWebStorage[key];
|
23
22
|
}
|
24
23
|
|
25
|
-
clear()
|
24
|
+
clear() {
|
26
25
|
this.fakeWebStorage = {};
|
27
26
|
}
|
27
|
+
|
28
28
|
}
|
29
29
|
|
30
|
-
|
31
|
-
|
30
|
+
class FakeLocalStorageService extends FakeWebStorageService {}
|
31
|
+
class FakeSessionStorageService extends FakeWebStorageService {}
|
32
|
+
|
33
|
+
export { FakeLocalStorageService, FakeSessionStorageService };
|
34
|
+
//# sourceMappingURL=web-storage.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"web-storage.js","sources":["../../../src/test-support/-private/web-storage.ts"],"sourcesContent":["import Service from '@ember/service';\n\ntype FakeWebStorage = Record<string, string>;\n\n/**\n * Mimics the Web Storage API, as used by localStorage and sessionStorage.\n *\n */\nclass FakeWebStorageService extends Service {\n fakeWebStorage: FakeWebStorage = {};\n\n setItem(key: string, value: string): void {\n // Everything in Web Storage is a string\n this.fakeWebStorage[key] = `${value}`;\n }\n\n getItem(key: string): string | null {\n return this.fakeWebStorage[key] || null;\n }\n\n removeItem(key: string): void {\n delete this.fakeWebStorage[key];\n }\n\n clear(): void {\n this.fakeWebStorage = {};\n }\n}\n\nexport class FakeLocalStorageService extends FakeWebStorageService {}\nexport class FakeSessionStorageService extends FakeWebStorageService {}\n"],"names":["FakeWebStorageService","Service","fakeWebStorage","setItem","key","value","getItem","removeItem","clear","FakeLocalStorageService","FakeSessionStorageService"],"mappings":";;AAIA;;;;;AAIA,MAAMA,qBAAN,SAAoCC,OAApC,CAA2C;AACzCC,EAAAA,cAAc,GAAmB,EAAnB,CAAA;;AAEdC,EAAAA,OAAO,CAACC,GAAD,EAAcC,KAAd,EAA2B;AAChC;AACA,IAAA,IAAA,CAAKH,cAAL,CAAoBE,GAApB,CAA2B,GAAA,CAAA,EAAGC,KAAK,CAAnC,CAAA,CAAA;AACD,GAAA;;EAEDC,OAAO,CAACF,GAAD,EAAY;AACjB,IAAA,OAAO,IAAKF,CAAAA,cAAL,CAAoBE,GAApB,KAA4B,IAAnC,CAAA;AACD,GAAA;;EAEDG,UAAU,CAACH,GAAD,EAAY;AACpB,IAAA,OAAO,IAAKF,CAAAA,cAAL,CAAoBE,GAApB,CAAP,CAAA;AACD,GAAA;;EAEDI,KAAK,GAAA;IACH,IAAKN,CAAAA,cAAL,GAAsB,EAAtB,CAAA;AACD,GAAA;;AAlBwC,CAAA;;AAqBrC,MAAOO,uBAAP,SAAuCT,qBAAvC,CAA4D,EAAA;AAC5D,MAAOU,yBAAP,SAAyCV,qBAAzC,CAA8D;;;;"}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import Service from '@ember/service';
|
2
|
+
import { RecursivePartial } from "../types";
|
3
|
+
type Fakes = {
|
4
|
+
window?: boolean | typeof Service | RecursivePartial<Window>;
|
5
|
+
localStorage?: boolean;
|
6
|
+
sessionStorage?: boolean;
|
7
|
+
document?: boolean | typeof Service | RecursivePartial<Document>;
|
8
|
+
navigator?: boolean | RecursivePartial<Navigator>;
|
9
|
+
};
|
10
|
+
declare function setupBrowserFakes(hooks: NestedHooks, options: Fakes): void;
|
11
|
+
type UnknownObject = Record<string, any>;
|
12
|
+
declare function maybeMake<DefaultType extends UnknownObject, TestClass extends UnknownObject>(maybeImplementation: true | typeof Service | TestClass | RecursivePartial<DefaultType>, target: DefaultType): DefaultType;
|
13
|
+
export { setupBrowserFakes, maybeMake };
|
@@ -1,66 +1,45 @@
|
|
1
1
|
import Service from '@ember/service';
|
2
|
-
|
3
|
-
import { proxyService } from 'ember-browser-services/utils/proxy-service';
|
4
2
|
import window from 'ember-window-mock';
|
5
3
|
import { setupWindowMock } from 'ember-window-mock/test-support';
|
4
|
+
import { proxyService } from '../services/browser/-proxy-service.js';
|
5
|
+
import { FakeLocalStorageService, FakeSessionStorageService } from './-private/web-storage.js';
|
6
|
+
import { patchWindow } from './window-mock-augments.js';
|
7
|
+
import 'ember-window-mock/test-support/-private/mock/location';
|
6
8
|
|
7
|
-
|
8
|
-
import { patchWindow } from './window-mock-augments';
|
9
|
-
|
10
|
-
import type { RecursivePartial } from 'ember-browser-services/types';
|
11
|
-
import type { TestContext } from 'ember-test-helpers';
|
12
|
-
|
13
|
-
type Fakes = {
|
14
|
-
window?: boolean | typeof Service | RecursivePartial<Window>;
|
15
|
-
localStorage?: boolean;
|
16
|
-
sessionStorage?: boolean;
|
17
|
-
document?: boolean | typeof Service | RecursivePartial<Document>;
|
18
|
-
navigator?: boolean | RecursivePartial<Navigator>;
|
19
|
-
};
|
20
|
-
|
21
|
-
export function setupBrowserFakes(hooks: NestedHooks, options: Fakes): void {
|
9
|
+
function setupBrowserFakes(hooks, options) {
|
22
10
|
setupWindowMock(hooks);
|
11
|
+
hooks.beforeEach(function () {
|
12
|
+
// the type for the owner keeps being wrong............
|
13
|
+
let owner = this.owner;
|
23
14
|
|
24
|
-
hooks.beforeEach(function (this: TestContext) {
|
25
15
|
if (options.window) {
|
26
16
|
// default, can still be overwritten
|
27
17
|
// see: https://github.com/kaliber5/ember-window-mock/issues/175
|
28
18
|
let patched = patchWindow(window);
|
29
19
|
let service = maybeMake(options.window, patched);
|
30
|
-
|
31
|
-
this.owner.register('service:browser/window', service);
|
20
|
+
owner.register('service:browser/window', service);
|
32
21
|
}
|
33
22
|
|
34
23
|
if (options.document) {
|
35
24
|
let service = maybeMake(options.document, window.document);
|
36
|
-
|
37
|
-
this.owner.register('service:browser/document', service);
|
25
|
+
owner.register('service:browser/document', service);
|
38
26
|
}
|
39
27
|
|
40
28
|
if (options.localStorage) {
|
41
|
-
|
29
|
+
owner.register('service:browser/local-storage', FakeLocalStorageService);
|
42
30
|
}
|
43
31
|
|
44
32
|
if (options.sessionStorage) {
|
45
|
-
|
33
|
+
owner.register('service:browser/session-storage', FakeSessionStorageService);
|
46
34
|
}
|
47
35
|
|
48
36
|
if (options.navigator) {
|
49
37
|
let service = maybeMake(options.navigator, window.navigator);
|
50
|
-
|
51
|
-
this.owner.register('service:browser/navigator', service);
|
38
|
+
owner.register('service:browser/navigator', service);
|
52
39
|
}
|
53
40
|
});
|
54
41
|
}
|
55
|
-
|
56
|
-
// this usage of any is correct, because it literally could be *any*thing
|
57
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
58
|
-
type UnknownObject = Record<string, any>;
|
59
|
-
|
60
|
-
export function maybeMake<DefaultType extends UnknownObject, TestClass extends UnknownObject>(
|
61
|
-
maybeImplementation: true | typeof Service | TestClass | RecursivePartial<DefaultType>,
|
62
|
-
target: DefaultType
|
63
|
-
): DefaultType {
|
42
|
+
function maybeMake(maybeImplementation, target) {
|
64
43
|
if (maybeImplementation === true) {
|
65
44
|
return proxyService(target);
|
66
45
|
}
|
@@ -71,21 +50,19 @@ export function maybeMake<DefaultType extends UnknownObject, TestClass extends U
|
|
71
50
|
|
72
51
|
if (typeof maybeImplementation === 'object') {
|
73
52
|
applyStub(target, maybeImplementation);
|
74
|
-
|
75
53
|
return proxyService(target);
|
76
54
|
}
|
77
55
|
|
78
56
|
return proxyService(target);
|
79
|
-
}
|
80
|
-
|
81
|
-
// we are already using ember-window-mock, so the proxy internal to that package will
|
57
|
+
} // we are already using ember-window-mock, so the proxy internal to that package will
|
82
58
|
// "just handle" setting stuff on the window
|
83
59
|
//
|
84
60
|
// NOTE:
|
85
61
|
// - Location implementation is incomplete:
|
86
62
|
// https://github.com/kaliber5/ember-window-mock/blob/2b8fbf581fc65e7f5455cd291497a3fdc2efdaf5/addon-test-support/-private/mock/location.js#L23
|
87
63
|
// - does not allow setting "origin"
|
88
|
-
|
64
|
+
|
65
|
+
function applyStub(root, partial) {
|
89
66
|
if (!partial) return root;
|
90
67
|
|
91
68
|
for (let key of Object.keys(partial)) {
|
@@ -100,3 +77,6 @@ function applyStub(root: any, partial?: any) {
|
|
100
77
|
}
|
101
78
|
}
|
102
79
|
}
|
80
|
+
|
81
|
+
export { maybeMake, setupBrowserFakes };
|
82
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/test-support/index.ts"],"sourcesContent":["import Service from '@ember/service';\n\nimport window from 'ember-window-mock';\nimport { setupWindowMock } from 'ember-window-mock/test-support';\n\nimport { proxyService } from '../services/browser/-proxy-service';\nimport { FakeLocalStorageService, FakeSessionStorageService } from './-private/web-storage';\nimport { patchWindow } from './window-mock-augments';\n\nimport type { RecursivePartial } from '../types';\nimport type { TestContext } from '@ember/test-helpers';\n\ntype Fakes = {\n window?: boolean | typeof Service | RecursivePartial<Window>;\n localStorage?: boolean;\n sessionStorage?: boolean;\n document?: boolean | typeof Service | RecursivePartial<Document>;\n navigator?: boolean | RecursivePartial<Navigator>;\n};\n\nexport function setupBrowserFakes(hooks: NestedHooks, options: Fakes): void {\n setupWindowMock(hooks);\n\n hooks.beforeEach(function (this: TestContext) {\n // the type for the owner keeps being wrong............\n let owner = this.owner as unknown as {\n register: (name: string, thing: unknown) => void;\n unregister: (name: string) => void;\n };\n\n if (options.window) {\n // default, can still be overwritten\n // see: https://github.com/kaliber5/ember-window-mock/issues/175\n let patched = patchWindow(window);\n let service = maybeMake(options.window, patched);\n\n owner.register('service:browser/window', service);\n }\n\n if (options.document) {\n let service = maybeMake(options.document, window.document);\n\n owner.register('service:browser/document', service);\n }\n\n if (options.localStorage) {\n owner.register('service:browser/local-storage', FakeLocalStorageService);\n }\n\n if (options.sessionStorage) {\n owner.register('service:browser/session-storage', FakeSessionStorageService);\n }\n\n if (options.navigator) {\n let service = maybeMake(options.navigator, window.navigator);\n\n owner.register('service:browser/navigator', service);\n }\n });\n}\n\n// this usage of any is correct, because it literally could be *any*thing\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype UnknownObject = Record<string, any>;\n\nexport function maybeMake<DefaultType extends UnknownObject, TestClass extends UnknownObject>(\n maybeImplementation: true | typeof Service | TestClass | RecursivePartial<DefaultType>,\n target: DefaultType\n): DefaultType {\n if (maybeImplementation === true) {\n return proxyService(target);\n }\n\n if (maybeImplementation.prototype instanceof Service) {\n return target;\n }\n\n if (typeof maybeImplementation === 'object') {\n applyStub(target, maybeImplementation);\n\n return proxyService(target);\n }\n\n return proxyService(target);\n}\n\n// we are already using ember-window-mock, so the proxy internal to that package will\n// \"just handle\" setting stuff on the window\n//\n// NOTE:\n// - Location implementation is incomplete:\n// https://github.com/kaliber5/ember-window-mock/blob/2b8fbf581fc65e7f5455cd291497a3fdc2efdaf5/addon-test-support/-private/mock/location.js#L23\n// - does not allow setting \"origin\"\nfunction applyStub(root: any, partial?: any) {\n if (!partial) return root;\n\n for (let key of Object.keys(partial)) {\n let value = partial[key];\n\n if (Array.isArray(value)) {\n root[key] = value;\n } else if (typeof value === 'object') {\n applyStub(root[key], value);\n } else {\n root[key] = value;\n }\n }\n}\n"],"names":["setupBrowserFakes","hooks","options","setupWindowMock","beforeEach","owner","window","patched","patchWindow","service","maybeMake","register","document","localStorage","FakeLocalStorageService","sessionStorage","FakeSessionStorageService","navigator","maybeImplementation","target","proxyService","prototype","Service","applyStub","root","partial","key","Object","keys","value","Array","isArray"],"mappings":"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"}
|
package/{addon-test-support/window-mock-augments.ts → dist/test-support/window-mock-augments.js}
RENAMED
@@ -1,17 +1,13 @@
|
|
1
1
|
import window from 'ember-window-mock';
|
2
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
3
|
-
// @ts-expect-error
|
4
2
|
import locationFactory from 'ember-window-mock/test-support/-private/mock/location';
|
5
3
|
|
6
|
-
const AUGMENTS
|
4
|
+
const AUGMENTS = ['origin'];
|
7
5
|
|
8
|
-
function createLocation(target
|
6
|
+
function createLocation(target) {
|
9
7
|
let initialHref = target?.location?.href ?? window.location.href;
|
10
8
|
let mockLocation = locationFactory(initialHref);
|
11
|
-
let values
|
12
|
-
|
9
|
+
let values = {};
|
13
10
|
mockLocation.isPatchedLocation = true;
|
14
|
-
|
15
11
|
return new Proxy(mockLocation, {
|
16
12
|
get(target, key, receiver) {
|
17
13
|
if (AUGMENTS.includes(key)) {
|
@@ -23,33 +19,36 @@ function createLocation(target?: Window) {
|
|
23
19
|
|
24
20
|
set(target, key, value, receiver) {
|
25
21
|
if (AUGMENTS.includes(key)) {
|
26
|
-
return
|
22
|
+
return values[key] = value;
|
27
23
|
}
|
28
24
|
|
29
25
|
return Reflect.set(target, key, value, receiver);
|
30
|
-
}
|
26
|
+
}
|
27
|
+
|
31
28
|
});
|
32
29
|
}
|
33
30
|
|
34
|
-
|
31
|
+
function patchWindow(target) {
|
35
32
|
let location = createLocation(target);
|
36
|
-
|
37
|
-
let self: any = new Proxy(target, {
|
33
|
+
let self = new Proxy(target, {
|
38
34
|
get(target, key, receiver) {
|
39
35
|
if (key === 'location') return location;
|
40
36
|
if (key === 'parent') return self;
|
41
37
|
if (key === 'top') return self;
|
42
|
-
|
43
38
|
return Reflect.get(target, key, receiver);
|
44
39
|
},
|
40
|
+
|
45
41
|
set(target, key, value, receiver) {
|
46
42
|
if (key === 'location') {
|
47
43
|
throw new Error(`location cannot be set on window`);
|
48
44
|
}
|
49
45
|
|
50
46
|
return Reflect.set(target, key, value, receiver);
|
51
|
-
}
|
52
|
-
});
|
47
|
+
}
|
53
48
|
|
49
|
+
});
|
54
50
|
return self;
|
55
51
|
}
|
52
|
+
|
53
|
+
export { patchWindow };
|
54
|
+
//# sourceMappingURL=window-mock-augments.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"window-mock-augments.js","sources":["../../src/test-support/window-mock-augments.ts"],"sourcesContent":["import window from 'ember-window-mock';\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-expect-error\nimport locationFactory from 'ember-window-mock/test-support/-private/mock/location';\n\nconst AUGMENTS: Array<string | symbol> = ['origin'];\n\nfunction createLocation(target?: Window) {\n let initialHref = target?.location?.href ?? window.location.href;\n let mockLocation = locationFactory(initialHref);\n let values: any = {};\n\n mockLocation.isPatchedLocation = true;\n\n return new Proxy(mockLocation, {\n get(target, key, receiver) {\n if (AUGMENTS.includes(key)) {\n return values[key] ?? Reflect.get(target, key, receiver);\n }\n\n return Reflect.get(target, key, receiver);\n },\n\n set(target, key, value, receiver) {\n if (AUGMENTS.includes(key)) {\n return (values[key] = value);\n }\n\n return Reflect.set(target, key, value, receiver);\n },\n });\n}\n\nexport function patchWindow(target: any) {\n let location = createLocation(target);\n\n let self: any = new Proxy(target, {\n get(target, key, receiver) {\n if (key === 'location') return location;\n if (key === 'parent') return self;\n if (key === 'top') return self;\n\n return Reflect.get(target, key, receiver);\n },\n set(target, key, value, receiver) {\n if (key === 'location') {\n throw new Error(`location cannot be set on window`);\n }\n\n return Reflect.set(target, key, value, receiver);\n },\n });\n\n return self;\n}\n"],"names":["AUGMENTS","createLocation","target","initialHref","location","href","window","mockLocation","locationFactory","values","isPatchedLocation","Proxy","get","key","receiver","includes","Reflect","set","value","patchWindow","self","Error"],"mappings":";;;AAKA,MAAMA,QAAQ,GAA2B,CAAC,QAAD,CAAzC,CAAA;;AAEA,SAASC,cAAT,CAAwBC,MAAxB,EAAuC;AACrC,EAAA,IAAIC,WAAW,GAAGD,MAAM,EAAEE,QAAR,EAAkBC,IAAlB,IAA0BC,MAAM,CAACF,QAAP,CAAgBC,IAA5D,CAAA;AACA,EAAA,IAAIE,YAAY,GAAGC,eAAe,CAACL,WAAD,CAAlC,CAAA;EACA,IAAIM,MAAM,GAAQ,EAAlB,CAAA;EAEAF,YAAY,CAACG,iBAAb,GAAiC,IAAjC,CAAA;AAEA,EAAA,OAAO,IAAIC,KAAJ,CAAUJ,YAAV,EAAwB;AAC7BK,IAAAA,GAAG,CAACV,MAAD,EAASW,GAAT,EAAcC,QAAd,EAAsB;AACvB,MAAA,IAAId,QAAQ,CAACe,QAAT,CAAkBF,GAAlB,CAAJ,EAA4B;AAC1B,QAAA,OAAOJ,MAAM,CAACI,GAAD,CAAN,IAAeG,OAAO,CAACJ,GAAR,CAAYV,MAAZ,EAAoBW,GAApB,EAAyBC,QAAzB,CAAtB,CAAA;AACD,OAAA;;MAED,OAAOE,OAAO,CAACJ,GAAR,CAAYV,MAAZ,EAAoBW,GAApB,EAAyBC,QAAzB,CAAP,CAAA;KAN2B;;IAS7BG,GAAG,CAACf,MAAD,EAASW,GAAT,EAAcK,KAAd,EAAqBJ,QAArB,EAA6B;AAC9B,MAAA,IAAId,QAAQ,CAACe,QAAT,CAAkBF,GAAlB,CAAJ,EAA4B;AAC1B,QAAA,OAAQJ,MAAM,CAACI,GAAD,CAAN,GAAcK,KAAtB,CAAA;AACD,OAAA;;MAED,OAAOF,OAAO,CAACC,GAAR,CAAYf,MAAZ,EAAoBW,GAApB,EAAyBK,KAAzB,EAAgCJ,QAAhC,CAAP,CAAA;AACD,KAAA;;AAf4B,GAAxB,CAAP,CAAA;AAiBD,CAAA;;AAEK,SAAUK,WAAV,CAAsBjB,MAAtB,EAAiC;AACrC,EAAA,IAAIE,QAAQ,GAAGH,cAAc,CAACC,MAAD,CAA7B,CAAA;AAEA,EAAA,IAAIkB,IAAI,GAAQ,IAAIT,KAAJ,CAAUT,MAAV,EAAkB;AAChCU,IAAAA,GAAG,CAACV,MAAD,EAASW,GAAT,EAAcC,QAAd,EAAsB;AACvB,MAAA,IAAID,GAAG,KAAK,UAAZ,EAAwB,OAAOT,QAAP,CAAA;AACxB,MAAA,IAAIS,GAAG,KAAK,QAAZ,EAAsB,OAAOO,IAAP,CAAA;AACtB,MAAA,IAAIP,GAAG,KAAK,KAAZ,EAAmB,OAAOO,IAAP,CAAA;MAEnB,OAAOJ,OAAO,CAACJ,GAAR,CAAYV,MAAZ,EAAoBW,GAApB,EAAyBC,QAAzB,CAAP,CAAA;KAN8B;;IAQhCG,GAAG,CAACf,MAAD,EAASW,GAAT,EAAcK,KAAd,EAAqBJ,QAArB,EAA6B;MAC9B,IAAID,GAAG,KAAK,UAAZ,EAAwB;AACtB,QAAA,MAAM,IAAIQ,KAAJ,CAAU,CAAA,gCAAA,CAAV,CAAN,CAAA;AACD,OAAA;;MAED,OAAOL,OAAO,CAACC,GAAR,CAAYf,MAAZ,EAAoBW,GAApB,EAAyBK,KAAzB,EAAgCJ,QAAhC,CAAP,CAAA;AACD,KAAA;;AAd+B,GAAlB,CAAhB,CAAA;AAiBA,EAAA,OAAOM,IAAP,CAAA;AACD;;;;"}
|
package/dist/types.d.ts
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
import { default as _DocumentService } from "./services/browser/document";
|
2
|
+
import { default as _LocalStorageService } from "./services/browser/local-storage";
|
3
|
+
import { default as _NavigatorService } from "./services/browser/navigator";
|
4
|
+
import { default as _SessionStorageService } from "./services/browser/session-storage";
|
5
|
+
import { default as _WindowService } from "./services/browser/window";
|
6
|
+
type WindowService = typeof _WindowService;
|
7
|
+
type DocumentService = typeof _DocumentService;
|
8
|
+
type LocalStorageService = typeof _LocalStorageService;
|
9
|
+
type SessionStorageService = typeof _SessionStorageService;
|
10
|
+
type NavigatorService = typeof _NavigatorService;
|
11
|
+
interface Class<T> {
|
12
|
+
new (...args: unknown[]): T;
|
13
|
+
}
|
14
|
+
type RecursivePartial<T> = {
|
15
|
+
[P in keyof T]?: T[P] extends (infer U)[] ? RecursivePartial<U>[] : T[P] extends object ? RecursivePartial<T[P]> : T[P];
|
16
|
+
};
|
17
|
+
export { WindowService, DocumentService, LocalStorageService, SessionStorageService, NavigatorService, Class, RecursivePartial };
|
package/dist/types.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"types.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/package.json
CHANGED
@@ -1,42 +1,106 @@
|
|
1
1
|
{
|
2
2
|
"name": "ember-browser-services",
|
3
|
-
"version": "
|
3
|
+
"version": "4.0.0",
|
4
4
|
"description": "Browser APIs as services for easier testing",
|
5
|
-
"keywords": [
|
6
|
-
"ember-addon",
|
7
|
-
"browser",
|
8
|
-
"ember",
|
9
|
-
"ember.js",
|
10
|
-
"services",
|
11
|
-
"window",
|
12
|
-
"testing"
|
13
|
-
],
|
14
5
|
"repository": "https://github.com/CrowdStrike/ember-browser-services",
|
15
6
|
"license": "MIT",
|
16
7
|
"author": "CrowdStrike UX Team",
|
17
|
-
"
|
18
|
-
"
|
19
|
-
|
8
|
+
"keywords": [
|
9
|
+
"ember-addon"
|
10
|
+
],
|
11
|
+
"exports": {
|
12
|
+
".": "./dist/index.js",
|
13
|
+
"./*": "./dist/*"
|
20
14
|
},
|
15
|
+
"typesVersions": {
|
16
|
+
">=4.0.0": {
|
17
|
+
"*": [
|
18
|
+
"dist/*"
|
19
|
+
]
|
20
|
+
}
|
21
|
+
},
|
22
|
+
"files": [
|
23
|
+
"dist",
|
24
|
+
"addon-main.cjs",
|
25
|
+
"CHANGELOG.md",
|
26
|
+
"README.md"
|
27
|
+
],
|
21
28
|
"scripts": {
|
22
|
-
"
|
23
|
-
"
|
24
|
-
"
|
25
|
-
"
|
26
|
-
"
|
27
|
-
"lint
|
28
|
-
"lint:
|
29
|
+
"start": "pnpm watch:js",
|
30
|
+
"build": "concurrently 'npm:build:*'",
|
31
|
+
"build:js": "rollup -c ./rollup.config.mjs",
|
32
|
+
"build:docs": "cp ../README.md ./README.md",
|
33
|
+
"watch:js": "rollup -c --watch --no-watch.clearScreen",
|
34
|
+
"lint": "concurrently 'npm:lint:js'",
|
35
|
+
"lint:fix": "concurrently 'npm:lint:js:fix'",
|
29
36
|
"lint:js": "eslint . --cache",
|
30
37
|
"lint:js:fix": "eslint . --fix",
|
31
|
-
"
|
32
|
-
"
|
33
|
-
|
34
|
-
|
35
|
-
"
|
38
|
+
"test": "echo 'Addon does not have tests, run tests in test-app'",
|
39
|
+
"prepublishOnly": "pnpm run build"
|
40
|
+
},
|
41
|
+
"dependencies": {
|
42
|
+
"@embroider/addon-shim": "1.3.0",
|
43
|
+
"ember-window-mock": "^0.8.1"
|
44
|
+
},
|
45
|
+
"devDependencies": {
|
46
|
+
"@babel/core": "7.17.5",
|
47
|
+
"@babel/plugin-proposal-class-properties": "7.16.7",
|
48
|
+
"@babel/plugin-proposal-decorators": "7.17.2",
|
49
|
+
"@babel/plugin-syntax-decorators": "7.17.0",
|
50
|
+
"@babel/plugin-transform-typescript": "7.16.8",
|
51
|
+
"@babel/preset-typescript": "7.16.7",
|
52
|
+
"@embroider/addon-dev": "1.3.0",
|
53
|
+
"@nullvoxpopuli/eslint-configs": "2.2.2",
|
54
|
+
"@semantic-release/changelog": "^5.0.0",
|
55
|
+
"@semantic-release/git": "^9.0.0",
|
56
|
+
"@types/ember__application": "^4.0.0",
|
57
|
+
"@types/ember__engine": "^4.0.0",
|
58
|
+
"@types/ember__object": "^4.0.0",
|
59
|
+
"@types/ember__service": "^4.0.0",
|
60
|
+
"@types/ember__test-helpers": "^2.0.2",
|
61
|
+
"@types/qunit": "^2.11.3",
|
62
|
+
"babel-eslint": "10.1.0",
|
63
|
+
"concurrently": "7.0.0",
|
64
|
+
"eslint": "^7.0.0",
|
65
|
+
"eslint-config-prettier": "8.5.0",
|
66
|
+
"eslint-plugin-decorator-position": "4.0.1",
|
67
|
+
"eslint-plugin-ember": "10.5.9",
|
68
|
+
"eslint-plugin-import": "2.25.4",
|
69
|
+
"eslint-plugin-json": "3.1.0",
|
70
|
+
"eslint-plugin-node": "11.1.0",
|
71
|
+
"eslint-plugin-prettier": "4.0.0",
|
72
|
+
"eslint-plugin-simple-import-sort": "7.0.0",
|
73
|
+
"prettier": "^2.2.1",
|
74
|
+
"rollup": "2.69.1",
|
75
|
+
"rollup-plugin-ts": "2.0.5",
|
76
|
+
"semantic-release": "^17.0.0",
|
77
|
+
"typescript": "4.6.2"
|
36
78
|
},
|
37
79
|
"publishConfig": {
|
38
80
|
"registry": "https://registry.npmjs.org"
|
39
81
|
},
|
82
|
+
"ember": {
|
83
|
+
"edition": "octane"
|
84
|
+
},
|
85
|
+
"ember-addon": {
|
86
|
+
"version": 2,
|
87
|
+
"type": "addon",
|
88
|
+
"main": "./addon-main.cjs",
|
89
|
+
"app-js": {
|
90
|
+
"./services/browser/-proxy-service.js": "./dist/_app_/services/browser/-proxy-service.js",
|
91
|
+
"./services/browser/document.js": "./dist/_app_/services/browser/document.js",
|
92
|
+
"./services/browser/local-storage.js": "./dist/_app_/services/browser/local-storage.js",
|
93
|
+
"./services/browser/navigator.js": "./dist/_app_/services/browser/navigator.js",
|
94
|
+
"./services/browser/session-storage.js": "./dist/_app_/services/browser/session-storage.js",
|
95
|
+
"./services/browser/window.js": "./dist/_app_/services/browser/window.js"
|
96
|
+
}
|
97
|
+
},
|
98
|
+
"engines": {
|
99
|
+
"node": "12.* || >= 14"
|
100
|
+
},
|
101
|
+
"volta": {
|
102
|
+
"extends": "../package.json"
|
103
|
+
},
|
40
104
|
"release": {
|
41
105
|
"branches": [
|
42
106
|
"main"
|
@@ -50,111 +114,5 @@
|
|
50
114
|
"@semantic-release/git"
|
51
115
|
]
|
52
116
|
},
|
53
|
-
"
|
54
|
-
"*": {
|
55
|
-
"*": [
|
56
|
-
"declarations/*",
|
57
|
-
"declarations/*/index"
|
58
|
-
]
|
59
|
-
}
|
60
|
-
},
|
61
|
-
"dependencies": {
|
62
|
-
"ember-cli-babel": "^7.26.11",
|
63
|
-
"ember-cli-htmlbars": "^6.0.1",
|
64
|
-
"ember-cli-typescript": "^5.0.0",
|
65
|
-
"ember-window-mock": "^0.8.1"
|
66
|
-
},
|
67
|
-
"devDependencies": {
|
68
|
-
"@commitlint/cli": "^16.2.1",
|
69
|
-
"@commitlint/config-conventional": "^16.2.1",
|
70
|
-
"@ember/optional-features": "^2.0.0",
|
71
|
-
"@ember/test-helpers": "^2.6.0",
|
72
|
-
"@embroider/test-setup": "^1.2.0",
|
73
|
-
"@glimmer/component": "^1.0.4",
|
74
|
-
"@glimmer/tracking": "^1.0.4",
|
75
|
-
"@nullvoxpopuli/eslint-configs": "^2.1.23",
|
76
|
-
"@semantic-release/changelog": "^6.0.1",
|
77
|
-
"@semantic-release/git": "^10.0.1",
|
78
|
-
"@types/ember-qunit": "^3.4.15",
|
79
|
-
"@types/ember-resolver": "^5.0.10",
|
80
|
-
"@types/ember__application": "^3.16.3",
|
81
|
-
"@types/ember__array": "^3.16.4",
|
82
|
-
"@types/ember__component": "^3.16.6",
|
83
|
-
"@types/ember__controller": "^3.16.6",
|
84
|
-
"@types/ember__debug": "^3.16.5",
|
85
|
-
"@types/ember__engine": "^3.16.3",
|
86
|
-
"@types/ember__error": "^3.16.1",
|
87
|
-
"@types/ember__object": "^3.12.6",
|
88
|
-
"@types/ember__polyfills": "^3.12.1",
|
89
|
-
"@types/ember__routing": "^3.16.15",
|
90
|
-
"@types/ember__runloop": "^3.16.3",
|
91
|
-
"@types/ember__service": "^3.16.1",
|
92
|
-
"@types/ember__string": "^3.16.3",
|
93
|
-
"@types/ember__template": "^3.16.1",
|
94
|
-
"@types/ember__test": "^3.16.1",
|
95
|
-
"@types/ember__test-helpers": "^2.6.0",
|
96
|
-
"@types/ember__utils": "^3.16.2",
|
97
|
-
"@types/htmlbars-inline-precompile": "^1.0.1",
|
98
|
-
"@types/qunit": "^2.11.3",
|
99
|
-
"@types/rsvp": "^4.0.4",
|
100
|
-
"@typescript-eslint/eslint-plugin": "5.11.0",
|
101
|
-
"@typescript-eslint/parser": "^5.11.0",
|
102
|
-
"babel-eslint": "^10.1.0",
|
103
|
-
"broccoli-asset-rev": "^3.0.0",
|
104
|
-
"ember-auto-import": "^2.4.0",
|
105
|
-
"ember-cli": "~4.1.1",
|
106
|
-
"ember-cli-dependency-checker": "^3.2.0",
|
107
|
-
"ember-cli-inject-live-reload": "^2.1.0",
|
108
|
-
"ember-cli-sri": "^2.1.1",
|
109
|
-
"ember-cli-terser": "^4.0.2",
|
110
|
-
"ember-disable-prototype-extensions": "^1.1.3",
|
111
|
-
"ember-export-application-global": "^2.0.1",
|
112
|
-
"ember-load-initializers": "^2.1.2",
|
113
|
-
"ember-maybe-import-regenerator": "^1.0.0",
|
114
|
-
"ember-page-title": "^7.0.0",
|
115
|
-
"ember-qunit": "^5.1.5",
|
116
|
-
"ember-resolver": "^8.0.3",
|
117
|
-
"ember-source": "~4.2.0",
|
118
|
-
"ember-source-channel-url": "^3.0.0",
|
119
|
-
"ember-template-lint": "^4.0.0",
|
120
|
-
"ember-try": "^2.0.0",
|
121
|
-
"eslint": "^7.32.0",
|
122
|
-
"eslint-config-prettier": "8.3.0",
|
123
|
-
"eslint-plugin-decorator-position": "^4.0.1",
|
124
|
-
"eslint-plugin-ember": "^10.5.8",
|
125
|
-
"eslint-plugin-markdown": "^2.2.1",
|
126
|
-
"eslint-plugin-node": "^11.1.0",
|
127
|
-
"eslint-plugin-prettier": "4.0.0",
|
128
|
-
"eslint-plugin-qunit": "^7.2.0",
|
129
|
-
"loader.js": "^4.7.0",
|
130
|
-
"npm-run-all": "^4.1.5",
|
131
|
-
"prettier": "2.5.1",
|
132
|
-
"qunit": "^2.17.2",
|
133
|
-
"qunit-console-grouper": "^0.3.0",
|
134
|
-
"qunit-dom": "^2.0.0",
|
135
|
-
"remark-cli": "^10.0.1",
|
136
|
-
"remark-lint": "^9.1.1",
|
137
|
-
"remark-preset-lint-recommended": "^6.1.2",
|
138
|
-
"semantic-release": "^19.0.2",
|
139
|
-
"typescript": "^4.5.5",
|
140
|
-
"webpack": "^5.69.1"
|
141
|
-
},
|
142
|
-
"remarkConfig": {
|
143
|
-
"plugins": [
|
144
|
-
"remark-preset-lint-recommended"
|
145
|
-
]
|
146
|
-
},
|
147
|
-
"engines": {
|
148
|
-
"node": "12.* || >= 14"
|
149
|
-
},
|
150
|
-
"ember": {
|
151
|
-
"edition": "octane"
|
152
|
-
},
|
153
|
-
"ember-addon": {
|
154
|
-
"configPath": "tests/dummy/config"
|
155
|
-
},
|
156
|
-
"volta": {
|
157
|
-
"node": "16.14.0",
|
158
|
-
"yarn": "1.22.17"
|
159
|
-
}
|
117
|
+
"types": "dist"
|
160
118
|
}
|
package/.remarkignore
DELETED
package/LICENSE.md
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
The MIT License (MIT)
|
2
|
-
|
3
|
-
Copyright (c) 2020
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
6
|
-
|
7
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
8
|
-
|
9
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -1,21 +0,0 @@
|
|
1
|
-
import '@ember/service';
|
2
|
-
|
3
|
-
import { proxyService } from 'ember-browser-services/utils/proxy-service';
|
4
|
-
|
5
|
-
const DocumentProxyService = proxyService(document);
|
6
|
-
|
7
|
-
/**
|
8
|
-
* In order to have thorough testing, we should only interact with the document
|
9
|
-
* (and other browser APIs) via a service.
|
10
|
-
*
|
11
|
-
* We can control, mock, and override the services, but we can't do so with
|
12
|
-
* the browser APIs.
|
13
|
-
*
|
14
|
-
*/
|
15
|
-
export default DocumentProxyService;
|
16
|
-
|
17
|
-
declare module '@ember/service' {
|
18
|
-
interface Registry {
|
19
|
-
'browser/document': typeof DocumentProxyService;
|
20
|
-
}
|
21
|
-
}
|
@@ -1,21 +0,0 @@
|
|
1
|
-
import '@ember/service';
|
2
|
-
|
3
|
-
import { proxyService } from 'ember-browser-services/utils/proxy-service';
|
4
|
-
|
5
|
-
const NavigatorProxyService = proxyService(navigator);
|
6
|
-
|
7
|
-
/**
|
8
|
-
* In order to have thorough testing, we should only interact with the navigator
|
9
|
-
* (and other browser APIs) via a service.
|
10
|
-
*
|
11
|
-
* We can control, mock, and override the services, but we can't do so with
|
12
|
-
* the browser APIs.
|
13
|
-
*
|
14
|
-
*/
|
15
|
-
export default NavigatorProxyService;
|
16
|
-
|
17
|
-
declare module '@ember/service' {
|
18
|
-
interface Registry {
|
19
|
-
'browser/navigator': typeof NavigatorProxyService;
|
20
|
-
}
|
21
|
-
}
|
@@ -1,27 +0,0 @@
|
|
1
|
-
import '@ember/service';
|
2
|
-
|
3
|
-
import { proxyService } from 'ember-browser-services/utils/proxy-service';
|
4
|
-
|
5
|
-
/**
|
6
|
-
* In order to have thorough testing, we should only interact with the window
|
7
|
-
* (and other browser APIs) via a service.
|
8
|
-
*
|
9
|
-
* We can control, mock, and override the services, but we can't do so with
|
10
|
-
* the browser APIs.
|
11
|
-
*
|
12
|
-
*/
|
13
|
-
const WindowProxyService = proxyService(window);
|
14
|
-
|
15
|
-
export default WindowProxyService;
|
16
|
-
|
17
|
-
declare global {
|
18
|
-
interface Window {
|
19
|
-
requirejs: (path: string) => { default: never };
|
20
|
-
}
|
21
|
-
}
|
22
|
-
|
23
|
-
declare module '@ember/service' {
|
24
|
-
interface Registry {
|
25
|
-
'browser/window': typeof WindowProxyService;
|
26
|
-
}
|
27
|
-
}
|
package/addon/tsconfig.json
DELETED