@inizioevoke/veeva-astroclm 1.0.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.
Files changed (67) hide show
  1. package/.claude/settings.local.json +10 -0
  2. package/.claude/skills/evoke-analytics-auditor/SKILL.md +509 -0
  3. package/.claude/skills/evoke-astro-core/SKILL.md +395 -0
  4. package/.claude/skills/evoke-page-manager/SKILL.md +75 -0
  5. package/.claude/skills/evoke-veeva-config-manager/SKILL.md +17 -0
  6. package/.claude/skills/evoke-veeva-config-manager/create.md +189 -0
  7. package/.claude/skills/evoke-veeva-config-manager/manage.md +48 -0
  8. package/.editorconfig +12 -0
  9. package/.env.development +3 -0
  10. package/.env.veeva-client +1 -0
  11. package/.env.veeva-client-training +2 -0
  12. package/.env.veeva-evoke +4 -0
  13. package/README.md +43 -0
  14. package/_contents.yml.example +6 -0
  15. package/astro.config.ts +36 -0
  16. package/package.json +40 -0
  17. package/public/astroclm.png +0 -0
  18. package/public/favicon.png +0 -0
  19. package/public/shared/salesforce.js +2586 -0
  20. package/public/shared/vault.js +2417 -0
  21. package/src/components/content/readme.md +1 -0
  22. package/src/components/isi/ISIContent.tsx +137 -0
  23. package/src/components/isi/_isi.scss +22 -0
  24. package/src/components/nav/MainNav/MainNav.astro +20 -0
  25. package/src/components/nav/MainNav/MainNav.tsx +36 -0
  26. package/src/components/nav/NavList.tsx +66 -0
  27. package/src/components/ui/Button.astro +19 -0
  28. package/src/components/ui/Image.astro +36 -0
  29. package/src/components/ui/IvaConsole/IvaConsole.astro +12 -0
  30. package/src/components/ui/IvaConsole/IvaConsole.scss +62 -0
  31. package/src/components/ui/IvaConsole/IvaConsole.ts +144 -0
  32. package/src/components/ui/Link.astro +39 -0
  33. package/src/components/ui/Link.tsx +36 -0
  34. package/src/components/ui/NavLink.astro +46 -0
  35. package/src/components/ui/NavLink.tsx +41 -0
  36. package/src/components/ui/VeevaControls/VeevaControls.astro +48 -0
  37. package/src/components/ui/VeevaControls/VeevaControls.scss +145 -0
  38. package/src/components/ui/VeevaLink.astro +36 -0
  39. package/src/data/pages.tsx +50 -0
  40. package/src/env.d.ts +14 -0
  41. package/src/lib/client/context.ts +45 -0
  42. package/src/lib/client/main.ts +54 -0
  43. package/src/lib/client/readme.md +1 -0
  44. package/src/lib/client/swipe-nav.ts +35 -0
  45. package/src/lib/client/utils.ts +58 -0
  46. package/src/lib/server/readme.md +1 -0
  47. package/src/lib/server/screen.ts +10 -0
  48. package/src/middleware.ts.bak +12 -0
  49. package/src/scss/_mixins.scss +1 -0
  50. package/src/scss/_variables.scss +6 -0
  51. package/src/scss/ipads.scss +89 -0
  52. package/src/shared/img/veeva/veeva-action.png +0 -0
  53. package/src/shared/img/veeva/veeva-desktop-action.png +0 -0
  54. package/src/shared/img/veeva/veeva-desktop-navigation.png +0 -0
  55. package/src/shared/img/veeva/veeva-desktop-next.png +0 -0
  56. package/src/shared/img/veeva/veeva-desktop-previous.png +0 -0
  57. package/src/shared/img/veeva/veeva-highlighter.png +0 -0
  58. package/src/shared/img/veeva/veeva-history-back.png +0 -0
  59. package/src/shared/img/veeva/veeva-history-forward.png +0 -0
  60. package/src/shared/img/veeva/veeva-navigation.png +0 -0
  61. package/src/shared/img/veeva/veeva-reactions.png +0 -0
  62. package/tasks/page-manager.ts +4 -0
  63. package/tasks/util.ts +7 -0
  64. package/tasks/veeva-config.ts +4 -0
  65. package/tasks/veeva-deploy.ts +21 -0
  66. package/tsconfig.json +23 -0
  67. package/veeva-metadata.js +461 -0
@@ -0,0 +1 @@
1
+ Place any shared popup, charts, etc. here, not in `ui`
@@ -0,0 +1,137 @@
1
+ // import React from 'react';
2
+ import type { FunctionComponent } from 'preact';
3
+
4
+ export type ContinuedProps = {
5
+ continued?: boolean;
6
+ }
7
+ export type ListProps = {
8
+ header?: boolean;
9
+ items?: number[];
10
+ };
11
+ export type PluralProps = {
12
+ plural?: boolean;
13
+ };
14
+
15
+ export const Indication: FunctionComponent = () => {
16
+ return (<>
17
+ <h2>Indication</h2>
18
+ <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam leo felis, sollicitudin ut dolor nec, congue maximus urna. Praesent ipsum enim, efficitur quis libero vel, sagittis fringilla lectus. Nunc suscipit.</p>
19
+ </>);
20
+ };
21
+
22
+ export const ImportantSafetyInformation: FunctionComponent<ContinuedProps> = ({ continued = false }) => {
23
+ return <h2>Important Safety Information{continued && <> (cont'd)</>}</h2>;
24
+ };
25
+
26
+ export const BoxedWarning: FunctionComponent<ListProps> = ({ header = true, items = [1,2] }: ListProps = {}) => {
27
+ return (<>
28
+ {header &&
29
+ <h3>BOXED WARNING: DUIS ET VELIT IN NULLA ORNARE RHONCUS. LOREM IPSUM DOLOR SIT AMET, CONSECTETUR ADIPISCING ELIT.</h3>
30
+ }
31
+ {items.length > 0 && (
32
+ <ul>
33
+ {items.includes(1) &&
34
+ <li><strong>Donec viverra condimentum purus, vel tincidunt nisi rutrum quis. Donec vel massa euismod, aliquam ante quis, congue quam. Nulla nec nulla sed nunc finibus semper eget ac est. Ut ultricies eu ante sit amet aliquet. Fusce molestie ipsum dui, quis commodo ipsum volutpat nec. Duis pharetra ullamcorper pellentesque. Nullam et urna id quam egestas ornare mollis quis mi. Suspendisse ultricies.</strong></li>
35
+ }
36
+ {items.includes(2) &&
37
+ <li><strong>Proin nisl tortor, congue nec aliquam ac, fringilla et metus. Morbi sit amet scelerisque mi. Cras velit arcu, condimentum in fermentum nec.</strong></li>
38
+ }
39
+ </ul>
40
+ )}
41
+ </>)
42
+ };
43
+
44
+ export const Contraindications: FunctionComponent<PluralProps> = ({ plural = true, header = true, items = [1,2] }: PluralProps & ListProps = {}) => {
45
+ return (<>
46
+ {header &&
47
+ <h3>Contraindication{plural && (<>s</>)}</h3>
48
+ }
49
+ {items.length > 0 && (
50
+ <>
51
+ {items.includes(1) &&
52
+ <p>Nulla a velit ligula. Aenean ac ligula sit amet neque iaculis rutrum pellentesque sit amet dolor. Pellentesque est lectus, dapibus vel nisl eu, porttitor fringilla magna. Etiam quis convallis nibh, a volutpat dolor. Aliquam congue mi eget euismod dapibus. Aliquam elementum rutrum vestibulum. Etiam iaculis ex tincidunt erat.</p>
53
+ }
54
+ {items.includes(2) &&
55
+ <p>Quisque velit ligula, lobortis vitae commodo eu, consectetur vel nisi. Integer finibus luctus interdum. Curabitur tempus ullamcorper nisi. Ut nibh arcu, iaculis sed mattis sed, aliquet sit amet</p>
56
+ }
57
+ </>
58
+ )}
59
+ </>)
60
+ };
61
+
62
+ export const WarningsPrecautions: FunctionComponent<ListProps> = ({ header = true, items = [1,2,3,4] }: ListProps = {}) => {
63
+ return (<>
64
+ {header &&
65
+ <h3>Warnings and precautions</h3>
66
+ }
67
+ {items.length > 0 && (
68
+ <ul>
69
+ {items.includes(1) &&
70
+ <li>In ac lacus est. Etiam sed ex sed ante dignissim ultricies vitae sit amet lectus. Suspendisse at maximus ex, sit amet vestibulum enim. Vivamus sit amet risus ac justo viverra euismod id vitae massa. Etiam elementum.
71
+ <ul>
72
+ <li>Quisque libero nunc, consequat a odio nec, congue commodo purus.</li>
73
+ <li>Nam quis sodales risus, ut sollicitudin dui. Donec tincidunt mauris non nunc consequat varius.</li>
74
+ <li>Mauris id convallis purus. Donec tempus in dolor.</li>
75
+ </ul>
76
+ </li>
77
+ }
78
+ {items.includes(2) &&
79
+ <li>Mauris ultrices vel tellus nec fermentum. Vivamus nibh sapien, aliquam id leo quis, euismod luctus arcu. Nullam a erat sollicitudin, laoreet sem quis, vulputate est. Curabitur feugiat elementum aliquet. Mauris faucibus blandit mauris. Donec interdum vulputate lorem, quis pellentesque elit mattis a. Proin tincidunt nibh nibh, sit amet ultrices lorem.</li>
80
+ }
81
+ {items.includes(3) &&
82
+ <li>Donec urna nunc, volutpat a iaculis scelerisque, consequat ac erat. Nulla eu nibh finibus, malesuada ante in, facilisis dui. Pellentesque lectus massa, porta non.</li>
83
+ }
84
+ {items.includes(4) &&
85
+ <li>Nam placerat, mauris vel dictum eleifend, augue tellus facilisis lorem, non sodales magna nunc sit amet orci. Proin sit amet sagittis tortor, a fermentum elit. Sed eu porttitor ex. Nunc rutrum in elit feugiat accumsan. Sed congue purus id maximus.</li>
86
+ }
87
+ </ul>
88
+ )}
89
+ </>)
90
+ }
91
+
92
+ export const AdverseReactions: FunctionComponent<ListProps> = ({ header = true, items = [1] }: ListProps = {}) => {
93
+ return (<>
94
+ {header &&
95
+ <h3>Adverse reactions</h3>
96
+ }
97
+ {items.includes(1) &&
98
+ <p>Fusce sit amet vehicula nunc, eu consequat orci. Cras eu est eu arcu congue pulvinar nec ut felis. Sed ornare vulputate ante, nec semper turpis facilisis eu. Etiam tincidunt pulvinar est eu ultrices. In semper maximus lacus, eu congue elit iaculis nec. Ut volutpat venenatis sapien, sit amet cursus mauris. Sed consequat rutrum dolor at venenatis. Duis placerat sagittis dolor vitae malesuada. Vivamus ac nisl nec urna volutpat commodo ac ut est. Quisque fermentum vulputate turpis id tristique. Sed a mauris tincidunt, dictum turpis ut, feugiat urna. Vestibulum tristique, eros eget egestas tincidunt, velit sapien consequat mi, eu pellentesque arcu justo eget risus. Mauris ut urna vel ligula mollis dignissim. Proin tempus est nec laoreet tincidunt. Sed laoreet laoreet ipsum, et viverra dui egestas eget.</p>
99
+ }
100
+ </>)
101
+ }
102
+
103
+ export const DrugInteractions: FunctionComponent<ListProps> = ({ header = true, items = [1,2,3] }: ListProps = {}) => {
104
+ return (<>
105
+ {header &&
106
+ <h3>Drug interactions</h3>
107
+ }
108
+ {items.includes(1) &&
109
+ <p>Integer vehicula auctor pretium. Aenean nibh nunc, mattis nec purus nec, fringilla venenatis nibh. Donec sagittis, metus eget facilisis gravida, justo leo gravida neque, sed semper ante risus quis diam. In tempus aliquet nibh, vel aliquam dolor maximus efficitur. Cras dapibus posuere ante nec tincidunt. Mauris justo elit, bibendum et eros vel, convallis sollicitudin quam. Duis vulputate congue ligula in auctor. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.</p>
110
+ }
111
+ {items.includes(2) &&
112
+ <p>Fusce metus quam, ullamcorper in laoreet vitae, accumsan at sapien. Vestibulum varius sapien in porta dapibus. Phasellus non pharetra mauris. Nunc consectetur nibh aliquam dui accumsan, eu semper mi cursus. Praesent vel erat lorem. Donec ornare lectus nec purus volutpat volutpat. Curabitur justo tortor, molestie vitae commodo in, blandit et eros. Cras vitae arcu vel felis facilisis blandit vel mattis odio. Ut pulvinar congue elit, non interdum nibh malesuada quis. Ut sit amet magna accumsan leo tincidunt laoreet eu quis est. Donec nec lacinia lectus, ut scelerisque urna. Nullam vel aliquet massa. Vivamus in sodales turpis. Donec et sem sollicitudin nisi scelerisque porta. Donec egestas augue eu mauris ultrices consequat. Donec lobortis tellus at lectus tristique commodo.</p>
113
+ }
114
+ {items.includes(3) &&
115
+ <p>Nam vel lectus eu neque tempor pharetra quis sed augue. Integer hendrerit placerat neque ut dictum. Nunc vulputate, metus id congue consequat, ante nunc dignissim purus, non sodales ex odio sed odio. Praesent id nisl dictum, vulputate urna quis, maximus risus. Nullam non ipsum orci. Nulla facilisi. Donec semper dapibus justo, elementum commodo ligula volutpat sit amet. Nam sagittis rhoncus lectus a lacinia. Fusce viverra nisl sed purus vestibulum, a euismod eros scelerisque. Nullam ac arcu dolor. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. In vel lacus ante. Nam volutpat elementum justo, sed lobortis magna egestas sed. Vestibulum mollis elit malesuada viverra suscipit.</p>
116
+ }
117
+ </>)
118
+ }
119
+
120
+ export const PleaseSee: FunctionComponent<ListProps> = ({ header = true, items = [1,2,3] }: ListProps = {}) => {
121
+ return <p>Please see full <a href="#">Prescribing Information</a>, including BOXED WARNING.</p>
122
+ }
123
+
124
+ export const FullISIContent: FunctionComponent = () => {
125
+ return (
126
+ <>
127
+ <ImportantSafetyInformation />
128
+ <BoxedWarning />
129
+ <Contraindications />
130
+ <WarningsPrecautions />
131
+ <AdverseReactions />
132
+ <DrugInteractions />
133
+ <Indication />
134
+ <PleaseSee />
135
+ </>
136
+ );
137
+ }
@@ -0,0 +1,22 @@
1
+ .partial-isi .isi-content,
2
+ .full-isi .isi-content {
3
+ h2 {
4
+ &:first-child {
5
+ margin-top: 0;
6
+ }
7
+ }
8
+
9
+ p:last-child {
10
+ margin-bottom: 0 !important;
11
+ }
12
+ ul {
13
+ &:last-child {
14
+ margin-bottom: 0 !important;
15
+ }
16
+ li {
17
+ &:last-child {
18
+ margin-bottom: 0 !important;
19
+ }
20
+ }
21
+ }
22
+ }
@@ -0,0 +1,20 @@
1
+ ---
2
+ import NavLink from "@components/ui/NavLink.astro";
3
+
4
+ // function hasCurrent(currentPath: string, href: string) {
5
+ // return currentPath.startsWith('hello');
6
+ // }
7
+ // <NavLink href="/about/" class="about" hasCurrent={/some-regexp/}>About</NavLink>
8
+ // <NavLink href="/about/" class="about" hasCurrent={hasCurrent}>About</NavLink>
9
+ ---
10
+ <nav id="main-nav">
11
+ <ul>
12
+ <li><NavLink href="/home/" class="home">Home</NavLink></li>
13
+ <li>
14
+ <NavLink href="/about/" class="about">About</NavLink>
15
+ <ul>
16
+ <li><NavLink href="/about-moa/" class="moa">MOA</NavLink></li>
17
+ </ul>
18
+ </li>
19
+ </ul>
20
+ </nav>
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Are you sure you need to use the TSX component?
3
+ * Try the MainNav.astro component first (this is, after all, an Astro project),
4
+ * but if what you need to do is too complicated use TSX.
5
+ */
6
+ import type { FunctionComponent } from 'preact';
7
+ import NavList, { type NavData } from '../NavList';
8
+
9
+ const data: NavData[] = [{
10
+ href: '/home',
11
+ content: <>Home</>,
12
+ }, {
13
+ href: '/about',
14
+ content: <>About</>,
15
+ attrs: {
16
+ class: 'about',
17
+ 'data-hello': 'world'
18
+ },
19
+ children: [{
20
+ href: '/about/moa',
21
+ content: <>MOA</>
22
+ }]
23
+ }];
24
+
25
+ interface MainNavProps {
26
+ url: URL;
27
+ }
28
+
29
+ const MainNav: FunctionComponent<MainNavProps> = ({ url }: MainNavProps) => {
30
+ return (
31
+ <nav id="main-nav">
32
+ <NavList url={url} data={data} />
33
+ </nav>
34
+ )
35
+ }
36
+ export default MainNav;
@@ -0,0 +1,66 @@
1
+ import { BUILD_TARGET } from 'astro:env/client';
2
+ import type { JSX } from "astro/jsx-runtime";
3
+ import type { FunctionComponent } from 'preact';
4
+ import { flattenPath, pathToSlideZip } from '@inizioevoke/veeva-astroclm-core/lib';
5
+
6
+ export interface NavData {
7
+ href: string;
8
+ content: JSX.Element;
9
+ gotoslide?: string;
10
+ attrs?: Record<string, string>;
11
+ current?: { 'aria-current': boolean };
12
+ children?: NavData[];
13
+ }
14
+
15
+ function initData(data: NavData[], path: string) {
16
+ for (const d of data) {
17
+ const linkPath = flattenPath(d.href);
18
+ d.current = linkPath === path ? { 'aria-current': true } : undefined;
19
+ d.gotoslide = pathToSlideZip(d.href);
20
+ switch (BUILD_TARGET) {
21
+ case 'web':
22
+ d.href = linkPath;
23
+ break;
24
+ case 'veeva':
25
+ default:
26
+ d.href = '#';
27
+ break;
28
+ }
29
+ if (d.children) {
30
+ initData(d.children, path);
31
+ }
32
+ }
33
+ }
34
+
35
+ function renderListItem(item: NavData) {
36
+ return (
37
+ <li>
38
+ <a href={item.href} data-gotoslide={item.gotoslide} {...item.current} {...item.attrs}>{item.content}</a>
39
+ {item.children &&
40
+ renderList(item.children)
41
+ }
42
+ </li>
43
+ )
44
+ }
45
+
46
+ function renderList(list: NavData[]) {
47
+ return (
48
+ <ul>
49
+ {list.map((item) => (
50
+ renderListItem(item)
51
+ ))}
52
+ </ul>
53
+ )
54
+ };
55
+
56
+ interface NavListProps {
57
+ url: URL;
58
+ data: NavData[]
59
+ }
60
+ const NavList: FunctionComponent<NavListProps> = ({ url, data }: NavListProps) => {
61
+ const path = url.pathname.endsWith('/') ? url.pathname : `${url.pathname}/`;
62
+ initData(data, path);
63
+ return renderList(data);
64
+ }
65
+
66
+ export default NavList;
@@ -0,0 +1,19 @@
1
+ ---
2
+ import type { HTMLAttributes } from "astro/types";
3
+ import { dataEvotrkToString } from "@inizioevoke/veeva-astroclm-core/lib";
4
+
5
+ interface Props extends HTMLAttributes<'button'> {
6
+ 'data-evotrk'?: DataEvotrk;
7
+ }
8
+
9
+ const {
10
+ 'data-evotrk': dataEvotrk,
11
+ ...rest
12
+ } = Astro.props;
13
+
14
+ const attrs = {...rest};
15
+ if (dataEvotrk) {
16
+ attrs['data-evotrk'] = dataEvotrkToString(dataEvotrk);
17
+ }
18
+ ---
19
+ <button {...attrs}><slot /></button>
@@ -0,0 +1,36 @@
1
+ ---
2
+ import type { ImageMetadata, ImageOutputFormat } from "astro";
3
+ import type { HTMLAttributes } from "astro/types";
4
+ import { getImage } from 'astro:assets';
5
+
6
+ interface Props extends Omit<HTMLAttributes<'img'>, 'src'> {
7
+ src: ImageMetadata;
8
+ format?: ImageOutputFormat;
9
+ width?: number;
10
+ height?: number;
11
+ quality?: number;
12
+ alt?: string;
13
+ }
14
+
15
+ const {
16
+ src,
17
+ format,
18
+ width,
19
+ height,
20
+ quality = 80,
21
+ alt = '',
22
+ ...rest
23
+ } = Astro.props;
24
+
25
+ const image = await getImage({ src, quality, format: format ?? src.format });
26
+
27
+ const imageWidth = width ?? (height ? Math.round(height * image.attributes.width / image.attributes.height) : image.attributes.width);
28
+ const imageHeight = height ?? (width ? Math.round(width * image.attributes.height / image.attributes.width) : image.attributes.height);
29
+
30
+ const attrs = {
31
+ ...image.attributes,
32
+ ...rest
33
+ }
34
+ delete attrs.loading;
35
+ ---
36
+ <img src={image.src} width={imageWidth} height={imageHeight} alt={alt} loading="eager" {...attrs} />
@@ -0,0 +1,12 @@
1
+ ---
2
+ import {LOG_LEVEL, LOG_OUTPUT} from 'astro:env/client';
3
+ import './IvaConsole.scss'
4
+ ---
5
+ {LOG_LEVEL !== 'disabled' && LOG_OUTPUT === 'screen' &&
6
+ <template id="template-iva-console">
7
+ <div id="iva-console">
8
+ <textarea id="iva-console-output"></textarea>
9
+ <button class="evotrk-ignore">X</button>
10
+ </div>
11
+ </template>
12
+ }
@@ -0,0 +1,62 @@
1
+ #iva-console {
2
+ position: fixed;
3
+ left: 5vw;
4
+ top: 5vh;
5
+ display: block;
6
+ width: 90vw;
7
+ height: 90vh;
8
+ z-index: 2147483647;
9
+
10
+ &.hidden {
11
+ display: none;
12
+ }
13
+
14
+ button {
15
+ position: absolute;
16
+ right: 0;
17
+ top: 0;
18
+ width: 40px;
19
+ height: 40px;
20
+ padding: 0;
21
+ font-size: 20px;
22
+ font-weight: bold;
23
+ line-height: 40px;
24
+ font-family: monospace;
25
+ text-align: left;
26
+ text-indent: -9999px;
27
+ color: white;
28
+ background-color: red;
29
+ border: none;
30
+ cursor: pointer;
31
+ &::before,
32
+ &::after {
33
+ content: "";
34
+ position: absolute;
35
+ left: 10px;
36
+ top: 19px;
37
+ width: 20px;
38
+ height: 2px;
39
+ background-color: white;
40
+ }
41
+ &::before {
42
+ transform: rotate(45deg);
43
+ }
44
+ &::after {
45
+ transform: rotate(-45deg);
46
+ }
47
+ }
48
+
49
+ textarea {
50
+ position: absolute;
51
+ left: 0;
52
+ top: 0;
53
+ width: 100%;
54
+ height: 100%;
55
+ padding: 40px;
56
+ color: white;
57
+ font-size: 16px;
58
+ font-family: monospace;
59
+ border: none;
60
+ background-color: rgba(0, 0, 0, 0.95);
61
+ }
62
+ }
@@ -0,0 +1,144 @@
1
+ import { BUILD_TARGET, LOG_LEVEL, LOG_OUTPUT, LOG_TIME } from "astro:env/client";
2
+ import type { LogLevel } from '@inizioevoke/veeva-astroclm-core/types';
3
+
4
+ const enabled = LOG_LEVEL !== 'disabled';
5
+ let ivaConsole = document.getElementById('iva-console');
6
+
7
+ export function showLog() {
8
+ ivaConsole?.classList.remove('hidden');
9
+ }
10
+
11
+ export function logError(message: string, err?: any): void;
12
+ export function logError(source: string, message: string, err?: any): void;
13
+ export function logError() {
14
+ const args = getLogArgs(...arguments);
15
+ if (args) {
16
+ log.apply(null, ['error', ...args]);
17
+ }
18
+ }
19
+
20
+ export function logDebug(message: string, data?: any): void;
21
+ export function logDebug(source: string, message: string, data?: any): void;
22
+ export function logDebug() {
23
+ const args = getLogArgs(...arguments);
24
+ if (args) {
25
+ log.apply(null, ['debug', ...args]);
26
+ }
27
+ }
28
+
29
+ function log(level: LogLevel, source: string | null | undefined, message: string | null | undefined, data?: any) {
30
+ let shouldLog = false;
31
+ switch (level) {
32
+ case 'debug':
33
+ shouldLog = enabled && /debug/.test(LOG_LEVEL);
34
+ break;
35
+ case 'error':
36
+ shouldLog = enabled && /(debug|error)/.test(LOG_LEVEL);
37
+ break;
38
+ }
39
+ if (shouldLog) {
40
+ let now: string | null = null; // new Date().toISOString();
41
+ switch (LOG_TIME) {
42
+ case 'date':
43
+ now = new Date().toISOString().substring(0, 10);
44
+ break;
45
+ case 'time':
46
+ now = new Date().toISOString().substring(11, 23);
47
+ break;
48
+ case 'datetime':
49
+ now = new Date().toISOString()
50
+ break;
51
+ case 'performance':
52
+ now = performance.now().toString();
53
+ break;
54
+ }
55
+ const msg = `${now ? `[${now}] ` : ''}${level.toUpperCase()}: ${source ?? ''}${source ? ' | ' : ''}${message ?? ''}`;
56
+
57
+ switch (LOG_OUTPUT) {
58
+ case 'screen': {
59
+ if (!ivaConsole) {
60
+ const template = document.getElementById('template-iva-console') as (HTMLTemplateElement | null);
61
+ if (template) {
62
+ document.body.append(template.content.cloneNode(true));
63
+ ivaConsole = document.getElementById('iva-console');
64
+ ivaConsole?.querySelector('button')?.addEventListener('click', (e) => {
65
+ e.preventDefault();
66
+ ivaConsole?.classList.add('hidden');
67
+ });
68
+ }
69
+ }
70
+ if (ivaConsole) {
71
+ let textarea = ivaConsole.querySelector('textarea') as HTMLTextAreaElement;
72
+ let screenData = '';
73
+ if (data !== undefined) {
74
+ if (data instanceof Error) {
75
+ screenData = `${data.name} | ${data.message}`;
76
+ if (data.stack) {
77
+ screenData = `${screenData}\nUncaught ${data.stack}`
78
+ }
79
+ } else if (typeof data != 'string') {
80
+ screenData = JSON.stringify(data, null, 2);
81
+ }
82
+ screenData = `> ${screenData.replace(/\n/g, '\n> ')}`;
83
+ }
84
+ textarea.value += `${msg}\n${data !== undefined ? `${screenData}\n` : ''}`;
85
+ ivaConsole.classList.remove('hidden');
86
+ }
87
+ }
88
+ // intentionally fallthrough
89
+ case 'console':
90
+ if (BUILD_TARGET === 'web') {
91
+ data !== undefined ? console.log(msg, data) : console.log(msg);
92
+ }
93
+ break;
94
+ }
95
+ }
96
+ }
97
+
98
+ function getLogArgs(...args: any[]): undefined | [string | undefined, string | undefined, any] {
99
+ let source: string | undefined;
100
+ let message: string | undefined;
101
+ let data: any = undefined;
102
+ switch (args.length) {
103
+ case 0:
104
+ return undefined;
105
+ case 1:
106
+ switch (typeof args[0]) {
107
+ case 'string':
108
+ message = args[0];
109
+ break;
110
+ default:
111
+ data = args[0];
112
+ break;
113
+ }
114
+ break;
115
+ case 2:
116
+ switch (typeof(args[1])) {
117
+ case 'string':
118
+ source = args[0];
119
+ message = args[1];
120
+ break;
121
+ default:
122
+ message = args[0];
123
+ data = args[1];
124
+ break;
125
+ }
126
+ break;
127
+ default: {
128
+ source = args[0];
129
+ message = args[1];
130
+ data = args[2];
131
+ break;
132
+ }
133
+ }
134
+ return [source, message, data];
135
+ }
136
+
137
+ if (BUILD_TARGET === 'veeva' && LOG_OUTPUT === 'screen') {
138
+ window.addEventListener('error', (e) => {
139
+ logError(e.message, e.error);
140
+ });
141
+ window.addEventListener('unhandledrejection', (e) => {
142
+ logError('Unhandled Promise rejection', e.reason);
143
+ });
144
+ }
@@ -0,0 +1,39 @@
1
+ ---
2
+ import type { HTMLAttributes } from "astro/types";
3
+ import { BUILD_TARGET } from 'astro:env/client';
4
+ import { flattenPath, pathToSlideZip, dataEvotrkToString } from "@inizioevoke/veeva-astroclm-core/lib";
5
+ import type { PageHref } from '@data/pages';
6
+
7
+ export interface Props extends HTMLAttributes<'a'> {
8
+ href: PageHref | (string & {});
9
+ 'data-evotrk'?: DataEvotrk;
10
+ }
11
+
12
+ const { href, 'data-evotrk': dataEvotrk, ...rest } = Astro.props;
13
+
14
+ const attrs: HTMLAttributes<'a'> & { ['data-gotoslide']?: string } = {
15
+ ...rest
16
+ };
17
+
18
+ const currentPath = Astro.url.pathname;
19
+
20
+ if (/^(?:https?:\/\/|(?:\.*\/)*shared\/)/i.test(href)) {
21
+ attrs.href = href;
22
+ } else {
23
+ attrs['data-gotoslide'] = pathToSlideZip(href);
24
+
25
+ const linkPath = flattenPath(href);
26
+
27
+ attrs.href = BUILD_TARGET === 'web' ? linkPath : '#';
28
+
29
+ if (linkPath === currentPath) {
30
+ attrs['aria-current'] = 'true';
31
+ }
32
+ }
33
+
34
+ if (dataEvotrk) {
35
+ attrs['data-evotrk'] = dataEvotrkToString(dataEvotrk);
36
+ }
37
+
38
+ ---
39
+ <a {...attrs}><slot /></a>
@@ -0,0 +1,36 @@
1
+ import type { ComponentProps } from 'preact';
2
+ import { BUILD_TARGET } from 'astro:env/client';
3
+ import { flattenPath, pathToSlideZip, dataEvotrkToString } from '@inizioevoke/veeva-astroclm-core/lib';
4
+ import type { PageHref } from '@data/pages';
5
+
6
+ interface LinkProps extends ComponentProps<'a'> {
7
+ href: PageHref | (string & {});
8
+ 'data-evotrk'?: DataEvotrk;
9
+ currentPath?: string;
10
+ }
11
+
12
+ const Link = ({ href, 'data-evotrk': dataEvotrk, currentPath, children, ...rest }: LinkProps) => {
13
+ const attrs: ComponentProps<'a'> & { 'data-gotoslide'?: string; 'data-evotrk'?: string } = { ...rest };
14
+
15
+ if (/^(?:https?:\/\/|(?:\.*\/)*shared\/)/i.test(href)) {
16
+ attrs.href = href;
17
+ } else {
18
+ attrs['data-gotoslide'] = pathToSlideZip(href);
19
+
20
+ const linkPath = flattenPath(href);
21
+
22
+ attrs.href = BUILD_TARGET === 'web' ? linkPath : '#';
23
+
24
+ if (currentPath && linkPath === currentPath) {
25
+ attrs['aria-current'] = 'true';
26
+ }
27
+ }
28
+
29
+ if (dataEvotrk) {
30
+ attrs['data-evotrk'] = dataEvotrkToString(dataEvotrk);
31
+ }
32
+
33
+ return <a {...attrs}>{children}</a>;
34
+ };
35
+
36
+ export default Link;