@searchspring/snap-preact 0.25.1 → 0.27.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/dist/cjs/Instantiators/RecommendationInstantiator.d.ts +20 -21
- package/dist/cjs/Instantiators/RecommendationInstantiator.d.ts.map +1 -1
- package/dist/cjs/Instantiators/RecommendationInstantiator.js +75 -50
- package/dist/cjs/Snap.d.ts +17 -15
- package/dist/cjs/Snap.d.ts.map +1 -1
- package/dist/cjs/Snap.js +314 -236
- package/dist/cjs/components/BranchOverride.d.ts +1 -6
- package/dist/cjs/components/BranchOverride.d.ts.map +1 -1
- package/dist/cjs/components/BranchOverride.js +2 -234
- package/dist/cjs/create/index.d.ts +1 -1
- package/dist/cjs/create/index.d.ts.map +1 -1
- package/dist/cjs/create/index.js +2 -2
- package/dist/cjs/getBundleDetails/getBundleDetails.d.ts +7 -0
- package/dist/cjs/getBundleDetails/getBundleDetails.d.ts.map +1 -0
- package/dist/cjs/getBundleDetails/getBundleDetails.js +64 -0
- package/dist/cjs/types.d.ts +1 -0
- package/dist/cjs/types.d.ts.map +1 -1
- package/dist/esm/Instantiators/RecommendationInstantiator.d.ts +20 -21
- package/dist/esm/Instantiators/RecommendationInstantiator.d.ts.map +1 -1
- package/dist/esm/Instantiators/RecommendationInstantiator.js +63 -40
- package/dist/esm/Snap.d.ts +17 -15
- package/dist/esm/Snap.d.ts.map +1 -1
- package/dist/esm/Snap.js +157 -111
- package/dist/esm/components/BranchOverride.d.ts +1 -6
- package/dist/esm/components/BranchOverride.d.ts.map +1 -1
- package/dist/esm/components/BranchOverride.js +1 -172
- package/dist/esm/create/index.d.ts +1 -1
- package/dist/esm/create/index.d.ts.map +1 -1
- package/dist/esm/create/index.js +1 -1
- package/dist/esm/getBundleDetails/getBundleDetails.d.ts +7 -0
- package/dist/esm/getBundleDetails/getBundleDetails.d.ts.map +1 -0
- package/dist/esm/getBundleDetails/getBundleDetails.js +22 -0
- package/dist/esm/types.d.ts +1 -0
- package/dist/esm/types.d.ts.map +1 -1
- package/package.json +13 -12
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import { DomTargeter } from '@searchspring/snap-toolbox';
|
|
2
|
-
import
|
|
2
|
+
import { Client } from '@searchspring/snap-client';
|
|
3
|
+
import { Logger } from '@searchspring/snap-logger';
|
|
4
|
+
import { Tracker } from '@searchspring/snap-tracker';
|
|
5
|
+
import type { ClientConfig, ClientGlobals } from '@searchspring/snap-client';
|
|
3
6
|
import type { UrlTranslatorConfig } from '@searchspring/snap-url-manager';
|
|
4
|
-
import type { Client } from '@searchspring/snap-client';
|
|
5
|
-
import type { Tracker } from '@searchspring/snap-tracker';
|
|
6
7
|
import type { AbstractController, RecommendationController, Attachments, ContextVariables } from '@searchspring/snap-controller';
|
|
7
8
|
import type { Middleware } from '@searchspring/snap-event-manager';
|
|
8
|
-
import type {
|
|
9
|
+
import type { RootComponent } from '../types';
|
|
9
10
|
export declare type RecommendationInstantiatorConfig = {
|
|
11
|
+
client?: {
|
|
12
|
+
globals: ClientGlobals;
|
|
13
|
+
config?: ClientConfig;
|
|
14
|
+
};
|
|
10
15
|
components: {
|
|
11
16
|
[name: string]: () => Promise<RootComponent> | RootComponent;
|
|
12
17
|
};
|
|
@@ -17,35 +22,29 @@ export declare type RecommendationInstantiatorConfig = {
|
|
|
17
22
|
limit?: number;
|
|
18
23
|
} & Attachments;
|
|
19
24
|
selector?: string;
|
|
20
|
-
services?: SnapControllerServices;
|
|
21
25
|
url?: UrlTranslatorConfig;
|
|
22
26
|
context?: ContextVariables;
|
|
23
27
|
};
|
|
24
28
|
export declare type RecommendationInstantiatorServices = {
|
|
25
|
-
client
|
|
26
|
-
logger
|
|
27
|
-
tracker
|
|
29
|
+
client?: Client;
|
|
30
|
+
logger?: Logger;
|
|
31
|
+
tracker?: Tracker;
|
|
28
32
|
};
|
|
29
33
|
export declare class RecommendationInstantiator {
|
|
30
|
-
controllers: {
|
|
31
|
-
[key: string]: RecommendationController;
|
|
32
|
-
};
|
|
33
34
|
client: Client;
|
|
34
35
|
tracker: Tracker;
|
|
35
36
|
logger: Logger;
|
|
37
|
+
controller: {
|
|
38
|
+
[key: string]: RecommendationController;
|
|
39
|
+
};
|
|
36
40
|
config: RecommendationInstantiatorConfig;
|
|
37
41
|
context: ContextVariables;
|
|
38
|
-
uses: Attachments[];
|
|
39
|
-
plugins: {
|
|
40
|
-
(cntrlr: AbstractController): Promise<void>;
|
|
41
|
-
}[];
|
|
42
|
-
middleware: {
|
|
43
|
-
event: string;
|
|
44
|
-
func: Middleware<unknown>[];
|
|
45
|
-
}[];
|
|
46
42
|
targeter: DomTargeter;
|
|
47
|
-
|
|
48
|
-
|
|
43
|
+
private uses;
|
|
44
|
+
private plugins;
|
|
45
|
+
private middleware;
|
|
46
|
+
constructor(config: RecommendationInstantiatorConfig, services?: RecommendationInstantiatorServices, context?: ContextVariables);
|
|
47
|
+
plugin(func: (cntrlr: AbstractController, ...args: any[]) => Promise<void>, ...args: unknown[]): void;
|
|
49
48
|
on<T>(event: string, ...func: Middleware<T>[]): void;
|
|
50
49
|
use(attachments: Attachments): void;
|
|
51
50
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RecommendationInstantiator.d.ts","sourceRoot":"","sources":["../../../src/Instantiators/RecommendationInstantiator.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAc,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"RecommendationInstantiator.d.ts","sourceRoot":"","sources":["../../../src/Instantiators/RecommendationInstantiator.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAc,MAAM,4BAA4B,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAErD,OAAO,KAAK,EAAE,YAAY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;IACzC,OAAO,EAAE,gBAAgB,CAAC;IAC1B,QAAQ,EAAE,WAAW,CAAC;IAE7B,OAAO,CAAC,IAAI,CAAqB;IACjC,OAAO,CAAC,OAAO,CAA2F;IAC1G,OAAO,CAAC,UAAU,CAAwD;gBAE9D,MAAM,EAAE,gCAAgC,EAAE,QAAQ,CAAC,EAAE,kCAAkC,EAAE,OAAO,CAAC,EAAE,gBAAgB;IAoLxH,MAAM,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,kBAAkB,EAAE,GAAG,IAAI,OAAA,KAAK,OAAO,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAI9F,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI;IAIpD,GAAG,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI;CAG1C"}
|
|
@@ -87,29 +87,34 @@ var jsx_runtime_1 = require("preact/jsx-runtime");
|
|
|
87
87
|
var preact_1 = require("preact");
|
|
88
88
|
var deepmerge_1 = __importDefault(require("deepmerge"));
|
|
89
89
|
var snap_toolbox_1 = require("@searchspring/snap-toolbox");
|
|
90
|
+
var snap_client_1 = require("@searchspring/snap-client");
|
|
91
|
+
var snap_logger_1 = require("@searchspring/snap-logger");
|
|
92
|
+
var snap_tracker_1 = require("@searchspring/snap-tracker");
|
|
90
93
|
var RecommendationInstantiator = /** @class */ (function () {
|
|
91
|
-
function RecommendationInstantiator(config,
|
|
92
|
-
var client = _a.client, logger = _a.logger, tracker = _a.tracker;
|
|
94
|
+
function RecommendationInstantiator(config, services, context) {
|
|
93
95
|
var _this = this;
|
|
94
|
-
var _b;
|
|
95
|
-
this.
|
|
96
|
+
var _a, _b, _c, _d;
|
|
97
|
+
this.controller = {};
|
|
96
98
|
this.uses = [];
|
|
97
99
|
this.plugins = [];
|
|
98
100
|
this.middleware = [];
|
|
99
101
|
this.config = config;
|
|
100
|
-
this.context = (0, deepmerge_1.default)(context || {}, config.context || {});
|
|
101
102
|
if (!this.config) {
|
|
102
103
|
throw new Error("Recommendation Instantiator config is required");
|
|
103
104
|
}
|
|
104
|
-
if (!((
|
|
105
|
+
if (!((_a = this.config.config) === null || _a === void 0 ? void 0 : _a.branch)) {
|
|
105
106
|
throw new Error("Recommendation Instantiator config must contain 'branch' property");
|
|
106
107
|
}
|
|
107
|
-
if (!this.config.components || typeof this.config.components != 'object') {
|
|
108
|
+
if (!this.config.components || typeof this.config.components != 'object' || !Object.keys(this.config.components).length) {
|
|
108
109
|
throw new Error("Recommendation Instantiator config must contain 'components' mapping property");
|
|
109
110
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
if ((!(services === null || services === void 0 ? void 0 : services.client) || !(services === null || services === void 0 ? void 0 : services.tracker)) && !((_d = (_c = (_b = this.config) === null || _b === void 0 ? void 0 : _b.client) === null || _c === void 0 ? void 0 : _c.globals) === null || _d === void 0 ? void 0 : _d.siteId)) {
|
|
112
|
+
throw new Error("Recommendation Instantiator config must contain a valid config.client.globals.siteId value");
|
|
113
|
+
}
|
|
114
|
+
this.context = (0, deepmerge_1.default)(context || {}, config.context || {});
|
|
115
|
+
this.client = (services === null || services === void 0 ? void 0 : services.client) || new snap_client_1.Client(this.config.client.globals, this.config.client.config);
|
|
116
|
+
this.tracker = (services === null || services === void 0 ? void 0 : services.tracker) || new snap_tracker_1.Tracker(this.config.client.globals);
|
|
117
|
+
this.logger = (services === null || services === void 0 ? void 0 : services.logger) || new snap_logger_1.Logger('RecommendationInstantiator ');
|
|
113
118
|
var profileCount = {};
|
|
114
119
|
this.targeter = new snap_toolbox_1.DomTargeter([
|
|
115
120
|
{
|
|
@@ -118,27 +123,27 @@ var RecommendationInstantiator = /** @class */ (function () {
|
|
|
118
123
|
action: 'before',
|
|
119
124
|
element: function (target, origElement) {
|
|
120
125
|
var profile = origElement.getAttribute('profile');
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
return recsContainer;
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
127
|
-
_this.logger.warn("'profile' attribute is missing from <script> tag, skipping this profile", origElement);
|
|
128
|
-
}
|
|
126
|
+
var recsContainer = document.createElement('div');
|
|
127
|
+
recsContainer.setAttribute('searchspring-recommend', profile);
|
|
128
|
+
return recsContainer;
|
|
129
129
|
},
|
|
130
130
|
},
|
|
131
131
|
},
|
|
132
132
|
], function (target, injectedElem, elem) { return __awaiter(_this, void 0, void 0, function () {
|
|
133
|
-
var contextGlobals, elemContext, context, shopper, shopperId, product, seed, options,
|
|
134
|
-
var _b, _c, _d
|
|
135
|
-
return __generator(this, function (
|
|
136
|
-
switch (
|
|
133
|
+
var tag, contextGlobals, elemContext, context, shopper, shopperId, product, seed, cart, options, cartContents, cartFuncContents, defaultGlobals, globals, controllerConfig, createRecommendationController, controller, profileVars, component, RecommendationsComponent, _a;
|
|
134
|
+
var _b, _c, _d;
|
|
135
|
+
return __generator(this, function (_e) {
|
|
136
|
+
switch (_e.label) {
|
|
137
137
|
case 0:
|
|
138
|
+
tag = injectedElem.getAttribute('searchspring-recommend');
|
|
139
|
+
if (!tag) {
|
|
140
|
+
this.logger.warn("'profile' attribute is missing from <script> tag, skipping this profile", elem);
|
|
141
|
+
return [2 /*return*/];
|
|
142
|
+
}
|
|
138
143
|
contextGlobals = {};
|
|
139
|
-
elemContext = (0, snap_toolbox_1.getContext)(['shopperId', 'shopper', 'product', 'seed', 'options', 'profile', 'custom'], elem);
|
|
144
|
+
elemContext = (0, snap_toolbox_1.getContext)(['shopperId', 'shopper', 'product', 'seed', 'cart', 'options', 'profile', 'custom'], elem);
|
|
140
145
|
context = (0, deepmerge_1.default)(this.context, elemContext);
|
|
141
|
-
shopper = context.shopper, shopperId = context.shopperId, product = context.product, seed = context.seed, options = context.options;
|
|
146
|
+
shopper = context.shopper, shopperId = context.shopperId, product = context.product, seed = context.seed, cart = context.cart, options = context.options;
|
|
142
147
|
/*
|
|
143
148
|
type instantiatorContext = {
|
|
144
149
|
shopper?: {
|
|
@@ -147,6 +152,7 @@ var RecommendationInstantiator = /** @class */ (function () {
|
|
|
147
152
|
shopperId?: string;
|
|
148
153
|
product?: string;
|
|
149
154
|
seed?: string;
|
|
155
|
+
cart?: string[] | () => string[];
|
|
150
156
|
options?: {
|
|
151
157
|
siteId?: string;
|
|
152
158
|
branch?: string;
|
|
@@ -175,55 +181,70 @@ var RecommendationInstantiator = /** @class */ (function () {
|
|
|
175
181
|
if ((options === null || options === void 0 ? void 0 : options.limit) && Number.isInteger(Number(options === null || options === void 0 ? void 0 : options.limit))) {
|
|
176
182
|
contextGlobals.limits = Number(options === null || options === void 0 ? void 0 : options.limit);
|
|
177
183
|
}
|
|
178
|
-
|
|
184
|
+
if (typeof cart === 'function') {
|
|
185
|
+
try {
|
|
186
|
+
cartFuncContents = cart();
|
|
187
|
+
if (Array.isArray(cartFuncContents)) {
|
|
188
|
+
cartContents = cartFuncContents;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
catch (e) {
|
|
192
|
+
this.logger.warn("Error getting cart contents from function", e);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
else if (Array.isArray(cart)) {
|
|
196
|
+
cartContents = cart;
|
|
197
|
+
}
|
|
198
|
+
if (Array.isArray(cartContents)) {
|
|
199
|
+
this.tracker.cookies.cart.set(cartContents);
|
|
200
|
+
contextGlobals.cart = this.tracker.cookies.cart.get();
|
|
201
|
+
}
|
|
179
202
|
profileCount[tag] = profileCount[tag] + 1 || 1;
|
|
180
203
|
defaultGlobals = {
|
|
181
204
|
limits: 20,
|
|
182
205
|
};
|
|
183
|
-
globals = (0, deepmerge_1.default)((0, deepmerge_1.default)(defaultGlobals, ((_b = this.config.
|
|
184
|
-
controllerConfig = __assign(__assign({ id: "recommend_".concat(tag
|
|
206
|
+
globals = (0, deepmerge_1.default)((0, deepmerge_1.default)(defaultGlobals, ((_b = this.config.client) === null || _b === void 0 ? void 0 : _b.globals) || {}), contextGlobals);
|
|
207
|
+
controllerConfig = __assign(__assign({ id: "recommend_".concat(tag, "_").concat(profileCount[tag] - 1), tag: tag, batched: (_c = options === null || options === void 0 ? void 0 : options.batched) !== null && _c !== void 0 ? _c : true, realtime: Boolean(options === null || options === void 0 ? void 0 : options.realtime) }, this.config.config), { globals: globals });
|
|
185
208
|
return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require('../create/createRecommendationController')); })];
|
|
186
209
|
case 1:
|
|
187
|
-
createRecommendationController = (
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
recs = createRecommendationController({
|
|
191
|
-
url: this.config.url || {},
|
|
210
|
+
createRecommendationController = (_e.sent()).default;
|
|
211
|
+
controller = createRecommendationController({
|
|
212
|
+
url: this.config.url,
|
|
192
213
|
controller: controllerConfig,
|
|
193
214
|
context: context,
|
|
194
|
-
}, { client: client, tracker: tracker });
|
|
195
|
-
this.uses.forEach(function (attachements) { return
|
|
196
|
-
this.plugins.forEach(function (plugin) { return
|
|
197
|
-
this.middleware.forEach(function (middleware) { return
|
|
198
|
-
return [4 /*yield*/,
|
|
215
|
+
}, { client: this.client, tracker: this.tracker });
|
|
216
|
+
this.uses.forEach(function (attachements) { return controller.use(attachements); });
|
|
217
|
+
this.plugins.forEach(function (plugin) { return controller.plugin.apply(controller, __spreadArray([plugin.func], plugin.args, false)); });
|
|
218
|
+
this.middleware.forEach(function (middleware) { return controller.on.apply(controller, __spreadArray([middleware.event], middleware.func, false)); });
|
|
219
|
+
return [4 /*yield*/, controller.search()];
|
|
199
220
|
case 2:
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
this.
|
|
203
|
-
profileVars =
|
|
204
|
-
component = (
|
|
221
|
+
_e.sent();
|
|
222
|
+
controller.addTargeter(this.targeter);
|
|
223
|
+
this.controller[controller.config.id] = controller;
|
|
224
|
+
profileVars = controller.store.profile.display.templateParameters;
|
|
225
|
+
component = (_d = controller.store.profile.display.template) === null || _d === void 0 ? void 0 : _d.component;
|
|
205
226
|
if (!profileVars) {
|
|
206
|
-
|
|
227
|
+
this.logger.error("profile '".concat(tag, "' found on ").concat(elem, " is missing templateParameters!"));
|
|
207
228
|
return [2 /*return*/];
|
|
208
229
|
}
|
|
209
230
|
if (!component) {
|
|
210
|
-
|
|
231
|
+
this.logger.error("profile '".concat(tag, "' found on ").concat(elem, " is missing component!"));
|
|
211
232
|
return [2 /*return*/];
|
|
212
233
|
}
|
|
213
|
-
_a = this.config.components;
|
|
234
|
+
_a = this.config.components[component];
|
|
214
235
|
if (!_a) return [3 /*break*/, 4];
|
|
215
236
|
return [4 /*yield*/, this.config.components[component]()];
|
|
216
237
|
case 3:
|
|
217
|
-
_a = (
|
|
218
|
-
|
|
238
|
+
_a = (_e.sent());
|
|
239
|
+
_e.label = 4;
|
|
219
240
|
case 4:
|
|
220
241
|
RecommendationsComponent = _a;
|
|
221
242
|
if (!RecommendationsComponent) {
|
|
222
|
-
|
|
243
|
+
this.logger.error("profile '".concat(tag, "' found on ").concat(elem, " is expecting component mapping for '").concat(component, "' - verify instantiator config."));
|
|
223
244
|
return [2 /*return*/];
|
|
224
245
|
}
|
|
225
246
|
setTimeout(function () {
|
|
226
|
-
(0, preact_1.render)((0, jsx_runtime_1.jsx)(RecommendationsComponent, { controller:
|
|
247
|
+
(0, preact_1.render)((0, jsx_runtime_1.jsx)(RecommendationsComponent, { controller: controller }), injectedElem);
|
|
227
248
|
});
|
|
228
249
|
return [2 /*return*/];
|
|
229
250
|
}
|
|
@@ -231,7 +252,11 @@ var RecommendationInstantiator = /** @class */ (function () {
|
|
|
231
252
|
}); });
|
|
232
253
|
}
|
|
233
254
|
RecommendationInstantiator.prototype.plugin = function (func) {
|
|
234
|
-
|
|
255
|
+
var args = [];
|
|
256
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
257
|
+
args[_i - 1] = arguments[_i];
|
|
258
|
+
}
|
|
259
|
+
this.plugins.push({ func: func, args: args });
|
|
235
260
|
};
|
|
236
261
|
RecommendationInstantiator.prototype.on = function (event) {
|
|
237
262
|
var func = [];
|
package/dist/cjs/Snap.d.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { Client } from '@searchspring/snap-client';
|
|
2
2
|
import { Logger } from '@searchspring/snap-logger';
|
|
3
3
|
import { Tracker } from '@searchspring/snap-tracker';
|
|
4
|
+
import { ControllerTypes } from '@searchspring/snap-controller';
|
|
4
5
|
import type { ClientConfig, ClientGlobals } from '@searchspring/snap-client';
|
|
5
6
|
import type { AbstractController, SearchController, AutocompleteController, FinderController, RecommendationController, SearchControllerConfig, AutocompleteControllerConfig, FinderControllerConfig, RecommendationControllerConfig, ControllerConfigs, ContextVariables } from '@searchspring/snap-controller';
|
|
6
7
|
import type { Target, OnTarget } from '@searchspring/snap-toolbox';
|
|
7
8
|
import type { UrlTranslatorConfig } from '@searchspring/snap-url-manager';
|
|
8
9
|
import { RecommendationInstantiator, RecommendationInstantiatorConfig } from './Instantiators/RecommendationInstantiator';
|
|
9
10
|
import type { SnapControllerServices, RootComponent } from './types';
|
|
11
|
+
export declare const BRANCH_COOKIE = "ssBranch";
|
|
12
|
+
export declare const SS_DEV_COOKIE = "ssDev";
|
|
10
13
|
declare type ExtendedTarget = Target & {
|
|
11
14
|
name?: string;
|
|
12
15
|
controller?: AbstractController;
|
|
@@ -19,7 +22,7 @@ declare type ExtendedTarget = Target & {
|
|
|
19
22
|
export declare type SnapConfig = {
|
|
20
23
|
context?: ContextVariables;
|
|
21
24
|
url?: UrlTranslatorConfig;
|
|
22
|
-
client
|
|
25
|
+
client?: {
|
|
23
26
|
globals: ClientGlobals;
|
|
24
27
|
config?: ClientConfig;
|
|
25
28
|
};
|
|
@@ -36,7 +39,7 @@ export declare type SnapConfig = {
|
|
|
36
39
|
}[];
|
|
37
40
|
autocomplete?: {
|
|
38
41
|
config: AutocompleteControllerConfig;
|
|
39
|
-
targeters
|
|
42
|
+
targeters?: ExtendedTarget[];
|
|
40
43
|
services?: SnapControllerServices;
|
|
41
44
|
url?: UrlTranslatorConfig;
|
|
42
45
|
context?: ContextVariables;
|
|
@@ -57,13 +60,12 @@ export declare type SnapConfig = {
|
|
|
57
60
|
}[];
|
|
58
61
|
};
|
|
59
62
|
};
|
|
60
|
-
declare type
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
63
|
+
declare type SnapServices = {
|
|
64
|
+
client?: Client;
|
|
65
|
+
tracker?: Tracker;
|
|
66
|
+
logger?: Logger;
|
|
67
|
+
};
|
|
68
|
+
declare type Controllers = SearchController | AutocompleteController | FinderController | RecommendationController;
|
|
67
69
|
export declare class Snap {
|
|
68
70
|
config: SnapConfig;
|
|
69
71
|
logger: Logger;
|
|
@@ -71,19 +73,19 @@ export declare class Snap {
|
|
|
71
73
|
tracker: Tracker;
|
|
72
74
|
context: ContextVariables;
|
|
73
75
|
_controllerPromises: {
|
|
74
|
-
[controllerConfigId: string]: Promise<
|
|
76
|
+
[controllerConfigId: string]: Promise<Controllers>;
|
|
75
77
|
};
|
|
76
78
|
controllers: {
|
|
77
|
-
[controllerConfigId: string]:
|
|
79
|
+
[controllerConfigId: string]: Controllers;
|
|
78
80
|
};
|
|
79
81
|
_instantiatorPromises: {
|
|
80
82
|
[instantiatorId: string]: Promise<RecommendationInstantiator>;
|
|
81
83
|
};
|
|
82
84
|
getInstantiator: (id: string) => Promise<RecommendationInstantiator>;
|
|
83
|
-
getController: (id: string) => Promise<
|
|
84
|
-
getControllers: (...controllerIds: string[]) => Promise<
|
|
85
|
-
createController: (type:
|
|
86
|
-
constructor(config: SnapConfig);
|
|
85
|
+
getController: (id: string) => Promise<Controllers>;
|
|
86
|
+
getControllers: (...controllerIds: string[]) => Promise<Controllers[]>;
|
|
87
|
+
createController: (type: keyof typeof ControllerTypes, config: ControllerConfigs, services?: SnapControllerServices, urlConfig?: UrlTranslatorConfig, context?: ContextVariables, callback?: (value?: Controllers | PromiseLike<Controllers>) => void | Promise<void>) => Promise<Controllers>;
|
|
88
|
+
constructor(config: SnapConfig, services?: SnapServices);
|
|
87
89
|
}
|
|
88
90
|
export {};
|
|
89
91
|
//# sourceMappingURL=Snap.d.ts.map
|
package/dist/cjs/Snap.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Snap.d.ts","sourceRoot":"","sources":["../../src/Snap.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACnD,OAAO,EAAE,MAAM,EAAW,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"Snap.d.ts","sourceRoot":"","sources":["../../src/Snap.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACnD,OAAO,EAAE,MAAM,EAAW,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAGrD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC7E,OAAO,KAAK,EACX,kBAAkB,EAClB,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,EAChB,wBAAwB,EACxB,sBAAsB,EACtB,4BAA4B,EAC5B,sBAAsB,EACtB,8BAA8B,EAC9B,iBAAiB,EACjB,gBAAgB,EAChB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAG1E,OAAO,EAAE,0BAA0B,EAAE,gCAAgC,EAAE,MAAM,4CAA4C,CAAC;AAC1H,OAAO,KAAK,EAAE,sBAAsB,EAA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