atriusmaps-node-sdk 3.3.791 → 3.3.793
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
CHANGED
|
@@ -48,6 +48,50 @@ const getContentStage = vconfig => {
|
|
|
48
48
|
return stage === 'alpha' || stage === 'beta' || stage === 'prod' ? stage : null;
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
+
// Groups of locale tags that refer to the same language variant and should match each other
|
|
52
|
+
// when no exact match is available. zh-CN/zh-SG use simplified script; zh-TW/zh-HK/zh-MO use traditional.
|
|
53
|
+
const LOCALE_ALIAS_GROUPS = [
|
|
54
|
+
['zh-CN', 'zh-SG', 'zh-Hans'],
|
|
55
|
+
['zh-TW', 'zh-HK', 'zh-MO', 'zh-Hant'],
|
|
56
|
+
];
|
|
57
|
+
|
|
58
|
+
const getLocaleAliases = locale => {
|
|
59
|
+
const group = LOCALE_ALIAS_GROUPS.find(g => g.includes(locale));
|
|
60
|
+
return group ? group.filter(l => l !== locale) : [];
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// Three tiers of locale match, from most to least specific. Returned as predicates
|
|
64
|
+
// so the resolver below can walk all venues at each tier before falling to the next.
|
|
65
|
+
// 1. Exact full-tag match (e.g. "zh-Hans" === "zh-Hans")
|
|
66
|
+
// 2. Known aliases (e.g. browser "zh-CN" matches venue "zh-Hans")
|
|
67
|
+
// 3. Two-char language-subtag prefix on both sides (e.g. "fr-FR" vs "fr_CA" both reduce to "fr")
|
|
68
|
+
const getLocaleMatchTiers = browserLang => {
|
|
69
|
+
const aliases = getLocaleAliases(browserLang);
|
|
70
|
+
const prefix = browserLang.slice(0, 2);
|
|
71
|
+
return [
|
|
72
|
+
locale => locale === browserLang,
|
|
73
|
+
locale => aliases.includes(locale),
|
|
74
|
+
locale => locale.slice(0, 2) === prefix,
|
|
75
|
+
];
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
// Resolve a browser locale to a venue. Within each tier, prefer `currentVenue` over
|
|
79
|
+
// other siblings when both would match — this keeps the caller on their intended venue
|
|
80
|
+
// when it satisfies the preference, and prevents a lower-tier match (e.g. "en" prefix)
|
|
81
|
+
// from yanking a user off an exactly-matching region sibling.
|
|
82
|
+
const findVenueForLocale = (venues, browserLang, currentVenue = null) => {
|
|
83
|
+
for (const matches of getLocaleMatchTiers(browserLang)) {
|
|
84
|
+
if (currentVenue && matches(currentVenue.locale)) {
|
|
85
|
+
return currentVenue;
|
|
86
|
+
}
|
|
87
|
+
const venue = venues.find(v => matches(v.locale));
|
|
88
|
+
if (venue) {
|
|
89
|
+
return venue;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return null;
|
|
93
|
+
};
|
|
94
|
+
|
|
51
95
|
const getVenueDataFromUrls = async (vconfig, fetchJson, languagesToTry) => {
|
|
52
96
|
const stages = {
|
|
53
97
|
alpha: 'alpha-a.locuslabs.com',
|
|
@@ -69,17 +113,22 @@ const getVenueDataFromUrls = async (vconfig, fetchJson, languagesToTry) => {
|
|
|
69
113
|
: await fetchJson(`${accountUrl}/${assetFormat}.json`);
|
|
70
114
|
|
|
71
115
|
// Reassign venue id to venueId+langauge preference if that venue in that language is avaialbe to us in the v5 json
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
116
|
+
|
|
117
|
+
// First, obtain the "venue code" for the venueId - This unique identifies the "same venue absent of language suffix"
|
|
118
|
+
const venueCode = venueList[venueId] ? venueList[venueId].venueCode : null;
|
|
119
|
+
if (!venueCode) {
|
|
120
|
+
throw Error(`Venue id ${venueId} not found in venue list: ${Object.keys(venueList)}`);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Now find the first language in the user's browser preferences that matches a venue with the same venue code - and if we find it, switch to that venue id instead (which will have the language suffix)
|
|
124
|
+
const venuesWithSameVenueCode = Object.values(venueList).filter(v => v.venueCode === venueCode);
|
|
125
|
+
const currentVenue = venueList[venueId];
|
|
126
|
+
for (const browserLang of languagesToTry) {
|
|
127
|
+
const venue = findVenueForLocale(venuesWithSameVenueCode, browserLang, currentVenue);
|
|
128
|
+
if (venue) {
|
|
129
|
+
venueId = venue.id;
|
|
130
|
+
vconfig.venueId = `${venueId}`;
|
|
131
|
+
break;
|
|
83
132
|
}
|
|
84
133
|
}
|
|
85
134
|
|
|
@@ -199,5 +248,6 @@ const normalizeCoords = (coords, venueBounds) => {
|
|
|
199
248
|
exports.buildStructures = buildStructures;
|
|
200
249
|
exports.createFetchJson = createFetchJson;
|
|
201
250
|
exports.createFetchText = createFetchText;
|
|
251
|
+
exports.findVenueForLocale = findVenueForLocale;
|
|
202
252
|
exports.getVenueDataFromUrls = getVenueDataFromUrls;
|
|
203
253
|
exports.normalizeCoords = normalizeCoords;
|
package/dist/package.json.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e="web-engine",t="3.3.
|
|
1
|
+
var e="web-engine",t="3.3.793",s="UNLICENSED",r="module",o="src/main.js",i=["demo","deploy","nodesdk","src/extModules/flexapi","services/*","libraries/*"],l={colors:"cat utils/colors1.txt && node utils/processColors.js | pbcopy && cat utils/colors2.txt","cypress:comp":"cypress open --component --browser chrome","cypress:comp:ci":"cypress run --component",demo:"cd demo/ && yarn start",dev:"yarn mol e2e","format:check":"yarn prettier . --check","format:fix":"yarn prettier . --write",goProd:"cd deploy && scripts/goProd.sh",goStaging:"deploy/scripts/goStaging.sh","icons:convert":"node scripts/convertSvgToJsx.mjs",lint:"eslint . --ext .js,.jsx,.ts,.tsx",mod:"demo/startMod.sh",mol:"demo/startMol.sh","mol:build":"demo/startMolBuild.sh",molProd:"cd deploy && yarn buildAndRunMol","playwright:ci":"yarn playwright test --grep-invert sdk","playwright:ci:failed":"yarn playwright test --last-failed --grep-invert sdk","playwright:sdk":"yarn start-server-and-test 'cd ./deploy && yarn buildDev && yarn serveLocal' 8085 'cd ./test/sdk && npx http-server' 8080 'yarn playwright test sdk --ui'","playwright:ui":"yarn playwright test --ui --grep-invert sdk",prepare:"husky",test:"jest --no-cache --verbose","test-watch":"jest --verbose --watch","test:all":"yarn lint && yarn format:check && yarn test && yarn test:vitest && yarn cypress:comp:ci && yarn playwright:ci","test:mod":"playwright test --config=playwright.mod.config.ts","test:vitest":"vitest run",typecheck:"tsc -p tsconfig.checkjs.json",storybook:"storybook dev -p 6006","build-storybook":"storybook build"},a=["defaults"],n={"@azure/event-hubs":"^5.12.2","@csstools/normalize.css":"^11.0.1","@dnd-kit/core":"^6.3.1","@dnd-kit/modifiers":"^9.0.0","@dnd-kit/sortable":"^10.0.0","@dnd-kit/utilities":"^3.2.2","@locus-labs/mod-badge":"^0.1.102","@locus-labs/mod-footer":"^0.0.111","@locus-labs/mod-header":"^0.0.105","@locus-labs/mod-location-marker":"^0.0.104","@locus-labs/mod-map-legend":"^0.0.104","@locus-labs/mod-offscreen-indicator":"^0.0.104","@locus-labs/mod-pin":"^0.0.104","@locus-labs/mod-qr-code-card":"^0.0.104","@locus-labs/mod-qr-code-window":"^0.0.105","@locus-labs/mod-walk-time-matrix":"^0.0.103","@mapbox/mapbox-gl-draw":"^1.5.0","@mapbox/mapbox-gl-draw-static-mode":"^1.0.1","@microsoft/applicationinsights-web":"^3.3.6","@turf/area":"^7.2.0","@turf/bbox-clip":"^7.2.0","@turf/bbox-polygon":"^7.2.0","@turf/bearing":"^7.2.0","@turf/circle":"^7.2.0","@turf/helpers":"^7.2.0","@turf/point-to-line-distance":"^7.2.0","@vitejs/plugin-react":"^5.2.0","axe-core":"^4.10.3",browserslist:"^4.27.0","crypto-browserify":"^3.12.1","cypress-multi-reporters":"^2.0.5","cypress-real-events":"^1.14.0",dompurify:"^3.3.3","file-loader":"^6.2.0",flexsearch:"^0.7.43","h3-js":"^4.1.0",i18next:"^20.6.1","i18next-browser-languagedetector":"^6.1.1","jest-transform-css":"6.0.2",jsdom:"^25.0.1",jsonschema:"^1.5.0",luxon:"^3.5.0","maplibre-gl":"^4.7.1","mini-css-extract-plugin":"^2.9.2","mocha-junit-reporter":"^2.2.1",mochawesome:"^7.1.3","node-polyfill-webpack-plugin":"^4.1.0","path-browserify":"^1.0.1",pmtiles:"^4.4.0","prop-types":"^15.8.1","qrcode.react":"^4.2.0",ramda:"^0.30.1",react:"^19.2.4","react-compound-slider":"^3.4.0","react-dom":"^19.2.4","react-json-editor-ajrm":"^2.5.14","react-svg":"^16.3.0","react-virtualized-auto-sizer":"^1.0.25","react-window":"^1.8.11","smoothscroll-polyfill":"^0.4.4","styled-components":"^6.1.15","styled-normalize":"^8.1.1","throttle-debounce":"^5.0.2",trackjs:"^3.10.4","ua-parser-js":"^0.7.40",uuid:"11.1.0",zousan:"^3.0.1","zousan-plus":"^4.0.1"},c={"@applitools/eyes-playwright":"^1.44.1","@axe-core/playwright":"^4.10.2","@azure/identity":"^4.13.0","@azure/playwright":"^1.0.0","@babel/core":"^7.26.10","@babel/eslint-parser":"^7.26.10","@babel/plugin-proposal-class-properties":"^7.18.6","@babel/plugin-syntax-dynamic-import":"^7.8.3","@babel/plugin-syntax-import-assertions":"^7.26.0","@babel/plugin-transform-modules-commonjs":"^7.26.3","@babel/plugin-transform-runtime":"^7.26.10","@babel/preset-env":"^7.26.9","@babel/preset-react":"^7.26.3","@playwright/test":"^1.56.0","@storybook/addon-essentials":"^8.6.15","@storybook/blocks":"^8.6.15","@storybook/react":"^8.6.15","@storybook/react-vite":"^8.6.15","@testing-library/jest-dom":"^6.6.3","@types/react":"^19.0.10","@types/react-dom":"^19.0.4","@typescript-eslint/eslint-plugin":"^8.26.1","@typescript-eslint/parser":"^8.26.1","babel-jest":"^29.7.0","babel-loader":"^10.0.0","babel-plugin-inline-json-import":"^0.3.2","babel-plugin-module-resolver":"^5.0.2","babel-plugin-styled-components":"^2.1.4","chai-colors":"^1.0.1","css-loader":"^7.1.2",cypress:"^15.0.0","cypress-wait-until":"^3.0.2",eslint:"^8.57.1","eslint-config-prettier":"^10.1.8","eslint-config-standard":"^17.1.0","eslint-import-resolver-alias":"^1.1.2","eslint-import-resolver-typescript":"^3.9.1","eslint-plugin-cypress":"^2.15.2","eslint-plugin-import":"^2.31.0","eslint-plugin-jest":"^28.11.0","eslint-plugin-n":"^17.16.2","eslint-plugin-node":"^11.1.0","eslint-plugin-playwright":"^2.2.2","eslint-plugin-promise":"^5.2.0","eslint-plugin-react":"^7.37.4","eslint-plugin-standard":"^5.0.0","fetch-mock-jest":"^1.5.1",glob:"^11.0.1",husky:"^9.1.7",jest:"29.7.0","jest-environment-jsdom":"^29.7.0","lint-staged":"^15.5.0","node-fetch":"^2.7.0","null-loader":"^4.0.1",nx:"19.8.14","nx-remotecache-azure":"^19.0.0","os-browserify":"^0.3.0",prettier:"3.7.4","start-server-and-test":"^2.0.11",storybook:"^8.6.15",typescript:"^5.8.2",vite:"^7.3.2",vitest:"^4.1.2","webpack-merge":"^6.0.1"},p="yarn@4.13.0",d={node:"24.x"},m={},y={name:e,version:t,private:!0,license:s,type:r,main:o,workspaces:i,scripts:l,"lint-staged":{"*.js":["eslint --fix","prettier --check"],"*.{json,md,css,ts,tsx,jsx}":["prettier --check"]},browserslist:a,dependencies:n,devDependencies:c,packageManager:p,engines:d,nx:m};export{a as browserslist,y as default,n as dependencies,c as devDependencies,d as engines,s as license,o as main,e as name,m as nx,p as packageManager,l as scripts,r as type,t as version,i as workspaces};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"ramda";import{findBoundsOfCoordinates as t}from"../../../src/utils/bounds.js";const
|
|
1
|
+
import*as e from"ramda";import{findBoundsOfCoordinates as t}from"../../../src/utils/bounds.js";const n=async(e,t)=>fetch(t),s=e=>e=>n(0,e).then(e=>e.json()),l=e=>e=>n(0,e).then(e=>e.text()),o=e=>`https://api.content.locuslabs.com/${e}`,a=(t,n,s,l,a)=>e.mapObjIndexed((e,n)=>((e,t,n,s,l,a)=>"theme"===a||"style"===a?`${o(n)}/${t}/${a}/${l}/${s}/${a}.json`:e.replace(/https:\/\/content.locuslabs.com/gi,o(n)))(e,t,s,l,a,n),n),r=[["zh-CN","zh-SG","zh-Hans"],["zh-TW","zh-HK","zh-MO","zh-Hant"]],i=e=>{const t=(e=>{const t=r.find(t=>t.includes(e));return t?t.filter(t=>t!==e):[]})(e),n=e.slice(0,2);return[t=>t===e,e=>t.includes(e),e=>e.slice(0,2)===n]},c=(e,t,n=null)=>{for(const s of i(t)){if(n&&s(n.locale))return n;const t=e.find(e=>s(e.locale));if(t)return t}return null},u=async(e,t,n)=>{const s={alpha:"alpha-a.locuslabs.com",beta:"beta-a.locuslabs.com",gamma:"gamma-a.locuslabs.com",prod:"a.locuslabs.com"},{assetStage:l,accountId:o,formatVersion:r}=e;let{venueId:i}=e;const u=`https://${s[l]||s.prod}/accounts/${o}`,d=r||"v5",h=e.dataFetch&&globalThis[e.dataFetch]&&globalThis[e.dataFetch].getFiles?await globalThis[e.dataFetch].getFiles(e):await t(`${u}/${d}.json`),g=h[i]?h[i].venueCode:null;if(!g)throw Error(`Venue id ${i} not found in venue list: ${Object.keys(h)}`);const f=Object.values(h).filter(e=>e.venueCode===g),b=h[i];for(const t of n){const n=c(f,t,b);if(n){i=n.id,e.venueId=`${i}`;break}}if(!h[i])throw Error(`Attempt to access venue ${i} which is not within venue list: ${Object.keys(h)}`);const m=h[i].files,p=(e.dataFetch&&globalThis[e.dataFetch]&&globalThis[e.dataFetch].getVenueData?await globalThis[e.dataFetch].getVenueData(e):await t(m.venueData))[i];p.tileServerAuthInfo&&function(e){const t={defaultOrdinal:0,defaultStructureId:"singleBuilding",formatVersion:"v5",structures:{singleBuilding:{name:"singleBuilding",boundsPolygon:[],defaultLevelId:"singleLevel",id:"singleBuilding",levels:{singleLevel:{boundsPolygon:[],clfloor:0,details:"",id:"singleLevel",name:"singleLevel",ordinal:0}}}},structureOrder:["singleBuilding"]};for(const n in t)e[n]=t[n]}(p),p.venueList=h;const v=(e=>{const t=e.deepLinkProps?e.deepLinkProps.contentStage:null;return"alpha"===t||"beta"===t||"prod"===t?t:null})(e);return p.files=v?a(p.category,m,v,o,i):m,p},d=e=>{const{structureOrder:n,structures:s}=e;return n.map(e=>{const n=s[e];Object.values(n.levels).forEach(e=>e.bounds=t(e.boundsPolygon));const l=t(n.boundsPolygon);return{...n,bounds:l}})};const h=([e,t,...n])=>[t,e,...n],g=(e,t)=>{return!e||!Array.isArray(e)||e.length<1?e:(n=e[0][0],s=t.ne.lng,l=t.sw.lng,(n>s?n<=l:e=>l)?e:e.map(h));var n,s,l};export{d as buildStructures,s as createFetchJson,l as createFetchText,c as findVenueForLocale,u as getVenueDataFromUrls,g as normalizeCoords};
|
package/package.json
CHANGED