@ninetailed/experience.js-gatsby 4.2.0-beta.9 → 4.2.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/_tslib.js +41 -0
- package/gatsby-browser.js +2 -28
- package/gatsby-node.d.ts +2 -1
- package/gatsby-node.js +67 -0
- package/package.json +3 -3
package/_tslib.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/******************************************************************************
|
|
4
|
+
Copyright (c) Microsoft Corporation.
|
|
5
|
+
|
|
6
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
7
|
+
purpose with or without fee is hereby granted.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
10
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
11
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
12
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
13
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
14
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
15
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
16
|
+
***************************************************************************** */
|
|
17
|
+
|
|
18
|
+
function __rest(s, e) {
|
|
19
|
+
var t = {};
|
|
20
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
21
|
+
t[p] = s[p];
|
|
22
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
23
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
24
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
25
|
+
t[p[i]] = s[p[i]];
|
|
26
|
+
}
|
|
27
|
+
return t;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
31
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
32
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
33
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
34
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
35
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
36
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
exports.__awaiter = __awaiter;
|
|
41
|
+
exports.__rest = __rest;
|
package/gatsby-browser.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var _tslib = require('./_tslib.js');
|
|
5
6
|
var React = require('react');
|
|
6
7
|
var experience_js = require('@ninetailed/experience.js');
|
|
7
8
|
var experience_jsReact = require('@ninetailed/experience.js-react');
|
|
@@ -15,39 +16,12 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
15
16
|
|
|
16
17
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
17
18
|
|
|
18
|
-
/******************************************************************************
|
|
19
|
-
Copyright (c) Microsoft Corporation.
|
|
20
|
-
|
|
21
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
22
|
-
purpose with or without fee is hereby granted.
|
|
23
|
-
|
|
24
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
25
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
26
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
27
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
28
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
29
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
30
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
31
|
-
***************************************************************************** */
|
|
32
|
-
|
|
33
|
-
function __rest(s, e) {
|
|
34
|
-
var t = {};
|
|
35
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
36
|
-
t[p] = s[p];
|
|
37
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
38
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
39
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
40
|
-
t[p[i]] = s[p[i]];
|
|
41
|
-
}
|
|
42
|
-
return t;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
19
|
let ninetailed;
|
|
46
20
|
const WrapRootElement = _a => {
|
|
47
21
|
var {
|
|
48
22
|
children
|
|
49
23
|
} = _a,
|
|
50
|
-
options = __rest(_a, ["children"]);
|
|
24
|
+
options = _tslib.__rest(_a, ["children"]);
|
|
51
25
|
if (!ninetailed) {
|
|
52
26
|
const resolvedPlugins = loaders_ninetailedPlugins.plugins.map(({
|
|
53
27
|
PluginCtor,
|
package/gatsby-node.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PluginOptionsSchemaArgs, CreateWebpackConfigArgs } from 'gatsby';
|
|
1
|
+
import { PluginOptionsSchemaArgs, CreateWebpackConfigArgs, CreatePagesArgs } from 'gatsby';
|
|
2
2
|
import { ObjectSchema } from 'gatsby-plugin-utils';
|
|
3
3
|
import { PluginOptions } from './plugin-options';
|
|
4
4
|
export declare const pluginOptionsSchema: ({ Joi, }: PluginOptionsSchemaArgs) => ObjectSchema<any>;
|
|
@@ -6,3 +6,4 @@ export declare const pluginOptionsSchema: ({ Joi, }: PluginOptionsSchemaArgs) =>
|
|
|
6
6
|
* Add the webpack config for loading MDX files
|
|
7
7
|
*/
|
|
8
8
|
export declare const onCreateWebpackConfig: ({ loaders, actions }: CreateWebpackConfigArgs, pluginOptions: PluginOptions) => void;
|
|
9
|
+
export declare const createPages: ({ actions, store, graphql, }: CreatePagesArgs) => Promise<void>;
|
package/gatsby-node.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var _tslib = require('./_tslib.js');
|
|
5
6
|
var require$$0 = require('path');
|
|
6
7
|
|
|
7
8
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -47,6 +48,72 @@ const onCreateWebpackConfig = ({
|
|
|
47
48
|
}
|
|
48
49
|
});
|
|
49
50
|
};
|
|
51
|
+
const createPages = ({
|
|
52
|
+
actions,
|
|
53
|
+
store,
|
|
54
|
+
graphql
|
|
55
|
+
}) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
56
|
+
const ninetailedGatsbyPlugin = store.getState().flattenedPlugins.find(plugin => plugin.name === '@ninetailed/experience.js-gatsby');
|
|
57
|
+
if (ninetailedGatsbyPlugin) {
|
|
58
|
+
const {
|
|
59
|
+
setPluginStatus
|
|
60
|
+
} = actions;
|
|
61
|
+
const ninetailedPreviewPlugin = ninetailedGatsbyPlugin.pluginOptions.ninetailedPlugins.find(plugin => plugin.name === '@ninetailed/experience.js-plugin-preview');
|
|
62
|
+
if (!ninetailedPreviewPlugin.options.customOptions) {
|
|
63
|
+
throw new Error('CustomOptions not found. CustomOptions are mandatory and need to be set in the preview plugin options.');
|
|
64
|
+
}
|
|
65
|
+
const {
|
|
66
|
+
audienceQuery,
|
|
67
|
+
experienceQuery,
|
|
68
|
+
audienceMapper,
|
|
69
|
+
experienceMapper
|
|
70
|
+
} = ninetailedPreviewPlugin.options.customOptions;
|
|
71
|
+
const audienceOptionsSet = audienceQuery && audienceMapper;
|
|
72
|
+
const experienceOptionsSet = experienceQuery && experienceMapper;
|
|
73
|
+
const passThroughReturn = {
|
|
74
|
+
errors: null,
|
|
75
|
+
data: null
|
|
76
|
+
};
|
|
77
|
+
if (!audienceOptionsSet) {
|
|
78
|
+
console.warn('No audience query or mapper found. Please provide both to process audience data.');
|
|
79
|
+
}
|
|
80
|
+
const {
|
|
81
|
+
errors: audienceErrors,
|
|
82
|
+
data: audienceData
|
|
83
|
+
} = audienceOptionsSet ? yield graphql(audienceQuery) : passThroughReturn;
|
|
84
|
+
if (!experienceOptionsSet) {
|
|
85
|
+
console.warn('No experience query or mapper found. Please provide both to process experience data.');
|
|
86
|
+
}
|
|
87
|
+
const {
|
|
88
|
+
errors: experienceErrors,
|
|
89
|
+
data: experienceData
|
|
90
|
+
} = experienceOptionsSet ? yield graphql(experienceQuery) : passThroughReturn;
|
|
91
|
+
if (audienceErrors) {
|
|
92
|
+
throw new Error('Failed to query audience data. Check query configuration or data retrieval by the source plugin.');
|
|
93
|
+
}
|
|
94
|
+
const audiences = audienceOptionsSet ? audienceMapper(audienceData) : [];
|
|
95
|
+
if (experienceErrors) {
|
|
96
|
+
throw new Error('Failed to query experience data. Check query configuration or data retrieval by the source plugin.');
|
|
97
|
+
}
|
|
98
|
+
const experiences = experienceOptionsSet ? experienceMapper(experienceData) : [];
|
|
99
|
+
const ninetailedPreviewPluginOverride = Object.assign(Object.assign({}, ninetailedPreviewPlugin), {
|
|
100
|
+
options: Object.assign(Object.assign({}, ninetailedPreviewPlugin.options), {
|
|
101
|
+
audiences,
|
|
102
|
+
experiences
|
|
103
|
+
})
|
|
104
|
+
});
|
|
105
|
+
const ninetailedPluginsOverwrite = ninetailedGatsbyPlugin.pluginOptions.ninetailedPlugins.map(plugin => {
|
|
106
|
+
return plugin === ninetailedPreviewPlugin ? ninetailedPreviewPluginOverride : plugin;
|
|
107
|
+
});
|
|
108
|
+
ninetailedGatsbyPlugin.pluginOptions = Object.assign(Object.assign({}, ninetailedGatsbyPlugin.pluginOptions), {
|
|
109
|
+
ninetailedPlugins: ninetailedPluginsOverwrite
|
|
110
|
+
});
|
|
111
|
+
setPluginStatus({
|
|
112
|
+
pluginOptions: ninetailedGatsbyPlugin.pluginOptions
|
|
113
|
+
}, ninetailedGatsbyPlugin);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
50
116
|
|
|
117
|
+
exports.createPages = createPages;
|
|
51
118
|
exports.onCreateWebpackConfig = onCreateWebpackConfig;
|
|
52
119
|
exports.pluginOptionsSchema = pluginOptionsSchema;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ninetailed/experience.js-gatsby",
|
|
3
|
-
"version": "4.2.0
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"gatsby",
|
|
6
6
|
"gatsby-plugin",
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"type": "commonjs",
|
|
19
19
|
"types": "./index.d.ts",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@ninetailed/experience.js": "4.2.0
|
|
22
|
-
"@ninetailed/experience.js-react": "4.2.0
|
|
21
|
+
"@ninetailed/experience.js": "4.2.0",
|
|
22
|
+
"@ninetailed/experience.js-react": "4.2.0",
|
|
23
23
|
"gatsby-plugin-utils": "3.19.0"
|
|
24
24
|
}
|
|
25
25
|
}
|