@next/third-parties 14.0.5-canary.2 → 14.0.5-canary.20

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.
@@ -1,9 +1,9 @@
1
1
  import React from 'react';
2
2
  export type ScriptEmbed = {
3
3
  html?: string | null;
4
- height?: number | null;
5
- width?: number | null;
4
+ height?: string | number | null;
5
+ width?: string | number | null;
6
6
  children?: React.ReactElement | React.ReactElement[];
7
7
  dataNtpc?: string;
8
8
  };
9
- export default function ThirdPartyScriptEmbed({ html, height, width, children, dataNtpc, }: ScriptEmbed): React.JSX.Element;
9
+ export default function ThirdPartyScriptEmbed({ html, height, width, children, dataNtpc, }: ScriptEmbed): import("react/jsx-runtime").JSX.Element;
@@ -1,30 +1,8 @@
1
1
  "use strict";
2
2
  'use client';
3
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
- if (k2 === undefined) k2 = k;
5
- var desc = Object.getOwnPropertyDescriptor(m, k);
6
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
- desc = { enumerable: true, get: function() { return m[k]; } };
8
- }
9
- Object.defineProperty(o, k2, desc);
10
- }) : (function(o, m, k, k2) {
11
- if (k2 === undefined) k2 = k;
12
- o[k2] = m[k];
13
- }));
14
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
- Object.defineProperty(o, "default", { enumerable: true, value: v });
16
- }) : function(o, v) {
17
- o["default"] = v;
18
- });
19
- var __importStar = (this && this.__importStar) || function (mod) {
20
- if (mod && mod.__esModule) return mod;
21
- var result = {};
22
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
23
- __setModuleDefault(result, mod);
24
- return result;
25
- };
26
3
  Object.defineProperty(exports, "__esModule", { value: true });
27
- const react_1 = __importStar(require("react"));
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
28
6
  function ThirdPartyScriptEmbed({ html, height = null, width = null, children, dataNtpc = '', }) {
29
7
  (0, react_1.useEffect)(() => {
30
8
  if (dataNtpc) {
@@ -38,11 +16,9 @@ function ThirdPartyScriptEmbed({ html, height = null, width = null, children, da
38
16
  });
39
17
  }
40
18
  }, [dataNtpc]);
41
- return (react_1.default.createElement(react_1.default.Fragment, null,
42
- children,
43
- html ? (react_1.default.createElement("div", { style: {
44
- height: height != null ? `${height}px` : 'auto',
45
- width: width != null ? `${width}px` : 'auto',
46
- }, "data-ntpc": dataNtpc, dangerouslySetInnerHTML: { __html: html } })) : null));
19
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [children, html ? ((0, jsx_runtime_1.jsx)("div", { style: {
20
+ height: height != null ? `${height}px` : 'auto',
21
+ width: width != null ? `${width}px` : 'auto',
22
+ }, "data-ntpc": dataNtpc, dangerouslySetInnerHTML: { __html: html } })) : null] }));
47
23
  }
48
24
  exports.default = ThirdPartyScriptEmbed;
@@ -0,0 +1,8 @@
1
+ import type { GAParams } from '../types/google';
2
+ declare global {
3
+ interface Window {
4
+ dataLayer?: Object[];
5
+ }
6
+ }
7
+ export declare function GoogleAnalytics(props: GAParams): import("react/jsx-runtime").JSX.Element;
8
+ export declare const sendGAEvent: (...args: Object[]) => void;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ 'use client';
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.sendGAEvent = exports.GoogleAnalytics = void 0;
8
+ const jsx_runtime_1 = require("react/jsx-runtime");
9
+ // TODO: Evaluate import 'client only'
10
+ const react_1 = require("react");
11
+ const script_1 = __importDefault(require("next/script"));
12
+ let currDataLayerName = undefined;
13
+ function GoogleAnalytics(props) {
14
+ const { gaId, dataLayerName = 'dataLayer' } = props;
15
+ if (currDataLayerName === undefined) {
16
+ currDataLayerName = dataLayerName;
17
+ }
18
+ (0, react_1.useEffect)(() => {
19
+ // performance.mark is being used as a feature use signal. While it is traditionally used for performance
20
+ // benchmarking it is low overhead and thus considered safe to use in production and it is a widely available
21
+ // existing API.
22
+ // The performance measurement will be handled by Chrome Aurora
23
+ performance.mark('mark_feature_usage', {
24
+ detail: {
25
+ feature: 'next-third-parties-ga',
26
+ },
27
+ });
28
+ }, []);
29
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(script_1.default, { id: "_next-ga-init", dangerouslySetInnerHTML: {
30
+ __html: `
31
+ window['${dataLayerName}'] = window['${dataLayerName}'] || [];
32
+ function gtag(){window['${dataLayerName}'].push(arguments);}
33
+ gtag('js', new Date());
34
+
35
+ gtag('config', '${gaId}');`,
36
+ } }), (0, jsx_runtime_1.jsx)(script_1.default, { id: "_next-ga", src: `https://www.googletagmanager.com/gtag/js?id=${gaId}` })] }));
37
+ }
38
+ exports.GoogleAnalytics = GoogleAnalytics;
39
+ const sendGAEvent = (...args) => {
40
+ if (currDataLayerName === undefined) {
41
+ console.warn(`@next/third-parties: GA has not been initialized`);
42
+ return;
43
+ }
44
+ if (window[currDataLayerName]) {
45
+ window[currDataLayerName].push(...args);
46
+ }
47
+ else {
48
+ console.warn(`@next/third-parties: GA dataLayer ${currDataLayerName} does not exist`);
49
+ }
50
+ };
51
+ exports.sendGAEvent = sendGAEvent;
@@ -1,3 +1,2 @@
1
- import React from 'react';
2
1
  import type { GoogleMapsEmbed as GoogleMapsEmbedTypes } from '../types/google';
3
- export default function GoogleMapsEmbed(props: GoogleMapsEmbedTypes): React.JSX.Element;
2
+ export default function GoogleMapsEmbed(props: GoogleMapsEmbedTypes): import("react/jsx-runtime").JSX.Element;
@@ -3,13 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const react_1 = __importDefault(require("react"));
6
+ const jsx_runtime_1 = require("react/jsx-runtime");
7
7
  const third_party_capital_1 = require("third-party-capital");
8
8
  const ThirdPartyScriptEmbed_1 = __importDefault(require("../ThirdPartyScriptEmbed"));
9
9
  function GoogleMapsEmbed(props) {
10
10
  const { apiKey, ...restProps } = props;
11
11
  const formattedProps = { ...restProps, key: apiKey };
12
12
  const { html } = (0, third_party_capital_1.GoogleMapsEmbed)(formattedProps);
13
- return (react_1.default.createElement(ThirdPartyScriptEmbed_1.default, { height: formattedProps.height || null, width: formattedProps.width || null, html: html, dataNtpc: "GoogleMapsEmbed" }));
13
+ return ((0, jsx_runtime_1.jsx)(ThirdPartyScriptEmbed_1.default, { height: formattedProps.height || null, width: formattedProps.width || null, html: html, dataNtpc: "GoogleMapsEmbed" }));
14
14
  }
15
15
  exports.default = GoogleMapsEmbed;
@@ -1,4 +1,3 @@
1
- import React from 'react';
2
1
  import type { GTMParams } from '../types/google';
3
- export declare function GoogleTagManager(props: GTMParams): React.JSX.Element;
2
+ export declare function GoogleTagManager(props: GTMParams): import("react/jsx-runtime").JSX.Element;
4
3
  export declare const sendGTMEvent: (data: Object) => void;
@@ -1,35 +1,13 @@
1
1
  "use strict";
2
2
  'use client';
3
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
- if (k2 === undefined) k2 = k;
5
- var desc = Object.getOwnPropertyDescriptor(m, k);
6
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
- desc = { enumerable: true, get: function() { return m[k]; } };
8
- }
9
- Object.defineProperty(o, k2, desc);
10
- }) : (function(o, m, k, k2) {
11
- if (k2 === undefined) k2 = k;
12
- o[k2] = m[k];
13
- }));
14
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
- Object.defineProperty(o, "default", { enumerable: true, value: v });
16
- }) : function(o, v) {
17
- o["default"] = v;
18
- });
19
- var __importStar = (this && this.__importStar) || function (mod) {
20
- if (mod && mod.__esModule) return mod;
21
- var result = {};
22
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
23
- __setModuleDefault(result, mod);
24
- return result;
25
- };
26
3
  var __importDefault = (this && this.__importDefault) || function (mod) {
27
4
  return (mod && mod.__esModule) ? mod : { "default": mod };
28
5
  };
29
6
  Object.defineProperty(exports, "__esModule", { value: true });
30
7
  exports.sendGTMEvent = exports.GoogleTagManager = void 0;
8
+ const jsx_runtime_1 = require("react/jsx-runtime");
31
9
  // TODO: Evaluate import 'client only'
32
- const react_1 = __importStar(require("react"));
10
+ const react_1 = require("react");
33
11
  const script_1 = __importDefault(require("next/script"));
34
12
  let currDataLayerName = undefined;
35
13
  function GoogleTagManager(props) {
@@ -44,22 +22,21 @@ function GoogleTagManager(props) {
44
22
  // performance.mark is being used as a feature use signal. While it is traditionally used for performance
45
23
  // benchmarking it is low overhead and thus considered safe to use in production and it is a widely available
46
24
  // existing API.
25
+ // The performance measurement will be handled by Chrome Aurora
47
26
  performance.mark('mark_feature_usage', {
48
27
  detail: {
49
28
  feature: 'next-third-parties-gtm',
50
29
  },
51
30
  });
52
31
  }, []);
53
- return (react_1.default.createElement(react_1.default.Fragment, null,
54
- react_1.default.createElement(script_1.default, { id: "_next-gtm-init", dangerouslySetInnerHTML: {
55
- __html: `
32
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(script_1.default, { id: "_next-gtm-init", dangerouslySetInnerHTML: {
33
+ __html: `
56
34
  (function(w,l){
57
35
  w[l]=w[l]||[];
58
36
  w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});
59
37
  ${dataLayer ? `w[l].push(${JSON.stringify(dataLayer)})` : ''}
60
38
  })(window,'${dataLayerName}');`,
61
- } }),
62
- react_1.default.createElement(script_1.default, { id: "_next-gtm", "data-ntpc": "GTM", src: `https://www.googletagmanager.com/gtm.js?id=${gtmId}${gtmLayer}${gtmAuth}${gtmPreview}` })));
39
+ } }), (0, jsx_runtime_1.jsx)(script_1.default, { id: "_next-gtm", "data-ntpc": "GTM", src: `https://www.googletagmanager.com/gtm.js?id=${gtmId}${gtmLayer}${gtmAuth}${gtmPreview}` })] }));
63
40
  }
64
41
  exports.GoogleTagManager = GoogleTagManager;
65
42
  const sendGTMEvent = (data) => {
@@ -1,3 +1,4 @@
1
1
  export { default as GoogleMapsEmbed } from './google-maps-embed';
2
2
  export { default as YouTubeEmbed } from './youtube-embed';
3
3
  export { GoogleTagManager, sendGTMEvent } from './gtm';
4
+ export { GoogleAnalytics, sendGAEvent } from './ga';
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.sendGTMEvent = exports.GoogleTagManager = exports.YouTubeEmbed = exports.GoogleMapsEmbed = void 0;
6
+ exports.sendGAEvent = exports.GoogleAnalytics = exports.sendGTMEvent = exports.GoogleTagManager = exports.YouTubeEmbed = exports.GoogleMapsEmbed = void 0;
7
7
  var google_maps_embed_1 = require("./google-maps-embed");
8
8
  Object.defineProperty(exports, "GoogleMapsEmbed", { enumerable: true, get: function () { return __importDefault(google_maps_embed_1).default; } });
9
9
  var youtube_embed_1 = require("./youtube-embed");
@@ -11,3 +11,6 @@ Object.defineProperty(exports, "YouTubeEmbed", { enumerable: true, get: function
11
11
  var gtm_1 = require("./gtm");
12
12
  Object.defineProperty(exports, "GoogleTagManager", { enumerable: true, get: function () { return gtm_1.GoogleTagManager; } });
13
13
  Object.defineProperty(exports, "sendGTMEvent", { enumerable: true, get: function () { return gtm_1.sendGTMEvent; } });
14
+ var ga_1 = require("./ga");
15
+ Object.defineProperty(exports, "GoogleAnalytics", { enumerable: true, get: function () { return ga_1.GoogleAnalytics; } });
16
+ Object.defineProperty(exports, "sendGAEvent", { enumerable: true, get: function () { return ga_1.sendGAEvent; } });
@@ -1,3 +1,2 @@
1
- import React from 'react';
2
1
  import type { YouTubeEmbed as YouTubeEmbedTypes } from '../types/google';
3
- export default function YouTubeEmbed(props: YouTubeEmbedTypes): React.JSX.Element;
2
+ export default function YouTubeEmbed(props: YouTubeEmbedTypes): import("react/jsx-runtime").JSX.Element;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const react_1 = __importDefault(require("react"));
6
+ const jsx_runtime_1 = require("react/jsx-runtime");
7
7
  const script_1 = __importDefault(require("next/script"));
8
8
  const third_party_capital_1 = require("third-party-capital");
9
9
  const ThirdPartyScriptEmbed_1 = __importDefault(require("../ThirdPartyScriptEmbed"));
@@ -15,6 +15,6 @@ const scriptStrategy = {
15
15
  };
16
16
  function YouTubeEmbed(props) {
17
17
  const { html, scripts, stylesheets } = (0, third_party_capital_1.YouTubeEmbed)(props);
18
- return (react_1.default.createElement(ThirdPartyScriptEmbed_1.default, { height: props.height || null, width: props.width || null, html: html, dataNtpc: "YouTubeEmbed" }, scripts === null || scripts === void 0 ? void 0 : scripts.map((script) => (react_1.default.createElement(script_1.default, { key: script.url, src: script.url, strategy: scriptStrategy[script.strategy], stylesheets: stylesheets })))));
18
+ return ((0, jsx_runtime_1.jsx)(ThirdPartyScriptEmbed_1.default, { height: props.height || null, width: props.width || null, html: html, dataNtpc: "YouTubeEmbed", children: scripts === null || scripts === void 0 ? void 0 : scripts.map((script) => ((0, jsx_runtime_1.jsx)(script_1.default, { src: script.url, strategy: scriptStrategy[script.strategy], stylesheets: stylesheets }, script.url))) }));
19
19
  }
20
20
  exports.default = YouTubeEmbed;
@@ -11,15 +11,20 @@ export type GTMParams = {
11
11
  auth?: string;
12
12
  preview?: string;
13
13
  };
14
+ export type GAParams = {
15
+ gaId: string;
16
+ dataLayerName?: string;
17
+ };
14
18
  export type GoogleMapsEmbed = {
15
- height?: number;
16
- width?: number;
19
+ height?: number | string;
20
+ width?: number | string;
17
21
  mode: 'place' | 'view' | 'directions' | 'streetview' | 'search';
18
22
  apiKey: string;
19
- style: string;
20
- allowfullscreen: boolean;
21
- loading: 'eager' | 'lazy';
23
+ style?: string;
24
+ allowfullscreen?: boolean;
25
+ loading?: 'eager' | 'lazy';
22
26
  q?: string;
27
+ id?: string;
23
28
  center?: string;
24
29
  zoom?: string;
25
30
  maptype?: string;
package/google.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './dist/google/index'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@next/third-parties",
3
- "version": "14.0.5-canary.2",
3
+ "version": "14.0.5-canary.20",
4
4
  "repository": {
5
5
  "url": "vercel/next.js",
6
6
  "directory": "packages/third-parties"
@@ -12,7 +12,8 @@
12
12
  }
13
13
  },
14
14
  "files": [
15
- "dist"
15
+ "dist",
16
+ "google.d.ts"
16
17
  ],
17
18
  "license": "MIT",
18
19
  "scripts": {
@@ -25,7 +26,7 @@
25
26
  "third-party-capital": "1.0.20"
26
27
  },
27
28
  "devDependencies": {
28
- "next": "14.0.5-canary.2",
29
+ "next": "14.0.5-canary.20",
29
30
  "outdent": "0.8.0",
30
31
  "prettier": "2.5.1"
31
32
  },