@phantomstudios/ft-lib 0.4.1-rc1 → 0.5.0-rc10

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/.github/CODEOWNERS +1 -1
  2. package/.github/dependabot.yml +11 -0
  3. package/.github/workflows/pr.yml +4 -1
  4. package/.github/workflows/release.yml +9 -2
  5. package/.nvmrc +1 -1
  6. package/CODE_OF_CONDUCT.md +1 -1
  7. package/CONTRIBUTING.md +3 -5
  8. package/SUPPORT.md +3 -3
  9. package/eslint.config.mjs +91 -0
  10. package/jest.config.js +1 -6
  11. package/lib/FTTracking/index.d.ts +3 -0
  12. package/lib/FTTracking/index.d.ts.map +1 -1
  13. package/lib/FTTracking/index.js +14 -1
  14. package/lib/FTTracking/index.js.map +1 -1
  15. package/lib/cmp/loadFtCmp.d.ts +3 -0
  16. package/lib/cmp/loadFtCmp.d.ts.map +1 -0
  17. package/lib/cmp/loadFtCmp.js +31 -0
  18. package/lib/cmp/loadFtCmp.js.map +1 -0
  19. package/lib/consentMonitor/index.d.ts +12 -12
  20. package/lib/consentMonitor/index.d.ts.map +1 -1
  21. package/lib/consentMonitor/index.js +111 -68
  22. package/lib/consentMonitor/index.js.map +1 -1
  23. package/lib/gaTracker/index.js +1 -2
  24. package/lib/gaTracker/index.js.map +1 -1
  25. package/lib/index.d.ts +7 -3
  26. package/lib/index.d.ts.map +1 -1
  27. package/lib/index.js +7 -4
  28. package/lib/index.js.map +1 -1
  29. package/lib/oTracker/index.js.map +1 -1
  30. package/lib/permutiveVideoUtils/index.d.ts.map +1 -1
  31. package/lib/permutiveVideoUtils/index.js +1 -1
  32. package/lib/permutiveVideoUtils/index.js.map +1 -1
  33. package/lib/reactPlayerTracking/index.d.ts.map +1 -1
  34. package/lib/reactPlayerTracking/index.js +1 -1
  35. package/lib/reactPlayerTracking/index.js.map +1 -1
  36. package/lib/utils/attention.js.map +1 -1
  37. package/lib/utils/cookies.js +1 -2
  38. package/lib/utils/cookies.js.map +1 -1
  39. package/lib/utils/getTrace.js.map +1 -1
  40. package/lib/utils/intersectionObserverPolyfill.d.ts +1 -0
  41. package/lib/utils/intersectionObserverPolyfill.js +1 -0
  42. package/lib/utils/intersectionObserverPolyfill.js.map +1 -1
  43. package/lib/utils/scroll.js.map +1 -1
  44. package/lib/utils/yupValidator.d.ts.map +1 -1
  45. package/lib/utils/yupValidator.js +2 -2
  46. package/lib/utils/yupValidator.js.map +1 -1
  47. package/lib/ytIframeTracking/index.d.ts +0 -1
  48. package/lib/ytIframeTracking/index.d.ts.map +1 -1
  49. package/lib/ytIframeTracking/index.js.map +1 -1
  50. package/package.json +27 -17
  51. package/src/FTTracking/index.ts +21 -4
  52. package/src/cmp/loadFtCmp.ts +28 -0
  53. package/src/consentMonitor/index.ts +108 -85
  54. package/src/gaTracker/index.ts +4 -4
  55. package/src/index.ts +10 -3
  56. package/src/oTracker/index.ts +5 -5
  57. package/src/permutiveVideoUtils/index.ts +2 -2
  58. package/src/reactPlayerTracking/index.ts +4 -4
  59. package/src/types.d.ts +24 -5
  60. package/src/utils/attention.js +9 -9
  61. package/src/utils/getTrace.js +2 -2
  62. package/src/utils/scroll.ts +2 -2
  63. package/src/utils/yupValidator.ts +6 -6
  64. package/src/ytIframeTracking/index.ts +9 -9
  65. package/test/index.test.tsx +13 -12
  66. package/tsconfig.json +3 -1
  67. package/.eslintrc +0 -58
@@ -1,8 +1,15 @@
1
- import { consentMonitor } from "../src/consentMonitor";
1
+ /**
2
+ * @jest-environment jsdom
3
+ */
4
+
5
+ import * as cmpLoader from "../src/cmp/loadFtCmp";
6
+ import { ConsentMonitor, consentMonitor } from "../src/consentMonitor";
2
7
  import { permutiveVideoUtils } from "../src/permutiveVideoUtils";
3
8
 
4
9
  let windowSpy: jest.SpyInstance;
5
10
 
11
+ jest.spyOn(cmpLoader, "loadFtCmpScript").mockResolvedValue(undefined);
12
+
6
13
  beforeEach(() => {
7
14
  windowSpy = jest.spyOn(window, "window", "get");
8
15
  });
@@ -30,23 +37,17 @@ describe("consentMonitor", () => {
30
37
  expect(obj.isDevEnvironment).toBe(true);
31
38
  });
32
39
 
33
- it("Initializes correctly", async () => {
34
- jest.useFakeTimers();
35
- windowSpy.mockImplementation(() => ({
36
- permutive: {
37
- consent: ({}) => {
38
- return {};
39
- },
40
- },
41
- }));
42
- const obj = new consentMonitor("https://FT-staging.devhost.com", [
40
+ it("Initializes correctly and sets the isInitialized flag", async () => {
41
+ const obj = new ConsentMonitor("https://FT-staging.devhost.com", [
43
42
  "localhost",
44
- "vercel.app",
45
43
  "phq",
46
44
  "devhost",
47
45
  ]);
46
+
47
+ await new Promise(process.nextTick);
48
48
  expect(obj.isInitialized).toBe(true);
49
49
  });
50
+
50
51
  //TODO - mock document.cookie get/set and test consent value
51
52
  describe("Permutive video progress utils", () => {
52
53
  it("can be initiated", () => {
package/tsconfig.json CHANGED
@@ -1,7 +1,9 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "target": "es5",
4
- "module": "commonjs",
4
+ "module": "node16",
5
+ "moduleResolution": "node16",
6
+ "isolatedModules": true,
5
7
  "types": ["youtube", "jest"],
6
8
  "lib": ["dom", "es2020"],
7
9
  "jsx": "react",
package/.eslintrc DELETED
@@ -1,58 +0,0 @@
1
- {
2
- "env": {
3
- "browser": true,
4
- "node": true,
5
- "es6": true,
6
- "jest": true
7
- },
8
- "parser": "@typescript-eslint/parser",
9
- "parserOptions": {
10
- "jsx": true,
11
- "useJSXTextNode": true
12
- },
13
- "settings": {
14
- "react": {
15
- "version": "detect"
16
- }
17
- },
18
- "plugins": ["prettier", "eslint-plugin-import"],
19
- "extends": [
20
- "plugin:react/recommended",
21
- "plugin:react-hooks/recommended",
22
- "plugin:@typescript-eslint/recommended",
23
- "plugin:prettier/recommended"
24
- ],
25
- "rules": {
26
- "react-hooks/rules-of-hooks": "error",
27
- "react-hooks/exhaustive-deps": "error",
28
- "react/react-in-jsx-scope": "off",
29
- "@typescript-eslint/explicit-function-return-type": "off",
30
- "@typescript-eslint/explicit-module-boundary-types": "off",
31
- "@typescript-eslint/ban-ts-comment": "off",
32
- "@typescript-eslint/no-explicit-any": "off",
33
- "react/prop-types": "off",
34
- "import/order": [
35
- "error",
36
- {
37
- "groups": ["builtin", "external", "internal"],
38
- "pathGroups": [
39
- {
40
- "pattern": "react",
41
- "group": "external",
42
- "position": "before"
43
- }
44
- ],
45
- "pathGroupsExcludedImportTypes": ["react"],
46
- "newlines-between": "always",
47
- "alphabetize": {
48
- "order": "asc",
49
- "caseInsensitive": true
50
- }
51
- }
52
- ],
53
- "prettier/prettier": "error"
54
- },
55
- "globals": {
56
- "React": "writable"
57
- }
58
- }