@ninetailed/experience.js-gatsby 4.2.6-beta.0 → 4.2.6
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/gatsby-browser.js +10 -7
- package/gatsby-node.js +20 -16
- package/package.json +3 -3
- package/plugin-options.d.ts +8 -6
- package/utils/serialize.d.ts +2 -2
package/gatsby-browser.js
CHANGED
|
@@ -36,6 +36,9 @@ const deserializePluginOptionFunctions = options => {
|
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
let ninetailed;
|
|
39
|
+
const isSerializedPreviewPlugin = options => {
|
|
40
|
+
return !!(options.customOptions && options.serializedFunctionNames && options.customOptions.serializedFunctionNames);
|
|
41
|
+
};
|
|
39
42
|
const WrapRootElement = _a => {
|
|
40
43
|
var {
|
|
41
44
|
children
|
|
@@ -46,16 +49,16 @@ const WrapRootElement = _a => {
|
|
|
46
49
|
PluginCtor,
|
|
47
50
|
options
|
|
48
51
|
}) => {
|
|
49
|
-
if (
|
|
50
|
-
|
|
52
|
+
if (isSerializedPreviewPlugin(options)) {
|
|
53
|
+
const updatedOptions = Object.assign(Object.assign(Object.assign({}, options), deserializePluginOptionFunctions(options)), {
|
|
54
|
+
customOptions: Object.assign(Object.assign({}, options.customOptions), deserializePluginOptionFunctions(options.customOptions))
|
|
55
|
+
});
|
|
56
|
+
return new PluginCtor(updatedOptions);
|
|
51
57
|
}
|
|
52
|
-
if (options
|
|
58
|
+
if (options) {
|
|
53
59
|
return new PluginCtor(options);
|
|
54
60
|
}
|
|
55
|
-
|
|
56
|
-
customOptions: Object.assign(Object.assign({}, options.customOptions), deserializePluginOptionFunctions(options.customOptions))
|
|
57
|
-
});
|
|
58
|
-
return new PluginCtor(updatedOptions);
|
|
61
|
+
return new PluginCtor();
|
|
59
62
|
});
|
|
60
63
|
const {
|
|
61
64
|
clientId,
|
package/gatsby-node.js
CHANGED
|
@@ -145,27 +145,31 @@ const createPages = ({
|
|
|
145
145
|
}
|
|
146
146
|
const experiences = experienceOptionsSet ? experienceMapper(experienceData) : [];
|
|
147
147
|
const ninetailedPluginsOverride = ninetailedGatsbyPlugin.pluginOptions.ninetailedPlugins.map(plugin => {
|
|
148
|
-
var _a;
|
|
149
148
|
const pluginOptions = plugin.options;
|
|
150
149
|
if (!pluginOptions) {
|
|
151
150
|
return plugin;
|
|
152
151
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
serializedFunctionNames:
|
|
152
|
+
if (plugin.name === '@ninetailed/experience.js-plugin-preview') {
|
|
153
|
+
const _pluginOptions = plugin.options;
|
|
154
|
+
const {
|
|
155
|
+
serializedOptionFunctions,
|
|
156
|
+
serializedOptionFunctionNames,
|
|
157
|
+
serializedCustomOptionFunctions,
|
|
158
|
+
serializedCustomOptionFunctionNames
|
|
159
|
+
} = serializePluginOptionFunctions(_pluginOptions);
|
|
160
|
+
return Object.assign(Object.assign({}, plugin), {
|
|
161
|
+
options: Object.assign(Object.assign(Object.assign({}, _pluginOptions), serializedOptionFunctions), {
|
|
162
|
+
serializedFunctionNames: serializedOptionFunctionNames,
|
|
163
|
+
customOptions: Object.assign(Object.assign(Object.assign({}, _pluginOptions.customOptions), serializedCustomOptionFunctions), {
|
|
164
|
+
serializedFunctionNames: serializedCustomOptionFunctionNames
|
|
165
|
+
}),
|
|
166
|
+
audiences,
|
|
167
|
+
experiences
|
|
164
168
|
})
|
|
165
|
-
})
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
})
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
return Object.assign(Object.assign({}, plugin), {
|
|
172
|
+
options: Object.assign({}, plugin.options)
|
|
169
173
|
});
|
|
170
174
|
});
|
|
171
175
|
ninetailedGatsbyPlugin.pluginOptions = Object.assign(Object.assign({}, ninetailedGatsbyPlugin.pluginOptions), {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ninetailed/experience.js-gatsby",
|
|
3
|
-
"version": "4.2.6
|
|
3
|
+
"version": "4.2.6",
|
|
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.6
|
|
22
|
-
"@ninetailed/experience.js-react": "4.2.6
|
|
21
|
+
"@ninetailed/experience.js": "4.2.6",
|
|
22
|
+
"@ninetailed/experience.js-react": "4.2.6",
|
|
23
23
|
"gatsby-plugin-utils": "3.19.0"
|
|
24
24
|
}
|
|
25
25
|
}
|
package/plugin-options.d.ts
CHANGED
|
@@ -6,21 +6,23 @@ export type PluginOptions = GatsbyPluginOptions & NinetailedProviderInstantiatio
|
|
|
6
6
|
options: unknown;
|
|
7
7
|
}[];
|
|
8
8
|
};
|
|
9
|
-
export type NinetailedPluginOptions = Record<string, unknown> & {
|
|
10
|
-
customOptions: Record<string, unknown>;
|
|
11
|
-
};
|
|
12
9
|
export type SerializedFunctions = {
|
|
13
10
|
serializedFunctionNames: string[];
|
|
14
11
|
};
|
|
15
|
-
type
|
|
12
|
+
type PreviewPluginCustomOptions = {
|
|
16
13
|
audienceQuery: string;
|
|
17
14
|
audienceMapper: string;
|
|
18
15
|
experienceQuery: string;
|
|
19
16
|
experienceMapper: string;
|
|
20
17
|
};
|
|
21
|
-
export type
|
|
22
|
-
customOptions:
|
|
18
|
+
export type NinetailedPreviewPluginOptions = Record<string, unknown> & {
|
|
19
|
+
customOptions: PreviewPluginCustomOptions & SerializedFunctions;
|
|
20
|
+
};
|
|
21
|
+
export type NinetailedPluginOptions = Record<string, unknown> | NinetailedPreviewPluginOptions;
|
|
22
|
+
export type ResolvedPreviewPluginOptions = Record<string, unknown> & SerializedFunctions & {
|
|
23
|
+
customOptions: PreviewPluginCustomOptions & SerializedFunctions;
|
|
23
24
|
};
|
|
25
|
+
export type ResolvedPluginOptions = Record<string, unknown> | ResolvedPreviewPluginOptions;
|
|
24
26
|
export type ResolvedPlugin = {
|
|
25
27
|
PluginCtor: any;
|
|
26
28
|
options?: ResolvedPluginOptions;
|
package/utils/serialize.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const serializePluginOptionFunctions: (pluginOptions:
|
|
1
|
+
import { NinetailedPreviewPluginOptions } from '../plugin-options';
|
|
2
|
+
export declare const serializePluginOptionFunctions: (pluginOptions: NinetailedPreviewPluginOptions) => {
|
|
3
3
|
serializedOptionFunctions: {};
|
|
4
4
|
serializedOptionFunctionNames: string[];
|
|
5
5
|
serializedCustomOptionFunctions: {};
|