@saasquatch/component-environment 1.0.0-2 → 1.0.0-3
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/README.md +45 -0
- package/dist/index.js +1 -2
- package/dist/index.mjs +1 -2
- package/package.json +1 -1
- package/src/listeners.ts +0 -1
package/README.md
CHANGED
|
@@ -1 +1,46 @@
|
|
|
1
1
|
Provides the environment for running SaaSquatch web components.
|
|
2
|
+
|
|
3
|
+
SaaSquatch web components can run in a number of different environments, including:
|
|
4
|
+
|
|
5
|
+
- in a widget via `squatch-js`
|
|
6
|
+
- in a microsite (portal)
|
|
7
|
+
- in a mobile SDK (i.e. `squatch-android`)
|
|
8
|
+
- in the admin portal
|
|
9
|
+
|
|
10
|
+
In each environment, a different set of context information about the tenant, user and program are provided, and the goal of this package is to normalize the differences in environments to provide a common API.
|
|
11
|
+
|
|
12
|
+
The environment is provided in a set of contexts through `dom-context`, which provides vanilla global context providers. They can be accessed through a raw `ContextListener` or via `useDomContext` in `dom-context-hooks`.
|
|
13
|
+
|
|
14
|
+
## General environment
|
|
15
|
+
|
|
16
|
+
### `getEnvironment()`
|
|
17
|
+
|
|
18
|
+
Get the environment type. The current possible values are: `SquatchJS2`, `SquatchAndroid`, `SquatchPortal`, `SquatchAdmin` or `None`.
|
|
19
|
+
|
|
20
|
+
### `isDemo()`
|
|
21
|
+
|
|
22
|
+
Returns whether components should run in demo/preview mode.
|
|
23
|
+
|
|
24
|
+
### `getTenantAlias()`
|
|
25
|
+
|
|
26
|
+
Get the current tenant alias.
|
|
27
|
+
|
|
28
|
+
### `getAppDomain()`
|
|
29
|
+
|
|
30
|
+
Get the SaaSquatch app domain.
|
|
31
|
+
|
|
32
|
+
### `getEngagementMedium()`
|
|
33
|
+
|
|
34
|
+
Get the current engagement medium. This is particularly important in widgets rendered by `squatch-js` for informing metadata about share link clicks.
|
|
35
|
+
|
|
36
|
+
## User identity
|
|
37
|
+
|
|
38
|
+
The user identity context name is exported in a constant `USER_CONTEXT_NAME`. The current value can be retrieved with `getUserIdentity()` and set with `setUserIdentity(identity)`.
|
|
39
|
+
|
|
40
|
+
## Locale
|
|
41
|
+
|
|
42
|
+
The locale context name is exported in a constnat `LOCALE_CONTEXT_NAME`. The current value can be retrieved with `getLocale()` and set with `setLocal(locale)`.
|
|
43
|
+
|
|
44
|
+
## Program ID
|
|
45
|
+
|
|
46
|
+
The program ID context name is exported in a constant `PROGRAM_CONTEXT_NAME`. The current value can be retrieved with `getProgramId()` and set with `setProgramId(programId)`.
|
package/dist/index.js
CHANGED
|
@@ -266,8 +266,7 @@ var userContextListenerForLocale = new import_dom_context2.ContextListener({
|
|
|
266
266
|
}
|
|
267
267
|
debug4(`Setting locale context to [${newLocale}]`);
|
|
268
268
|
localeProvider.context = newLocale;
|
|
269
|
-
}
|
|
270
|
-
onStatus: (status) => debug4("STATUS", status)
|
|
269
|
+
}
|
|
271
270
|
});
|
|
272
271
|
function startUserContextListenerForLocale() {
|
|
273
272
|
debug4("Starting user context listener for locale updates");
|
package/dist/index.mjs
CHANGED
|
@@ -222,8 +222,7 @@ var userContextListenerForLocale = new ContextListener({
|
|
|
222
222
|
}
|
|
223
223
|
debug4(`Setting locale context to [${newLocale}]`);
|
|
224
224
|
localeProvider.context = newLocale;
|
|
225
|
-
}
|
|
226
|
-
onStatus: (status) => debug4("STATUS", status)
|
|
225
|
+
}
|
|
227
226
|
});
|
|
228
227
|
function startUserContextListenerForLocale() {
|
|
229
228
|
debug4("Starting user context listener for locale updates");
|
package/package.json
CHANGED
package/src/listeners.ts
CHANGED
|
@@ -44,7 +44,6 @@ const userContextListenerForLocale = new ContextListener<
|
|
|
44
44
|
debug(`Setting locale context to [${newLocale}]`);
|
|
45
45
|
localeProvider.context = newLocale;
|
|
46
46
|
},
|
|
47
|
-
onStatus: (status) => debug("STATUS", status),
|
|
48
47
|
});
|
|
49
48
|
|
|
50
49
|
export function startUserContextListenerForLocale() {
|