@telia-ace/knowledge-widget-core 1.0.12 → 1.0.16
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 +78 -100
- package/dist/index.js.map +1 -1
- package/package.json +8 -4
package/dist/index.js
CHANGED
|
@@ -1,122 +1,100 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
20
|
-
import { selectImplementations, version as
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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(
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
return implementation;
|
|
37
|
+
createImplementation(t) {
|
|
38
|
+
const n = super.createImplementation(t);
|
|
39
|
+
return n.bindings = t.bindings, n;
|
|
64
40
|
}
|
|
65
|
-
navigate(
|
|
66
|
-
this.widgets.query(
|
|
41
|
+
navigate(t, n, e) {
|
|
42
|
+
this.widgets.query(t).forEach((r) => r.invoke("navigate", { route: n, params: e }));
|
|
67
43
|
}
|
|
68
|
-
static create(
|
|
69
|
-
const
|
|
70
|
-
return new
|
|
44
|
+
static create(t = {}) {
|
|
45
|
+
const n = [l].concat(t.configurationApiExtensions || []);
|
|
46
|
+
return new a("humany", n);
|
|
71
47
|
}
|
|
72
|
-
static createFromGlobal(
|
|
73
|
-
if (this.isRuntime(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const
|
|
78
|
-
|
|
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(
|
|
87
|
-
|
|
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
|
|
94
|
-
|
|
95
|
-
class
|
|
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
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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
|
|
110
|
-
const
|
|
111
|
-
return fetch(
|
|
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((
|
|
78
|
+
}).then((r) => r.status === 200 && r.ok);
|
|
115
79
|
};
|
|
116
|
-
class
|
|
117
|
-
constructor(
|
|
118
|
-
super(
|
|
80
|
+
class G extends E {
|
|
81
|
+
constructor(n) {
|
|
82
|
+
super(n);
|
|
119
83
|
}
|
|
120
84
|
}
|
|
121
|
-
export {
|
|
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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AAS,eAAe,oBAAoB;AACvD,WAAA;AAAA,EACX;AAAA,EAMA,OAAO,UAAU,KAAmB;AAE5B,QAAA,OACA,OAAO,QAAQ,YACf,IAAI,aACJ,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","Widg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IACd,QAAQ;AAAA,IACR,aAAa;AAAA,EAAA,CAChB,EAAE,KAAK,CAAC,MAAa,EAAS,WAAW,OAAO,EAAS,EAAE;AAChE;ACFA,MAAqB,UAAmBC,EAAe;AAAA,EACnD,YAAY,GAAsB;AAC9B,UAAM,CAAS;AAAA,EACnB;AACJ;"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telia-ace/knowledge-widget-core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.16",
|
|
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
|
-
"
|
|
10
|
+
"exports": {
|
|
11
|
+
"development": "./src/index.ts",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"type": "module",
|
|
11
15
|
"types": "dist/index.d.ts",
|
|
12
16
|
"files": [
|
|
13
17
|
"LICENSE.txt",
|
|
@@ -25,10 +29,10 @@
|
|
|
25
29
|
},
|
|
26
30
|
"sideEffects": false,
|
|
27
31
|
"dependencies": {
|
|
28
|
-
"@telia-ace/widget-core": "^1.0.
|
|
32
|
+
"@telia-ace/widget-core": "^1.0.12",
|
|
29
33
|
"@telia-ace/widget-utilities": "^1.0.2",
|
|
30
34
|
"@webprovisions/bootstrapping": "^1.0.12",
|
|
31
35
|
"@webprovisions/platform": "^1.1.2"
|
|
32
36
|
},
|
|
33
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "321711ae47ffe611d0ce45c51965e6441b4d894e"
|
|
34
38
|
}
|