@inizioevoke/veeva-astroclm-core 1.1.7 → 1.2.0
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 +1 -0
- package/dist/components/scripts/PlatformScript/PlatformScript.astro +25 -0
- package/dist/components/scripts/PlatformScript/index.ts +4 -0
- package/dist/components/scripts/PlatformScript/platform.ts +16 -0
- package/dist/components/scripts/ResizeScript/ResizeScript.astro +35 -0
- package/dist/components/scripts/ResizeScript/index.ts +4 -0
- package/dist/components/scripts/ResizeScript/resize.ts +50 -0
- package/package.json +3 -1
- package/src/components/scripts/PlatformScript/PlatformScript.astro +25 -0
- package/src/components/scripts/PlatformScript/index.ts +4 -0
- package/src/components/scripts/PlatformScript/platform.ts +16 -0
- package/src/components/scripts/ResizeScript/ResizeScript.astro +35 -0
- package/src/components/scripts/ResizeScript/index.ts +4 -0
- package/src/components/scripts/ResizeScript/resize.ts +50 -0
- package/tsconfig.json +2 -1
package/build.ts
CHANGED
|
@@ -0,0 +1,25 @@
|
|
|
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} />}
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
})();
|
|
@@ -0,0 +1,35 @@
|
|
|
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} />}
|
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inizioevoke/veeva-astroclm-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "",
|
|
@@ -12,6 +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
17
|
"./env": "./dist/env/index.js",
|
|
16
18
|
"./integrations": "./dist/integrations/index.js",
|
|
17
19
|
"./lib": {
|
|
@@ -0,0 +1,25 @@
|
|
|
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} />}
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
})();
|
|
@@ -0,0 +1,35 @@
|
|
|
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} />}
|
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
})();
|