@telia-ace/knowledge-widget-core 1.0.13 → 1.0.14

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/index.js CHANGED
@@ -1,122 +1,100 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
- var __hasOwnProp = Object.prototype.hasOwnProperty;
4
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
- var __spreadValues = (a, b) => {
7
- for (var prop in b || (b = {}))
8
- if (__hasOwnProp.call(b, prop))
9
- __defNormalProp(a, prop, b[prop]);
10
- if (__getOwnPropSymbols)
11
- for (var prop of __getOwnPropSymbols(b)) {
12
- if (__propIsEnum.call(b, prop))
13
- __defNormalProp(a, prop, b[prop]);
14
- }
15
- return a;
1
+ var p = Object.defineProperty;
2
+ var c = Object.getOwnPropertySymbols;
3
+ var f = Object.prototype.hasOwnProperty, d = Object.prototype.propertyIsEnumerable;
4
+ var u = (t, n, e) => n in t ? p(t, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[n] = e, s = (t, n) => {
5
+ for (var e in n || (n = {}))
6
+ f.call(n, e) && u(t, e, n[e]);
7
+ if (c)
8
+ for (var e of c(n))
9
+ d.call(n, e) && u(t, e, n[e]);
10
+ return t;
16
11
  };
17
12
  export * from "@telia-ace/widget-core";
18
- import { bootstrapImplementation, ConfigurationApi } from "@webprovisions/bootstrapping";
19
- export { supportBootstrapping } from "@webprovisions/bootstrapping";
20
- import { selectImplementations, version as version$1, Environment, Implementation as Implementation$1, Plugin as Plugin$1, WidgetType as WidgetType$1 } from "@webprovisions/platform";
21
- export { Widget, destroyWidget as destroy } from "@webprovisions/platform";
22
- var bootstrap = (implementation, configure, options = {}) => {
23
- return bootstrapImplementation(implementation, implementation.bindings, () => {
24
- const runtimeConfigurationHandlers = implementation.container.get("$runtimecfg").map((cfgHandlerArgs) => {
25
- const fnOrSelector = cfgHandlerArgs[0];
26
- if (typeof fnOrSelector === "function") {
27
- return fnOrSelector;
28
- }
29
- if (selectImplementations(fnOrSelector)(implementation)) {
30
- return cfgHandlerArgs[1];
31
- }
32
- }).filter((handler) => !!handler);
33
- return (configure ? [configure] : []).concat(runtimeConfigurationHandlers);
34
- }, options.rootElementResolver || (() => document.body));
35
- };
36
- var DialogItemType = /* @__PURE__ */ ((DialogItemType2) => {
37
- DialogItemType2["guide"] = "guide";
38
- DialogItemType2["link"] = "link";
39
- DialogItemType2["default"] = "default";
40
- return DialogItemType2;
41
- })(DialogItemType || {});
42
- var PickerTypes = /* @__PURE__ */ ((PickerTypes2) => {
43
- PickerTypes2["MODAL"] = "modal";
44
- PickerTypes2["DRAWER"] = "drawer";
45
- PickerTypes2["DROPDOWN"] = "dropdown";
46
- PickerTypes2["NONE"] = "none";
47
- return PickerTypes2;
48
- })(PickerTypes || {});
49
- var version = "#____version____#";
50
- const _Humany = class extends Environment {
51
- constructor(name, configurationApiExtensions = []) {
52
- super(name, configurationApiExtensions, {
53
- transformPluginSettings: (settings, name2, container) => {
54
- const $settings = container.get("$settings");
55
- const configPluginSettings = $settings.plugins && name2 ? $settings.plugins[name2] || {} : {};
56
- return __spreadValues(__spreadValues({}, configPluginSettings), settings);
13
+ import { bootstrapImplementation as g, ConfigurationApi as l } from "@webprovisions/bootstrapping";
14
+ import { supportBootstrapping as B } from "@webprovisions/bootstrapping";
15
+ import { selectImplementations as h, version as v, Environment as $, Implementation as x, Plugin as _, WidgetType as E } from "@webprovisions/platform";
16
+ import { Widget as L, destroyWidget as M } from "@webprovisions/platform";
17
+ const C = (t, n, e = {}) => g(t, t.bindings, () => {
18
+ const r = t.container.get("$runtimecfg").map((i) => {
19
+ const o = i[0];
20
+ if (typeof o == "function")
21
+ return o;
22
+ if (h(o)(t))
23
+ return i[1];
24
+ }).filter((i) => !!i);
25
+ return (n ? [n] : []).concat(r);
26
+ }, e.rootElementResolver || (() => document.body));
27
+ var I = /* @__PURE__ */ ((t) => (t.guide = "guide", t.link = "link", t.default = "default", t))(I || {}), R = /* @__PURE__ */ ((t) => (t.MODAL = "modal", t.DRAWER = "drawer", t.DROPDOWN = "dropdown", t.NONE = "none", t))(R || {});
28
+ const W = "#____version____#", a = class extends $ {
29
+ constructor(t, n = []) {
30
+ super(t, n, {
31
+ transformPluginSettings: (e, r, i) => {
32
+ const o = i.get("$settings"), m = o.plugins && r ? o.plugins[r] || {} : {};
33
+ return s(s({}, m), e);
57
34
  }
58
35
  });
59
36
  }
60
- createImplementation(configuration) {
61
- const implementation = super.createImplementation(configuration);
62
- implementation.bindings = configuration.bindings;
63
- return implementation;
37
+ createImplementation(t) {
38
+ const n = super.createImplementation(t);
39
+ return n.bindings = t.bindings, n;
64
40
  }
65
- navigate(selector, route, params) {
66
- this.widgets.query(selector).forEach((widget) => widget.invoke("navigate", { route, params }));
41
+ navigate(t, n, e) {
42
+ this.widgets.query(t).forEach((r) => r.invoke("navigate", { route: n, params: e }));
67
43
  }
68
- static create(configuration = {}) {
69
- const configurationApiExtensions = [ConfigurationApi].concat(configuration.configurationApiExtensions || []);
70
- return new _Humany("humany", configurationApiExtensions);
44
+ static create(t = {}) {
45
+ const n = [l].concat(t.configurationApiExtensions || []);
46
+ return new a("humany", n);
71
47
  }
72
- static createFromGlobal(globalHumany, configuration = {}) {
73
- if (this.isRuntime(globalHumany)) {
74
- globalHumany.patch(configuration);
75
- return globalHumany;
76
- }
77
- const runtimeConfiguration = [];
78
- const tempRuntimeConfiguration = globalHumany && globalHumany._c;
79
- if (tempRuntimeConfiguration) {
80
- tempRuntimeConfiguration.forEach((args) => runtimeConfiguration.push(args));
81
- }
82
- const runtime = this.create(configuration);
83
- runtime.container.register("$runtimecfg", runtimeConfiguration);
84
- return runtime;
48
+ static createFromGlobal(t, n = {}) {
49
+ if (this.isRuntime(t))
50
+ return t.patch(n), t;
51
+ const e = [], r = t && t._c;
52
+ r && r.forEach((o) => e.push(o));
53
+ const i = this.create(n);
54
+ return i.container.register("$runtimecfg", e), i;
85
55
  }
86
- static isRuntime(obj) {
87
- if (obj && typeof obj === "object" && obj.container && typeof obj.container.get === "function" && obj.container.get("$environment") === obj && obj.container.owner === obj) {
88
- return true;
89
- }
90
- return false;
56
+ static isRuntime(t) {
57
+ return !!(t && typeof t == "object" && t.container && typeof t.container.get == "function" && t.container.get("$environment") === t && t.container.owner === t);
91
58
  }
92
59
  };
93
- let Humany = _Humany;
94
- Humany.version = `${version} (${version$1})`;
95
- class Implementation extends Implementation$1 {
60
+ let w = a;
61
+ w.version = `${W} (${v})`;
62
+ class N extends x {
96
63
  constructor() {
97
- super(...arguments);
98
- this.bindings = [];
64
+ super(...arguments), this.bindings = [];
99
65
  }
100
66
  }
101
- const loadImplementation = (humany, url) => {
102
- return fetch(url + "/config.json").then((response) => response.json()).then((json) => json.implementation).then((configuration) => humany.createImplementation(configuration));
103
- };
104
- class Plugin extends Plugin$1 {
105
- constructor(container, settings) {
106
- super(container, settings);
67
+ const P = (t, n) => fetch(n + "/config.json").then((e) => e.json()).then((e) => e.implementation).then((e) => t.createImplementation(e));
68
+ class S extends _ {
69
+ constructor(n, e) {
70
+ super(n, e);
107
71
  }
108
72
  }
109
- const verifyAuth = (host, widgetName) => {
110
- const url = `${host}${widgetName}/interfaceauthorized`;
111
- return fetch(url, {
73
+ const D = (t, n) => {
74
+ const e = `${t}${n}/interfaceauthorized`;
75
+ return fetch(e, {
112
76
  method: "GET",
113
77
  credentials: "include"
114
- }).then((response) => response.status === 200 && response.ok);
78
+ }).then((r) => r.status === 200 && r.ok);
115
79
  };
116
- class WidgetType extends WidgetType$1 {
117
- constructor(container) {
118
- super(container);
80
+ class G extends E {
81
+ constructor(n) {
82
+ super(n);
119
83
  }
120
84
  }
121
- export { DialogItemType, Humany, Implementation, PickerTypes, Plugin, WidgetType, bootstrap, loadImplementation, verifyAuth, version };
85
+ export {
86
+ I as DialogItemType,
87
+ w as Humany,
88
+ N as Implementation,
89
+ R as PickerTypes,
90
+ S as Plugin,
91
+ L as Widget,
92
+ G as WidgetType,
93
+ C as bootstrap,
94
+ M as destroy,
95
+ P as loadImplementation,
96
+ B as supportBootstrapping,
97
+ D as verifyAuth,
98
+ W as version
99
+ };
122
100
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/bootstrap.ts","../src/data-types.ts","../src/version.ts","../src/humany.ts","../src/implementation.ts","../src/load-implementation.ts","../src/plugin.ts","../src/verify-auth.ts","../src/widget-type.ts"],"sourcesContent":["import { bootstrapImplementation, BootstrappedImplementation } from '@webprovisions/bootstrapping';\r\nimport { ConfigureCallback, selectImplementations } from '@webprovisions/platform';\r\nimport Implementation from './implementation';\r\n\r\nexport type BootstrapOptions = {\r\n /**\r\n * Resolver function for the root element to base the bootstrapping on.\r\n */\r\n rootElementResolver?: () => HTMLElement;\r\n};\r\n\r\n/**\r\n * Bootstraps an `Implementation` by scanning trigger elements and attaches them to\r\n * their corresponding widgets.\r\n */\r\nexport default (\r\n implementation: Implementation,\r\n configure: ConfigureCallback,\r\n options: BootstrapOptions = {}\r\n): Promise<BootstrappedImplementation> => {\r\n return bootstrapImplementation(\r\n implementation as any,\r\n implementation.bindings,\r\n () => {\r\n const runtimeConfigurationHandlers = implementation.container\r\n .get('$runtimecfg')\r\n .map((cfgHandlerArgs: any) => {\r\n const fnOrSelector = cfgHandlerArgs[0];\r\n if (typeof fnOrSelector === 'function') {\r\n return fnOrSelector;\r\n }\r\n if (selectImplementations(fnOrSelector)(implementation)) {\r\n return cfgHandlerArgs[1];\r\n }\r\n })\r\n .filter((handler: any) => !!handler);\r\n return (configure ? [configure] : []).concat(runtimeConfigurationHandlers);\r\n },\r\n options.rootElementResolver || (() => document.body)\r\n );\r\n};\r\n","export type Symbol = {\r\n type: 'Uri' | 'Svg' | 'FontAwesome' | 'Text' | string;\r\n content: string;\r\n};\r\n\r\nexport type Guide = {\r\n id: string;\r\n title: string;\r\n tags: Tag[];\r\n published?: string;\r\n modified?: string;\r\n publishedBy?: string;\r\n modifiedBy?: string;\r\n};\r\n\r\nexport type Category = {\r\n id: string;\r\n title: string;\r\n symbol?: Symbol;\r\n activeSymbol?: Symbol;\r\n description?: string;\r\n items?: Category[];\r\n matches?: number;\r\n};\r\n\r\nexport type Tag = {\r\n id: string;\r\n title: string;\r\n symbol?: Symbol;\r\n matches?: number;\r\n defaultIcon?: Symbol;\r\n activeIcon?: Symbol;\r\n};\r\n\r\nexport enum DialogItemType {\r\n guide = 'guide',\r\n link = 'link',\r\n default = 'default',\r\n}\r\n\r\nexport type DialogItem = {\r\n id: string;\r\n title: string;\r\n parent: Guide;\r\n type: DialogItemType;\r\n connection?: string;\r\n href?: string;\r\n target?: string;\r\n};\r\n\r\nexport type GuideCategoryBrowserList = {\r\n id: string;\r\n title: string;\r\n symbol?: Symbol;\r\n guides: Guide[];\r\n paging: boolean;\r\n pager?: string;\r\n};\r\n\r\nexport type Notification = {\r\n id: string;\r\n title: string;\r\n body: string;\r\n modified?: string;\r\n expandable?: boolean;\r\n};\r\n\r\nexport type NotificationList = {\r\n id: string;\r\n title?: string;\r\n symbol?: Symbol;\r\n notifications: Notification[];\r\n defaultHeaderOptions?: {\r\n visible: boolean;\r\n };\r\n};\r\n\r\nexport type Tab = {\r\n title: string;\r\n name: string;\r\n aliases: string[];\r\n};\r\n\r\nexport type WidgetEntry = {\r\n id: string;\r\n type: string;\r\n content: {\r\n open: boolean;\r\n };\r\n origin: string;\r\n};\r\n\r\nexport enum PickerTypes {\r\n MODAL = 'modal',\r\n DRAWER = 'drawer',\r\n DROPDOWN = 'dropdown',\r\n NONE = 'none',\r\n}\r\n","export default '#____version____#';\r\n","import {\r\n BootstrappedImplementationConfiguration,\r\n ConfigurationApi as BootstrappingConfigurationApi,\r\n} from '@webprovisions/bootstrapping';\r\nimport {\r\n ConfigurationApiDefinition,\r\n Environment,\r\n version as webprovisionsVersion,\r\n WidgetSelector,\r\n} from '@webprovisions/platform';\r\nimport Implementation from './implementation';\r\nimport version from './version';\r\n\r\nexport interface HumanyConfiguration {\r\n /**\r\n * Extensions for the configuration API (optional).\r\n */\r\n configurationApiExtensions?: ConfigurationApiDefinition[];\r\n}\r\n\r\n/**\r\n * The Humany widget runtime.\r\n */\r\nexport default class Humany extends Environment {\r\n /**\r\n * Version of the Humany runtime.\r\n */\r\n static version: string = `${version} (${webprovisionsVersion})`;\r\n\r\n constructor(name: string, configurationApiExtensions: ConfigurationApiDefinition[] = []) {\r\n super(name, configurationApiExtensions, {\r\n transformPluginSettings: (settings, name, container) => {\r\n const $settings = container.get('$settings');\r\n const configPluginSettings =\r\n $settings.plugins && name ? $settings.plugins[name] || {} : {};\r\n return {\r\n ...configPluginSettings,\r\n ...settings,\r\n };\r\n },\r\n });\r\n }\r\n\r\n createImplementation(configuration: BootstrappedImplementationConfiguration): Implementation {\r\n const implementation = <Implementation>super.createImplementation(configuration);\r\n implementation.bindings = configuration.bindings;\r\n return implementation;\r\n }\r\n\r\n /**\r\n * Performs navigation for widgets matching the specified selector by invoking a\r\n * 'navigate' command.\r\n * @param selector Widget selector matching the widget(s) to perform navigation on.\r\n * @param route Route name.\r\n * @param params Route params.\r\n */\r\n navigate(selector: WidgetSelector, route: string, params: { [key: string]: string }) {\r\n this.widgets\r\n .query(selector)\r\n .forEach((widget) => widget.invoke('navigate', { route, params }));\r\n }\r\n\r\n /**\r\n * Creates a `Humany` runtime based on provided configuration.\r\n * @param configuration Runtime configuration.\r\n */\r\n static create(configuration: HumanyConfiguration = {}): Humany {\r\n const configurationApiExtensions = [BootstrappingConfigurationApi].concat(\r\n (configuration.configurationApiExtensions as any) || []\r\n );\r\n return new Humany('humany', configurationApiExtensions as any);\r\n }\r\n\r\n /**\r\n * Creates a `Humany` runtime based on provided configuration and retains configuration handlers\r\n * registered on global context. Use this factory to fully support the default embed script.\r\n * Will return any existing `Humany` runtime if available.\r\n * @param configuration Runtime configuration.\r\n * @param global Object to read configuration handlers from (default: window).\r\n */\r\n static createFromGlobal(globalHumany: any, configuration: HumanyConfiguration = {}): Humany {\r\n if (this.isRuntime(globalHumany)) {\r\n (globalHumany as Humany).patch(configuration);\r\n return globalHumany;\r\n }\r\n\r\n const runtimeConfiguration: any[] = [];\r\n\r\n const tempRuntimeConfiguration = globalHumany && globalHumany._c;\r\n if (tempRuntimeConfiguration) {\r\n tempRuntimeConfiguration.forEach((args: any) => runtimeConfiguration.push(args));\r\n }\r\n\r\n const runtime = this.create(configuration);\r\n runtime.container.register('$runtimecfg', runtimeConfiguration);\r\n return runtime;\r\n }\r\n\r\n /**\r\n * Determines whether the specified object is a valid `Humany` runtime.\r\n * @param obj Object to compare.\r\n */\r\n static isRuntime(obj: any): boolean {\r\n if (\r\n obj &&\r\n typeof obj === 'object' &&\r\n obj.container &&\r\n typeof obj.container.get === 'function' &&\r\n obj.container.get('$environment') === obj &&\r\n obj.container.owner === obj\r\n ) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n}\r\n","import { Implementation as ImplementationBase } from '@webprovisions/platform';\r\n\r\n/**\r\n * Represents a Humany implementation.\r\n */\r\nexport default class Implementation extends ImplementationBase {\r\n bindings: string[] = [];\r\n}\r\n","import { BootstrappedImplementationConfiguration } from '@webprovisions/bootstrapping';\r\nimport Humany from './humany';\r\nimport Implementation from './implementation';\r\n\r\n/**\r\n * Loads a Humany implementation by fetching the configuration from the specified URL.\r\n * @param implementationPath Implementation URL.\r\n */\r\nconst loadImplementation = (humany: Humany, url: string): Promise<Implementation> => {\r\n return fetch(url + '/config.json')\r\n .then((response) => response.json())\r\n .then((json) => json.implementation)\r\n .then((configuration: BootstrappedImplementationConfiguration) =>\r\n humany.createImplementation(configuration)\r\n );\r\n};\r\nexport default loadImplementation;\r\n","import { Container, Plugin as PluginBase } from '@webprovisions/platform';\r\n\r\n/**\r\n * Base class for a Humany plugin.\r\n */\r\nexport default class Plugin extends PluginBase {\r\n constructor(container: Container, settings?: any) {\r\n super(container, settings);\r\n }\r\n}\r\n","const verifyAuth = (host: string, widgetName: string): Promise<boolean> => {\r\n const url = `${host}${widgetName}/interfaceauthorized`;\r\n\r\n return fetch(url, {\r\n method: 'GET',\r\n credentials: 'include',\r\n }).then((response) => response.status === 200 && response.ok);\r\n};\r\n\r\nexport default verifyAuth;\r\n","import { Container, WidgetType as WidgetTypeBase } from '@webprovisions/platform';\r\n\r\n/**\r\n * Base class for a Humany widget.\r\n */\r\nexport default class WidgetType extends WidgetTypeBase {\r\n constructor(container: Container) {\r\n super(container);\r\n }\r\n}\r\n"],"names":["BootstrappingConfigurationApi","webprovisionsVersion","ImplementationBase","PluginBase","WidgetTypeBase"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAeA,IAAe,YAAA,CACX,gBACA,WACA,UAA4B,OACU;AACtC,SAAO,wBACH,gBACA,eAAe,UACf,MAAM;AACI,UAAA,+BAA+B,eAAe,UAC/C,IAAI,aAAa,EACjB,IAAI,CAAC,mBAAwB;AAC1B,YAAM,eAAe,eAAe;AAChC,UAAA,OAAO,iBAAiB,YAAY;AAC7B,eAAA;AAAA,MACX;AACA,UAAI,sBAAsB,YAAY,EAAE,cAAc,GAAG;AACrD,eAAO,eAAe;AAAA,MAC1B;AAAA,IACH,CAAA,EACA,OAAO,CAAC,YAAiB,CAAC,CAAC,OAAO;AACvC,wBAAoB,CAAC,SAAS,IAAI,CAAA,GAAI,OAAO,4BAA4B;AAAA,EAE7E,GAAA,QAAQ,uBAAwB,OAAM,SAAS,KACnD;AACJ;ACNY,IAAA,mCAAA,oBAAL;AACK,kBAAA,WAAA;AACD,kBAAA,UAAA;AACG,kBAAA,aAAA;AAHF,SAAA;AAAA,GAAA,kBAAA,CAAA,CAAA;AA0DA,IAAA,gCAAA,iBAAL;AACK,eAAA,WAAA;AACC,eAAA,YAAA;AACE,eAAA,cAAA;AACJ,eAAA,UAAA;AAJC,SAAA;AAAA,GAAA,eAAA,CAAA,CAAA;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,OAAO,IAAI,UAAU,QAAQ,cAC7B,IAAI,UAAU,IAAI,cAAc,MAAM,OACtC,IAAI,UAAU,UAAU,KAC1B;AACS,aAAA;AAAA,IACX;AACO,WAAA;AAAA,EACX;AACJ;AA5FA,IAAqB,SAArB;AAII,OAAO,UAAkB,GAAG,YAAYC;ACtB5C,MAAqB,uBAAuBC,iBAAmB;AAAA,EAA/D,cAAA;AAAA,UAAA,GAAA,SAAA;AACI,SAAA,WAAqB;EAAC;AAC1B;ACCM,MAAA,qBAAqB,CAAC,QAAgB,QAAyC;AAC1E,SAAA,MAAM,MAAM,cAAc,EAC5B,KAAK,CAAC,aAAa,SAAS,KAAA,CAAM,EAClC,KAAK,CAAC,SAAS,KAAK,cAAc,EAClC,KAAK,CAAC,kBACH,OAAO,qBAAqB,aAAa,CAC7C;AACR;ACVA,MAAqB,eAAeC,SAAW;AAAA,EAC3C,YAAY,WAAsB,UAAgB;AAC9C,UAAM,WAAW,QAAQ;AAAA,EAC7B;AACJ;ACTM,MAAA,aAAa,CAAC,MAAc,eAAyC;AACjE,QAAA,MAAM,GAAG,OAAO;AAEtB,SAAO,MAAM,KAAK;AAAA,IACd,QAAQ;AAAA,IACR,aAAa;AAAA,EAAA,CAChB,EAAE,KAAK,CAAC,aAAa,SAAS,WAAW,OAAO,SAAS,EAAE;AAChE;ACFA,MAAqB,mBAAmBC,aAAe;AAAA,EACnD,YAAY,WAAsB;AAC9B,UAAM,SAAS;AAAA,EACnB;AACJ;;"}
1
+ {"version":3,"file":"index.js","sources":["../src/bootstrap.ts","../src/data-types.ts","../src/version.ts","../src/humany.ts","../src/implementation.ts","../src/load-implementation.ts","../src/plugin.ts","../src/verify-auth.ts","../src/widget-type.ts"],"sourcesContent":["import { bootstrapImplementation, BootstrappedImplementation } from '@webprovisions/bootstrapping';\r\nimport { ConfigureCallback, selectImplementations } from '@webprovisions/platform';\r\nimport Implementation from './implementation';\r\n\r\nexport type BootstrapOptions = {\r\n /**\r\n * Resolver function for the root element to base the bootstrapping on.\r\n */\r\n rootElementResolver?: () => HTMLElement;\r\n};\r\n\r\n/**\r\n * Bootstraps an `Implementation` by scanning trigger elements and attaches them to\r\n * their corresponding widgets.\r\n */\r\nexport default (\r\n implementation: Implementation,\r\n configure: ConfigureCallback,\r\n options: BootstrapOptions = {}\r\n): Promise<BootstrappedImplementation> => {\r\n return bootstrapImplementation(\r\n implementation as any,\r\n implementation.bindings,\r\n () => {\r\n const runtimeConfigurationHandlers = implementation.container\r\n .get('$runtimecfg')\r\n .map((cfgHandlerArgs: any) => {\r\n const fnOrSelector = cfgHandlerArgs[0];\r\n if (typeof fnOrSelector === 'function') {\r\n return fnOrSelector;\r\n }\r\n if (selectImplementations(fnOrSelector)(implementation)) {\r\n return cfgHandlerArgs[1];\r\n }\r\n })\r\n .filter((handler: any) => !!handler);\r\n return (configure ? [configure] : []).concat(runtimeConfigurationHandlers);\r\n },\r\n options.rootElementResolver || (() => document.body)\r\n );\r\n};\r\n","export type Symbol = {\r\n type: 'Uri' | 'Svg' | 'FontAwesome' | 'Text' | string;\r\n content: string;\r\n};\r\n\r\nexport type Guide = {\r\n id: string;\r\n title: string;\r\n tags: Tag[];\r\n published?: string;\r\n modified?: string;\r\n publishedBy?: string;\r\n modifiedBy?: string;\r\n};\r\n\r\nexport type Category = {\r\n id: string;\r\n title: string;\r\n symbol?: Symbol;\r\n activeSymbol?: Symbol;\r\n description?: string;\r\n items?: Category[];\r\n matches?: number;\r\n};\r\n\r\nexport type Tag = {\r\n id: string;\r\n title: string;\r\n symbol?: Symbol;\r\n matches?: number;\r\n defaultIcon?: Symbol;\r\n activeIcon?: Symbol;\r\n};\r\n\r\nexport enum DialogItemType {\r\n guide = 'guide',\r\n link = 'link',\r\n default = 'default',\r\n}\r\n\r\nexport type DialogItem = {\r\n id: string;\r\n title: string;\r\n parent: Guide;\r\n type: DialogItemType;\r\n connection?: string;\r\n href?: string;\r\n target?: string;\r\n};\r\n\r\nexport type GuideCategoryBrowserList = {\r\n id: string;\r\n title: string;\r\n symbol?: Symbol;\r\n guides: Guide[];\r\n paging: boolean;\r\n pager?: string;\r\n};\r\n\r\nexport type Notification = {\r\n id: string;\r\n title: string;\r\n body: string;\r\n modified?: string;\r\n expandable?: boolean;\r\n};\r\n\r\nexport type NotificationList = {\r\n id: string;\r\n title?: string;\r\n symbol?: Symbol;\r\n notifications: Notification[];\r\n defaultHeaderOptions?: {\r\n visible: boolean;\r\n };\r\n};\r\n\r\nexport type Tab = {\r\n title: string;\r\n name: string;\r\n aliases: string[];\r\n};\r\n\r\nexport type WidgetEntry = {\r\n id: string;\r\n type: string;\r\n content: {\r\n open: boolean;\r\n };\r\n origin: string;\r\n};\r\n\r\nexport enum PickerTypes {\r\n MODAL = 'modal',\r\n DRAWER = 'drawer',\r\n DROPDOWN = 'dropdown',\r\n NONE = 'none',\r\n}\r\n","export default '#____version____#';\r\n","import {\r\n BootstrappedImplementationConfiguration,\r\n ConfigurationApi as BootstrappingConfigurationApi,\r\n} from '@webprovisions/bootstrapping';\r\nimport {\r\n ConfigurationApiDefinition,\r\n Environment,\r\n version as webprovisionsVersion,\r\n WidgetSelector,\r\n} from '@webprovisions/platform';\r\nimport Implementation from './implementation';\r\nimport version from './version';\r\n\r\nexport interface HumanyConfiguration {\r\n /**\r\n * Extensions for the configuration API (optional).\r\n */\r\n configurationApiExtensions?: ConfigurationApiDefinition[];\r\n}\r\n\r\n/**\r\n * The Humany widget runtime.\r\n */\r\nexport default class Humany extends Environment {\r\n /**\r\n * Version of the Humany runtime.\r\n */\r\n static version: string = `${version} (${webprovisionsVersion})`;\r\n\r\n constructor(name: string, configurationApiExtensions: ConfigurationApiDefinition[] = []) {\r\n super(name, configurationApiExtensions, {\r\n transformPluginSettings: (settings, name, container) => {\r\n const $settings = container.get('$settings');\r\n const configPluginSettings =\r\n $settings.plugins && name ? $settings.plugins[name] || {} : {};\r\n return {\r\n ...configPluginSettings,\r\n ...settings,\r\n };\r\n },\r\n });\r\n }\r\n\r\n createImplementation(configuration: BootstrappedImplementationConfiguration): Implementation {\r\n const implementation = <Implementation>super.createImplementation(configuration);\r\n implementation.bindings = configuration.bindings;\r\n return implementation;\r\n }\r\n\r\n /**\r\n * Performs navigation for widgets matching the specified selector by invoking a\r\n * 'navigate' command.\r\n * @param selector Widget selector matching the widget(s) to perform navigation on.\r\n * @param route Route name.\r\n * @param params Route params.\r\n */\r\n navigate(selector: WidgetSelector, route: string, params: { [key: string]: string }) {\r\n this.widgets\r\n .query(selector)\r\n .forEach((widget) => widget.invoke('navigate', { route, params }));\r\n }\r\n\r\n /**\r\n * Creates a `Humany` runtime based on provided configuration.\r\n * @param configuration Runtime configuration.\r\n */\r\n static create(configuration: HumanyConfiguration = {}): Humany {\r\n const configurationApiExtensions = [BootstrappingConfigurationApi].concat(\r\n (configuration.configurationApiExtensions as any) || []\r\n );\r\n return new Humany('humany', configurationApiExtensions as any);\r\n }\r\n\r\n /**\r\n * Creates a `Humany` runtime based on provided configuration and retains configuration handlers\r\n * registered on global context. Use this factory to fully support the default embed script.\r\n * Will return any existing `Humany` runtime if available.\r\n * @param configuration Runtime configuration.\r\n * @param global Object to read configuration handlers from (default: window).\r\n */\r\n static createFromGlobal(globalHumany: any, configuration: HumanyConfiguration = {}): Humany {\r\n if (this.isRuntime(globalHumany)) {\r\n (globalHumany as Humany).patch(configuration);\r\n return globalHumany;\r\n }\r\n\r\n const runtimeConfiguration: any[] = [];\r\n\r\n const tempRuntimeConfiguration = globalHumany && globalHumany._c;\r\n if (tempRuntimeConfiguration) {\r\n tempRuntimeConfiguration.forEach((args: any) => runtimeConfiguration.push(args));\r\n }\r\n\r\n const runtime = this.create(configuration);\r\n runtime.container.register('$runtimecfg', runtimeConfiguration);\r\n return runtime;\r\n }\r\n\r\n /**\r\n * Determines whether the specified object is a valid `Humany` runtime.\r\n * @param obj Object to compare.\r\n */\r\n static isRuntime(obj: any): boolean {\r\n if (\r\n obj &&\r\n typeof obj === 'object' &&\r\n obj.container &&\r\n typeof obj.container.get === 'function' &&\r\n obj.container.get('$environment') === obj &&\r\n obj.container.owner === obj\r\n ) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n}\r\n","import { Implementation as ImplementationBase } from '@webprovisions/platform';\r\n\r\n/**\r\n * Represents a Humany implementation.\r\n */\r\nexport default class Implementation extends ImplementationBase {\r\n bindings: string[] = [];\r\n}\r\n","import { BootstrappedImplementationConfiguration } from '@webprovisions/bootstrapping';\r\nimport Humany from './humany';\r\nimport Implementation from './implementation';\r\n\r\n/**\r\n * Loads a Humany implementation by fetching the configuration from the specified URL.\r\n * @param implementationPath Implementation URL.\r\n */\r\nconst loadImplementation = (humany: Humany, url: string): Promise<Implementation> => {\r\n return fetch(url + '/config.json')\r\n .then((response) => response.json())\r\n .then((json) => json.implementation)\r\n .then((configuration: BootstrappedImplementationConfiguration) =>\r\n humany.createImplementation(configuration)\r\n );\r\n};\r\nexport default loadImplementation;\r\n","import { Container, Plugin as PluginBase } from '@webprovisions/platform';\r\n\r\n/**\r\n * Base class for a Humany plugin.\r\n */\r\nexport default class Plugin extends PluginBase {\r\n constructor(container: Container, settings?: any) {\r\n super(container, settings);\r\n }\r\n}\r\n","const verifyAuth = (host: string, widgetName: string): Promise<boolean> => {\r\n const url = `${host}${widgetName}/interfaceauthorized`;\r\n\r\n return fetch(url, {\r\n method: 'GET',\r\n credentials: 'include',\r\n }).then((response) => response.status === 200 && response.ok);\r\n};\r\n\r\nexport default verifyAuth;\r\n","import { Container, WidgetType as WidgetTypeBase } from '@webprovisions/platform';\r\n\r\n/**\r\n * Base class for a Humany widget.\r\n */\r\nexport default class WidgetType extends WidgetTypeBase {\r\n constructor(container: Container) {\r\n super(container);\r\n }\r\n}\r\n"],"names":["BootstrappingConfigurationApi","webprovisionsVersion","ImplementationBase","PluginBase","WidgetTypeBase"],"mappings":";;;;;;;;;;;;;;;;AAeA,MAAe,IAAA,CACX,GACA,GACA,IAA4B,OAErB,EACH,GACA,EAAe,UACf,MAAM;AACI,QAAA,IAA+B,E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C,EAAe;AAAA,EACnD,YAAY,GAAsB;AAC9B,UAAM,CAAS;AAAA,EACnB;AACJ;"}
package/package.json CHANGED
@@ -1,14 +1,17 @@
1
1
  {
2
2
  "name": "@telia-ace/knowledge-widget-core",
3
- "version": "1.0.13",
3
+ "version": "1.0.14",
4
4
  "description": "Core framework for ACE Knowledge widgets.",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "author": "Telia Company AB",
7
7
  "keywords": [
8
8
  "telia"
9
9
  ],
10
- "source": "src/index.ts",
11
- "module": "dist/index.js",
10
+ "exports": {
11
+ "development": "./src/index.ts",
12
+ "default": "./dist/index.js"
13
+ },
14
+ "type": "module",
12
15
  "types": "dist/index.d.ts",
13
16
  "files": [
14
17
  "LICENSE.txt",
@@ -26,10 +29,10 @@
26
29
  },
27
30
  "sideEffects": false,
28
31
  "dependencies": {
29
- "@telia-ace/widget-core": "^1.0.10",
32
+ "@telia-ace/widget-core": "^1.0.11",
30
33
  "@telia-ace/widget-utilities": "^1.0.2",
31
34
  "@webprovisions/bootstrapping": "^1.0.12",
32
35
  "@webprovisions/platform": "^1.1.2"
33
36
  },
34
- "gitHead": "55b5291d2c388bcba1b43d0b4c0319829f3fbfbd"
37
+ "gitHead": "25ba427459b76aaec250d8618cfeeeb19676e347"
35
38
  }