@inizioevoke/veeva-astroclm-core 1.2.0 → 1.2.2

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/build.ts CHANGED
@@ -28,7 +28,6 @@ switch (argv.cmd) {
28
28
  const dirsToCopy = [
29
29
  'apps/page-manager/templates',
30
30
  'apps/veeva-config-manager/templates',
31
- 'components',
32
31
  'types'
33
32
  ];
34
33
  for (const dir of dirsToCopy) {
@@ -4,4 +4,16 @@ export type VeevaEnv = 'client' | 'evoke';
4
4
  export type VeevaPlatform = 'salesforce' | 'vault';
5
5
  export type LogLevel = 'disabled' | 'error' | 'debug';
6
6
  export type LogTime = 'none' | 'date' | 'time' | 'datetime' | 'performance';
7
- export type LogOutput = 'console' | 'screen';
7
+ export type LogOutput = 'console' | 'screen';
8
+
9
+ declare module 'astro:env/client' {
10
+ export const BUILD_TARGET: BuildTarget;
11
+ export const WEB_ENV: WebEnv;
12
+ export const WEB_SCALING: boolean;
13
+ export const VEEVA_TRAINING: boolean;
14
+ export const VEEVA_ENV: VeevaEnv;
15
+ export const VEEVA_PLATFORM: VeevaPlatform;
16
+ export const LOG_LEVEL: LogLevel;
17
+ export const LOG_TIME: LogTime;
18
+ export const LOG_OUTPUT: LogOutput;
19
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inizioevoke/veeva-astroclm-core",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "",
5
5
  "license": "ISC",
6
6
  "author": "",
@@ -12,8 +12,8 @@
12
12
  },
13
13
  "exports": {
14
14
  "./apps": "./dist/apps/index.js",
15
- "./PlatformScript": "./dist/components/PlatformScript/index.ts",
16
- "./ResizeScript": "./dist/components/ResizeScript/index.ts",
15
+ "./PlatformScript": "./src/components/scripts/PlatformScript/index.ts",
16
+ "./ResizeScript": "./src/components/scripts/ResizeScript/index.ts",
17
17
  "./env": "./dist/env/index.js",
18
18
  "./integrations": "./dist/integrations/index.js",
19
19
  "./lib": {
@@ -1,19 +1,21 @@
1
1
  ---
2
+ /// <reference path="../../../types/env.d.ts" />
3
+ import { BUILD_TARGET } from 'astro:env/client';
2
4
  import esbuild from 'esbuild';
3
- import { BuildTarget } from '../../../types/env';
5
+ // import { BuildTarget } from '../../../types/env';
4
6
 
5
7
  import script from './platform.ts?raw';
6
8
 
7
- export interface Props {
8
- buildTarget: BuildTarget;
9
- }
9
+ // export interface Props {
10
+ // buildTarget: BuildTarget;
11
+ // }
10
12
 
11
13
  const {
12
14
  buildTarget
13
15
  } = Astro.props;
14
16
 
15
17
  let js: string | undefined;
16
- if (buildTarget === 'veeva') {
18
+ if (BUILD_TARGET === 'veeva') {
17
19
  const { code } = await esbuild.transform(script, {
18
20
  loader: 'ts',
19
21
  target: 'es2020',
@@ -1,32 +1,28 @@
1
1
  ---
2
+ /// <reference path="../../../types/env.d.ts" />
3
+ import { BUILD_TARGET, WEB_SCALING } from 'astro:env/client';
2
4
  import esbuild from 'esbuild';
3
- import { BuildTarget } from '../../../types/env';
4
5
  import script from './resize.ts?raw';
5
6
 
6
7
  export interface Props {
7
- buildTarget: BuildTarget,
8
- webScaling: boolean,
9
- ivaDimensions: {
10
- width: number,
11
- height: number
12
- }
8
+ width: number,
9
+ height: number
13
10
  }
14
11
 
15
12
  const {
16
- buildTarget,
17
- webScaling,
18
- ivaDimensions
13
+ width,
14
+ height
19
15
  } = Astro.props;
20
16
 
21
17
  let js: string | undefined;
22
- if (buildTarget === 'veeva' || webScaling) {
18
+ if (BUILD_TARGET === 'veeva' || WEB_SCALING) {
23
19
  const { code } = await esbuild.transform(script, {
24
20
  loader: 'ts',
25
21
  target: 'es2020',
26
22
  minify: true,
27
23
  define: {
28
- IVA_WIDTH: ivaDimensions.width.toString(),
29
- IVA_HEIGHT: ivaDimensions.height.toString()
24
+ IVA_WIDTH: width.toString(),
25
+ IVA_HEIGHT: height.toString()
30
26
  }
31
27
  });
32
28
  js = code;
@@ -4,4 +4,16 @@ export type VeevaEnv = 'client' | 'evoke';
4
4
  export type VeevaPlatform = 'salesforce' | 'vault';
5
5
  export type LogLevel = 'disabled' | 'error' | 'debug';
6
6
  export type LogTime = 'none' | 'date' | 'time' | 'datetime' | 'performance';
7
- export type LogOutput = 'console' | 'screen';
7
+ export type LogOutput = 'console' | 'screen';
8
+
9
+ declare module 'astro:env/client' {
10
+ export const BUILD_TARGET: BuildTarget;
11
+ export const WEB_ENV: WebEnv;
12
+ export const WEB_SCALING: boolean;
13
+ export const VEEVA_TRAINING: boolean;
14
+ export const VEEVA_ENV: VeevaEnv;
15
+ export const VEEVA_PLATFORM: VeevaPlatform;
16
+ export const LOG_LEVEL: LogLevel;
17
+ export const LOG_TIME: LogTime;
18
+ export const LOG_OUTPUT: LogOutput;
19
+ }
@@ -1,25 +0,0 @@
1
- ---
2
- import esbuild from 'esbuild';
3
- import { BuildTarget } from '../../../types/env';
4
-
5
- import script from './platform.ts?raw';
6
-
7
- export interface Props {
8
- buildTarget: BuildTarget;
9
- }
10
-
11
- const {
12
- buildTarget
13
- } = Astro.props;
14
-
15
- let js: string | undefined;
16
- if (buildTarget === 'veeva') {
17
- const { code } = await esbuild.transform(script, {
18
- loader: 'ts',
19
- target: 'es2020',
20
- minify: true
21
- });
22
- js = code;
23
- }
24
- ---
25
- {js && <script is:inline set:html={js} />}
@@ -1,4 +0,0 @@
1
- export {
2
- default,
3
- type Props as PlatformScriptProps
4
- } from "./PlatformScript.astro";
@@ -1,16 +0,0 @@
1
- (() => {
2
- const veevaPlatform: 'windows' | 'mac' | 'ipad' | 'unknown' = (() => {
3
- const ua = navigator.userAgent;
4
- const platform = navigator.platform;
5
- if (/windows/i.test(ua)) {
6
- return 'windows';
7
- } else if (/ipad/i.test(ua) || (platform === 'MacIntel' && navigator.maxTouchPoints > 1) || (/macintosh/i.test(ua) && 'ontouchstart' in window)) {
8
- return 'ipad';
9
- } else if (/macintosh/i.test(ua) || platform === 'MacIntel') {
10
- return 'mac';
11
- } else {
12
- return 'unknown';
13
- }
14
- })();
15
- document.documentElement.classList.add(`platform-${veevaPlatform}`);
16
- })();
@@ -1,35 +0,0 @@
1
- ---
2
- import esbuild from 'esbuild';
3
- import { BuildTarget } from '../../../types/env';
4
- import script from './resize.ts?raw';
5
-
6
- export interface Props {
7
- buildTarget: BuildTarget,
8
- webScaling: boolean,
9
- ivaDimensions: {
10
- width: number,
11
- height: number
12
- }
13
- }
14
-
15
- const {
16
- buildTarget,
17
- webScaling,
18
- ivaDimensions
19
- } = Astro.props;
20
-
21
- let js: string | undefined;
22
- if (buildTarget === 'veeva' || webScaling) {
23
- const { code } = await esbuild.transform(script, {
24
- loader: 'ts',
25
- target: 'es2020',
26
- minify: true,
27
- define: {
28
- IVA_WIDTH: ivaDimensions.width.toString(),
29
- IVA_HEIGHT: ivaDimensions.height.toString()
30
- }
31
- });
32
- js = code;
33
- }
34
- ---
35
- {js && <script is:inline set:html={js} />}
@@ -1,4 +0,0 @@
1
- export {
2
- default,
3
- type Props as ResizeScriptProps
4
- } from "./ResizeScript.astro";
@@ -1,50 +0,0 @@
1
- (() => {
2
- // Backup for CSS scaling for Veeva builds when the current screen size is not configured
3
-
4
- // ----------------------------------------------------------------------------------------------------
5
- // These values will be replaced during the build
6
- // @ts-ignore
7
- const width: number = IVA_WIDTH;
8
- // @ts-ignore
9
- const height: number = IVA_HEIGHT;
10
- // ----------------------------------------------------------------------------------------------------
11
-
12
- const scalingWrapper = document.querySelector('.scaling-wrapper') as HTMLElement;
13
-
14
- function debounce<T extends (...args: unknown[]) => void>(fn: T, delay: number = 100) {
15
- let timer: ReturnType<typeof setTimeout>;
16
- return (...args: Parameters<T>) => {
17
- clearTimeout(timer);
18
- timer = setTimeout(() => fn(...args), delay);
19
- };
20
- }
21
-
22
- let lastScale = 0;
23
- const resize = () => {
24
- const vw = Math.round(visualViewport?.width ?? window.innerWidth);
25
- const vh = Math.round(visualViewport?.height ?? window.innerHeight);
26
- let transform: string | undefined;
27
- const shouldScaleDown = vw < width - 1 || vh < height - 1;
28
- if (shouldScaleDown) {
29
- const scale = Math.min(vw / width, vh / height);
30
- if (scale !== 1 && lastScale !== scale) {
31
- lastScale = scale;
32
- const offsetX = (vw - width * scale) / 2 / scale;
33
- const offsetY = (vh - height * scale) / 2 / scale;
34
- transform = `scale(${scale}) translate(${offsetX}px, ${offsetY}px)`;
35
- }
36
- } else {
37
- transform = 'none';
38
- }
39
-
40
- if (transform) {
41
- document.body.classList[transform === 'none' ? 'remove' : 'add']('scaled');
42
- scalingWrapper.style.transform = transform;
43
- }
44
- }
45
-
46
- resize();
47
- window.addEventListener('DOMContentLoaded', () => {
48
- window.addEventListener('resize', debounce(resize), { passive: true });
49
- }, { passive: true });
50
- })();