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