@ninetailed/experience.js-gatsby 3.0.0-beta.15 → 3.0.0-beta.17

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/Tracker.js ADDED
@@ -0,0 +1,31 @@
1
+ import React, { useEffect, useRef } from 'react';
2
+ import { Location } from '@reach/router';
3
+ import { useNinetailed } from '@ninetailed/experience.js-react';
4
+
5
+ const usePrevious = value => {
6
+ const ref = useRef();
7
+ useEffect(() => {
8
+ ref.current = value;
9
+ });
10
+ return ref.current;
11
+ };
12
+ const Executor = ({
13
+ location
14
+ }) => {
15
+ const {
16
+ page
17
+ } = useNinetailed();
18
+ const previousPathname = usePrevious(location);
19
+ const pathname = location.pathname;
20
+ useEffect(() => {
21
+ if (pathname !== previousPathname) {
22
+ page();
23
+ }
24
+ }, [pathname, previousPathname, page]);
25
+ return null;
26
+ };
27
+ const Tracker = () => {
28
+ return /*#__PURE__*/React.createElement(Location, null, location => /*#__PURE__*/React.createElement(Executor, Object.assign({}, location)));
29
+ };
30
+
31
+ export { Tracker as T };
@@ -0,0 +1,3 @@
1
+ import { WrapRootElementBrowserArgs } from 'gatsby';
2
+ import { PluginOptions } from './plugin-options';
3
+ export declare const wrapRootElement: (args: WrapRootElementBrowserArgs, options: PluginOptions) => JSX.Element;
package/gatsby-browser.js CHANGED
@@ -1,23 +1,56 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.wrapRootElement = void 0;
4
- const tslib_1 = require("tslib");
5
- const react_1 = (0, tslib_1.__importDefault)(require("react"));
6
- const experience_js_react_1 = require("@ninetailed/experience.js-react");
7
- const Tracker_1 = require("./src/lib/Tracker");
8
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
9
- //@ts-ignore
10
- const ninetailed_plugins_1 = require("./loaders/ninetailed-plugins");
11
- const WrapRootElement = (_a) => {
12
- var { children } = _a, options = (0, tslib_1.__rest)(_a, ["children"]);
13
- const resolvedPlugins = ninetailed_plugins_1.plugins.map(({ plugin, options }) => plugin(options));
14
- return (react_1.default.createElement(experience_js_react_1.NinetailedProvider, Object.assign({}, options, { plugins: resolvedPlugins }),
15
- react_1.default.createElement(Tracker_1.Tracker, null),
16
- children));
1
+ import React from 'react';
2
+ import { NinetailedProvider } from '@ninetailed/experience.js-react';
3
+ import { T as Tracker } from './Tracker.js';
4
+ import { n as ninetailedPlugins } from './ninetailed-plugins.js';
5
+ import '@reach/router';
6
+ import 'path';
7
+ import 'crypto';
8
+
9
+ /******************************************************************************
10
+ Copyright (c) Microsoft Corporation.
11
+
12
+ Permission to use, copy, modify, and/or distribute this software for any
13
+ purpose with or without fee is hereby granted.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
16
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
17
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
18
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
19
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
20
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
21
+ PERFORMANCE OF THIS SOFTWARE.
22
+ ***************************************************************************** */
23
+
24
+ function __rest(s, e) {
25
+ var t = {};
26
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
27
+ t[p] = s[p];
28
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
29
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
30
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
31
+ t[p[i]] = s[p[i]];
32
+ }
33
+ return t;
34
+ }
35
+
36
+ const WrapRootElement = _a => {
37
+ var {
38
+ children
39
+ } = _a,
40
+ options = __rest(_a, ["children"]);
41
+ const resolvedPlugins = ninetailedPlugins.plugins.map(({
42
+ plugin,
43
+ options
44
+ }) => plugin(options));
45
+ return /*#__PURE__*/React.createElement(NinetailedProvider, Object.assign({}, options, {
46
+ plugins: resolvedPlugins
47
+ }), /*#__PURE__*/React.createElement(Tracker, null), children);
17
48
  };
18
49
  const wrapRootElement = (args, options) => {
19
- const { element } = args;
20
- return react_1.default.createElement(WrapRootElement, Object.assign({}, options), element);
50
+ const {
51
+ element
52
+ } = args;
53
+ return /*#__PURE__*/React.createElement(WrapRootElement, Object.assign({}, options), element);
21
54
  };
22
- exports.wrapRootElement = wrapRootElement;
23
- //# sourceMappingURL=gatsby-browser.js.map
55
+
56
+ export { wrapRootElement };
@@ -0,0 +1,8 @@
1
+ import { PluginOptionsSchemaArgs, CreateWebpackConfigArgs } from 'gatsby';
2
+ import { ObjectSchema } from 'gatsby-plugin-utils';
3
+ import { PluginOptions } from './plugin-options';
4
+ export declare const pluginOptionsSchema: ({ Joi, }: PluginOptionsSchemaArgs) => ObjectSchema<any>;
5
+ /**
6
+ * Add the webpack config for loading MDX files
7
+ */
8
+ export declare const onCreateWebpackConfig: ({ loaders, actions }: CreateWebpackConfigArgs, pluginOptions: PluginOptions) => void;
package/gatsby-node.js CHANGED
@@ -1,50 +1,43 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.onCreateWebpackConfig = exports.pluginOptionsSchema = void 0;
4
- const tslib_1 = require("tslib");
5
- const path_1 = (0, tslib_1.__importDefault)(require("path"));
6
- const pluginOptionsSchema = ({ Joi, }) => {
7
- return Joi.object({
8
- clientId: Joi.string()
9
- .required()
10
- .description("Your organizations' client id.")
11
- .messages({
12
- 'any.required': '"clientId" needs to be specified. Get your clientId from the dashboard.',
13
- }),
14
- environment: Joi.string(),
15
- ninetailedPlugins: Joi.array(),
16
- });
1
+ import require$$0 from 'path';
2
+
3
+ const pluginOptionsSchema = ({
4
+ Joi
5
+ }) => {
6
+ return Joi.object({
7
+ clientId: Joi.string().required().description("Your organizations' client id.").messages({
8
+ 'any.required': '"clientId" needs to be specified. Get your clientId from the dashboard.'
9
+ }),
10
+ environment: Joi.string(),
11
+ ninetailedPlugins: Joi.array()
12
+ });
17
13
  };
18
- exports.pluginOptionsSchema = pluginOptionsSchema;
19
- /**
20
- * Add the webpack config for loading MDX files
14
+ /**
15
+ * Add the webpack config for loading MDX files
21
16
  */
22
- const onCreateWebpackConfig = ({ loaders, actions }, pluginOptions) => {
23
- actions.setWebpackConfig({
24
- resolve: {
25
- fallback: {
26
- path: false,
27
- crypto: false,
28
- },
29
- },
30
- module: {
31
- rules: [
32
- {
33
- test: /ninetailed-plugins\.js$/,
34
- include: __dirname,
35
- use: [
36
- loaders.js(),
37
- {
38
- loader: path_1.default.join(__dirname, `loaders`, `ninetailed-plugins`),
39
- options: {
40
- plugins: pluginOptions.ninetailedPlugins,
41
- },
42
- },
43
- ],
44
- },
45
- ],
46
- },
47
- });
17
+ const onCreateWebpackConfig = ({
18
+ loaders,
19
+ actions
20
+ }, pluginOptions) => {
21
+ actions.setWebpackConfig({
22
+ resolve: {
23
+ fallback: {
24
+ path: false,
25
+ crypto: false
26
+ }
27
+ },
28
+ module: {
29
+ rules: [{
30
+ test: /ninetailed-plugins\.js$/,
31
+ include: __dirname,
32
+ use: [loaders.js(), {
33
+ loader: require$$0.join(__dirname, `loaders`, `ninetailed-plugins`),
34
+ options: {
35
+ plugins: pluginOptions.ninetailedPlugins
36
+ }
37
+ }]
38
+ }]
39
+ }
40
+ });
48
41
  };
49
- exports.onCreateWebpackConfig = onCreateWebpackConfig;
50
- //# sourceMappingURL=gatsby-node.js.map
42
+
43
+ export { onCreateWebpackConfig, pluginOptionsSchema };
@@ -0,0 +1,3 @@
1
+ import { WrapRootElementNodeArgs } from 'gatsby';
2
+ import { PluginOptions } from './plugin-options';
3
+ export declare const wrapRootElement: (args: WrapRootElementNodeArgs, options: PluginOptions) => JSX.Element;
package/gatsby-ssr.js CHANGED
@@ -1,16 +1,20 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.wrapRootElement = void 0;
4
- const tslib_1 = require("tslib");
5
- const react_1 = (0, tslib_1.__importDefault)(require("react"));
6
- const experience_js_react_1 = require("@ninetailed/experience.js-react");
7
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
8
- // @ts-ignore
9
- const ninetailed_plugins_1 = require("./loaders/ninetailed-plugins");
1
+ import React from 'react';
2
+ import { NinetailedProvider } from '@ninetailed/experience.js-react';
3
+ import { n as ninetailedPlugins } from './ninetailed-plugins.js';
4
+ import 'path';
5
+ import 'crypto';
6
+
10
7
  const wrapRootElement = (args, options) => {
11
- const resolvedPlugins = ninetailed_plugins_1.plugins.map(({ plugin, options }) => plugin(options));
12
- const { element } = args;
13
- return (react_1.default.createElement(experience_js_react_1.NinetailedProvider, Object.assign({}, options, { plugins: resolvedPlugins }), element));
8
+ const resolvedPlugins = ninetailedPlugins.plugins.map(({
9
+ plugin,
10
+ options
11
+ }) => plugin(options));
12
+ const {
13
+ element
14
+ } = args;
15
+ return /*#__PURE__*/React.createElement(NinetailedProvider, Object.assign({}, options, {
16
+ plugins: resolvedPlugins
17
+ }), element);
14
18
  };
15
- exports.wrapRootElement = wrapRootElement;
16
- //# sourceMappingURL=gatsby-ssr.js.map
19
+
20
+ export { wrapRootElement };
package/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './src';
package/index.js CHANGED
@@ -1,5 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- (0, tslib_1.__exportStar)(require("./src"), exports);
5
- //# sourceMappingURL=index.js.map
1
+ export { T as Tracker } from './Tracker.js';
2
+ export * from '@ninetailed/experience.js-react';
3
+ import 'react';
4
+ import '@reach/router';