atriusmaps-node-sdk 3.3.934 → 3.3.936
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/package.json.js +1 -1
- package/dist/cjs/plugins/sdkServer/src/sdkServer.js +1 -1
- package/dist/cjs/plugins/searchService/src/poiSearch.js +22 -1
- package/dist/cjs/plugins/searchService/src/searchTypeahead.js +7 -1
- package/dist/package.json.js +1 -1
- package/dist/plugins/sdkServer/src/sdkServer.js +1 -1
- package/dist/plugins/searchService/src/poiSearch.js +1 -1
- package/dist/plugins/searchService/src/searchTypeahead.js +1 -1
- package/package.json +1 -1
package/dist/cjs/package.json.js
CHANGED
|
@@ -16,7 +16,7 @@ function describeMessageRelation(senderOrigin, iframeOrigin) {
|
|
|
16
16
|
}
|
|
17
17
|
function logBrowserMessageTelemetry(bus, payload) {
|
|
18
18
|
bus.send("appInsights/log", {
|
|
19
|
-
name: "browserMessageObserved",
|
|
19
|
+
name: "sdkServer/browserMessageObserved",
|
|
20
20
|
properties: {
|
|
21
21
|
command: payload.command,
|
|
22
22
|
deploymentHost: window.location.host,
|
|
@@ -23,6 +23,13 @@ function _interopNamespaceDefault(e) {
|
|
|
23
23
|
var R__namespace = /*#__PURE__*/_interopNamespaceDefault(R);
|
|
24
24
|
|
|
25
25
|
const DEFAULT_RESULTS_LIMIT = 5e3;
|
|
26
|
+
function promoteExactMatches(results, exactIdSet) {
|
|
27
|
+
if (!exactIdSet.size) return results;
|
|
28
|
+
return results.map((poi, index) => {
|
|
29
|
+
const exact = exactIdSet.has(Number(poi.poiId));
|
|
30
|
+
return { poi: exact ? { ...poi, isExactNameMatch: true } : poi, index, exact };
|
|
31
|
+
}).sort((a, b) => Number(b.exact) - Number(a.exact) || a.index - b.index).map((entry) => entry.poi);
|
|
32
|
+
}
|
|
26
33
|
function createPOISearch(pois, lang) {
|
|
27
34
|
const index = utils.getFlexSearchInstance({ lang });
|
|
28
35
|
prepareIndexEntries(pois).forEach(([id, content]) => index.add(id, content));
|
|
@@ -36,13 +43,27 @@ function createPOISearch(pois, lang) {
|
|
|
36
43
|
return [Number(poiId), content];
|
|
37
44
|
});
|
|
38
45
|
}
|
|
46
|
+
function findExactNameMatchIds(normalizedQuery) {
|
|
47
|
+
const ids = /* @__PURE__ */ new Set();
|
|
48
|
+
Object.values(pois).forEach((poi) => {
|
|
49
|
+
const isExact = [poi.name, poi.staticName].filter(Boolean).some((name) => name.toLowerCase() === normalizedQuery);
|
|
50
|
+
if (isExact) {
|
|
51
|
+
ids.add(Number(poi.poiId));
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
return ids;
|
|
55
|
+
}
|
|
39
56
|
function search(queryParams) {
|
|
40
57
|
const options = { ...queryParams };
|
|
41
58
|
if (!options.limit) {
|
|
42
59
|
options.limit = DEFAULT_RESULTS_LIMIT;
|
|
43
60
|
}
|
|
44
61
|
const ids = index.search(options);
|
|
45
|
-
|
|
62
|
+
const normalizedQuery = (options.query ?? "").toLowerCase();
|
|
63
|
+
const exactIdSet = normalizedQuery ? findExactNameMatchIds(normalizedQuery) : /* @__PURE__ */ new Set();
|
|
64
|
+
const missingExactIds = [...exactIdSet].filter((id) => !ids.includes(id));
|
|
65
|
+
const results = Object.values(R__namespace.pick(ids.concat(missingExactIds), pois));
|
|
66
|
+
return promoteExactMatches(results, exactIdSet).slice(0, options.limit);
|
|
46
67
|
}
|
|
47
68
|
function updateMultiple(pois2) {
|
|
48
69
|
prepareIndexEntries(pois2).forEach(([id, content]) => index.update(id, content));
|
|
@@ -53,7 +53,8 @@ function createSuggestedKeywordsSearch(pois, lang) {
|
|
|
53
53
|
let { keywords, index } = buildKeywordsAndIndex(pois, lang);
|
|
54
54
|
const search = (queryParams) => {
|
|
55
55
|
const ids = index.search(queryParams);
|
|
56
|
-
|
|
56
|
+
const results = ids.map((index2) => keywords[index2]);
|
|
57
|
+
return rankByExactMatch(results, queryParams.query);
|
|
57
58
|
};
|
|
58
59
|
const add = (newKeyword) => {
|
|
59
60
|
keywords.push(newKeyword);
|
|
@@ -71,5 +72,10 @@ function createSuggestedKeywordsSearch(pois, lang) {
|
|
|
71
72
|
function extractParentCategories(pois) {
|
|
72
73
|
return Object.values(pois).map((poi) => poi.category).map((fullCategory) => fullCategory.split(".")).map((subcategories) => subcategories[0]);
|
|
73
74
|
}
|
|
75
|
+
function rankByExactMatch(results, query) {
|
|
76
|
+
const normalizedQuery = (query ?? "").toLowerCase();
|
|
77
|
+
if (!normalizedQuery) return results;
|
|
78
|
+
return results.map((keyword, index) => ({ keyword, index, tier: keyword.toLowerCase() === normalizedQuery ? 0 : 1 })).sort((a, b) => a.tier - b.tier || a.index - b.index).map((entry) => entry.keyword);
|
|
79
|
+
}
|
|
74
80
|
|
|
75
81
|
module.exports = createSearchTypeahead;
|
package/dist/package.json.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var a="3.3.
|
|
1
|
+
var a="3.3.936",e={version:a};export{e as default,a as version};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{throttle as e}from"throttle-debounce";import{getStructureAndFloorAtPoint as o}from"../../../src/utils/geom.js";import n from"../../../src/utils/observable.js";import{headlessCommands as t,handleHeadless as a}from"./sdkHeadless.js";let
|
|
1
|
+
import{throttle as e}from"throttle-debounce";import{getStructureAndFloorAtPoint as o}from"../../../src/utils/geom.js";import n from"../../../src/utils/observable.js";import{headlessCommands as t,handleHeadless as a}from"./sdkHeadless.js";let r=null;function i(e,o){return"null"===e?"null-origin":e===o?"same-origin":"cross-origin"}function s(e,o){e.send("appInsights/log",{name:"sdkServer/browserMessageObserved",properties:{command:o.command,deploymentHost:window.location.host,iframeOrigin:o.iframeOrigin,messageType:o.messageType,relation:i(o.senderOrigin,o.iframeOrigin),senderOrigin:o.senderOrigin,wouldRejectCrossOrigin:!l(o.senderOrigin,o.iframeOrigin)}})}function l(e,o){return e===o}function m(e){const o=(e,o)=>{const n={payload:e,type:"LL-server",clientMsgId:o};try{window.postMessage(n,"*")}catch{window.postMessage((t=n,JSON.parse(JSON.stringify(t))),"*")}var t},n=n=>{const t=n.data;if(!t||"LL-client"!==t.type)return;const a=window.location.origin;s(e.bus,{messageType:"LL-client",senderOrigin:n.origin,command:t.payload?.command,iframeOrigin:a}),l(n.origin,a)&&e.bus.get("clientAPI/execute",t.payload).then(e=>o(e,t.msgId)).catch(o=>{var n,a;e.config.debug&&console.error(o),n=o.message,a=t.msgId,window.postMessage({error:!0,payload:n,type:"LL-server",clientMsgId:a},"*")})};return r&&r(),window.addEventListener("message",n),r=()=>window.removeEventListener("message",n),(e,o)=>{window.postMessage({event:e,payload:o,type:"LL-server"},"*")}}async function d(r,i){const s=r.env.isBrowser?m(r):function(e){const o=n();return e.eventListener=o,(e,n)=>o.fire(e,n)}(r);return function(n,t){const a=async(e,o)=>{const{lat:a,lng:r,floorId:i,ordinal:s,structureId:l}=await n.bus.get("map/getMapCenter");t(e,{lat:a,lng:r,floorId:i,ord:s,structureId:l,...o})};n.bus.monitor("map/userMoveStart",e=>{a("userMoveStart",e)}),n.bus.monitor("map/userMoving",e(500,e=>{a("userMoving",e)})),n.bus.monitor("map/moveEnd",e=>{a("moveEnd",e)}),n.bus.monitor("map/floorChanged",({structure:e,floor:o})=>t("levelChange",{floorId:o?.id??null,floorName:o?.name??null,ord:o?.ordinal??null,structureId:e?.id??null,structureName:e?.name??null})),n.bus.monitor("map/poiClicked",({poi:e})=>t("poiSelected",e)),n.bus.monitor("poiDetails/showPoi",({poi:e})=>t("poiShown",e)),n.bus.monitor("map/click",async({lat:e,lng:a,ord:r})=>{const i=await n.bus.get("venueData/getStructures"),s=await n.bus.get("map/getViewBBox"),{building:l,floor:m}=o(i,e,a,r,s,!0);t("mapClicked",{lat:e,lng:a,ord:r,building:l,floor:m})})}(r,s),{init:async()=>{!function(e){[{name:"latLngOrdLocation",spec:{type:"object",props:[{name:"lat",type:"float"},{name:"lng",type:"float"},{name:"ord",type:"integer"}]}},{name:"latLngFloorLocation",spec:{type:"object",props:[{name:"lat",type:"float"},{name:"lng",type:"float"},{name:"floorId",type:"string"}]}},{name:"poiIdLocation",spec:{type:"object",props:[{name:"poiId",type:"integer",min:0}]}},{name:"location",spec:{type:"multi",types:[{type:"poiIdLocation"},{type:"latLngOrdLocation"},{type:"latLngFloorLocation"}]}},{name:"viewSettings",spec:{type:"object",props:[{name:"zoom",type:"float",optional:!0},{name:"pitch",type:"float",optional:!0},{name:"bearing",type:"float",optional:!0}]}}].forEach(o=>{e.bus.send("clientAPI/registerCustomType",o)})}(r),t.forEach(e=>r.bus.send("clientAPI/registerCommand",e)),a(r),i.headless||await import("../../../_virtual/_empty_module_placeholder.js").then(e=>{e.visualCommands.forEach(e=>r.bus.send("clientAPI/registerCommand",e)),e.handleVisual(r,s)});const e=async()=>{await r.bus.send("system/readywhenyouare"),r.bus.get("clientAPI/execute",{command:"getCommandJSON"}).then(e=>s("ready",{commandJSON:e})),!i.headless&&r.config.uiHide?.sidebar&&r.env.isDesktop()&&r.bus.send("map/changePadding",{padding:{left:55,right:55,top:72,bottom:22}})};i.headless?Promise.all([new Promise(e=>r.bus.monitor("venueData/navGraphLoaded",e)),new Promise(e=>r.bus.monitor("venueData/poiDataLoaded",e))]).then(e):r.bus.on("map/mapReadyToShow",e),r.bus.on("sdkServer/sendEvent",({eventName:e,...o})=>s(e,o))}}}export{d as create,i as describeMessageRelation,l as isSameOriginBrowserMessage,s as logBrowserMessageTelemetry};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as
|
|
1
|
+
import*as e from"ramda";import{getFlexSearchInstance as t}from"./utils.js";function a(a,r){const o=t({lang:r});function n(t){return Object.values(t).map(t=>{const{poiId:a,category:r="",name:o,staticName:n,keywords:i=[],roomId:c=""}=t,s=e.path(["dynamicData","grab","tags"],t)||[],u=i.filter(e.prop("isUserSearchable")).map(e.prop("name")),m=`${o} ${n&&n!==o?n:""} ${r.split(".").join(" ")} ${c} ${u.join(" ")} ${s.join(" ")}`;return[Number(a),m]})}return n(a).forEach(([e,t])=>o.add(e,t)),{search:function(t){const r={...t};r.limit||(r.limit=5e3);const n=o.search(r),i=(r.query??"").toLowerCase(),c=i?function(e){const t=new Set;return Object.values(a).forEach(a=>{[a.name,a.staticName].filter(Boolean).some(t=>t.toLowerCase()===e)&&t.add(Number(a.poiId))}),t}(i):new Set,s=[...c].filter(e=>!n.includes(e));return function(e,t){return t.size?e.map((e,a)=>{const r=t.has(Number(e.poiId));return{poi:r?{...e,isExactNameMatch:!0}:e,index:a,exact:r}}).sort((e,t)=>Number(t.exact)-Number(e.exact)||e.index-t.index).map(e=>e.poi):e}(Object.values(e.pick(n.concat(s),a)),c).slice(0,r.limit)},updateMultiple:function(e){n(e).forEach(([e,t])=>o.update(e,t))}}}export{a as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{pipe as e,values as t,chain as r,prop as n,filter as
|
|
1
|
+
import{pipe as e,values as t,chain as r,prop as n,filter as o,pluck as a}from"ramda";import{getFlexSearchInstance as i}from"./utils.js";function s(e,t,r){const n=function(e,t){let r=e,{keywords:n,index:o}=d(e,t);const a=e=>{r=e;const a=d(e,t);n=a.keywords,o=a.index};return{search:e=>function(e,t){const r=(t??"").toLowerCase();return r?e.map((e,t)=>({keyword:e,index:t,tier:e.toLowerCase()===r?0:1})).sort((e,t)=>e.tier-t.tier||e.index-t.index).map(e=>e.keyword):e}(o.search(e).map(e=>n[e]),e.query),add:e=>{n.push(e),o.add(n.length-1,e)},update:a,getAllPois:()=>r}}(e,r);return{query:(e,r)=>{const o=n.search({query:e,limit:r}),a=!(e.length<3)&&o.length,i=r-o.length,s=a?function(e,r){const n=t({query:e,limit:r}),o=t({query:e,suggest:!0,limit:r}),a=n.map(e=>e.poiId),i=o.filter(e=>-1===a.indexOf(e.poiId));return n.concat(i)}(e,i):[];return{keywords:o,pois:s}},addKeyword:e=>{n.add(e)},updatePOIs:e=>{const t={...n.getAllPois()};for(const r of e)t[r.poiId]=r;n.update(t)}}}function d(s,d){const c=function(e){return Object.values(e).map(e=>e.category).map(e=>e.split(".")).map(e=>e[0])}(s),u=[...c,...e(t,r(n("keywords")),o(n("isUserSearchable")),a("name"))(s),...e(t,a("name"))(s),...e(t,o(e=>e.staticName&&e.staticName!==e.name),a("staticName"))(s)],m=Array.from(new Set([...u])),l=i({lang:d});return m.forEach((e,t)=>l.add(t,e)),{keywords:m,index:l}}export{s as default};
|
package/package.json
CHANGED