@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,46 @@
1
+ ---
2
+ import type { HTMLAttributes } from "astro/types";
3
+ import { flattenPath } from "@inizioevoke/veeva-astroclm-core/lib";
4
+ import Link, { type Props as LinkProps } from './Link.astro';
5
+
6
+ type HasCurrentCallback = (pathname: string, href: string) => boolean;
7
+
8
+ interface Props extends LinkProps {
9
+ hasCurrent?: string | RegExp | HasCurrentCallback;
10
+ }
11
+
12
+ const {
13
+ hasCurrent,
14
+ href,
15
+ ...rest
16
+ } = Astro.props;
17
+
18
+ const attrs: Omit<HTMLAttributes<'a'>, 'href'> = {
19
+ ...rest
20
+ };
21
+
22
+ const currentPath = Astro.url.pathname;
23
+
24
+ if (!/^(?:https?:\/\/|(?:\.*\/)*shared\/)/i.test(href)) {
25
+ const linkPath = flattenPath(href);
26
+
27
+ let current = false;
28
+ if (linkPath === currentPath) {
29
+ current = true;
30
+ attrs['aria-current'] = 'true';
31
+ } else if (hasCurrent) {
32
+ if (typeof hasCurrent == 'string') {
33
+ current = currentPath.startsWith(hasCurrent);
34
+ } else if (typeof hasCurrent == 'function') {
35
+ current = hasCurrent(currentPath, href);
36
+ } else if (hasCurrent instanceof RegExp) {
37
+ current = hasCurrent.test(currentPath);
38
+ }
39
+ }
40
+ if (current) {
41
+ attrs['data-current'] = 'true';
42
+ }
43
+ }
44
+
45
+ ---
46
+ <Link href={href} {...attrs}><slot /></Link>
@@ -0,0 +1,41 @@
1
+ import type { ComponentProps } from 'preact';
2
+ import { flattenPath } from '@inizioevoke/veeva-astroclm-core/lib';
3
+ import Link from './Link';
4
+ import type { PageHref } from '@data/pages';
5
+
6
+ type HasCurrentCallback = (pathname: string, href: string) => boolean;
7
+
8
+ interface NavLinkProps extends ComponentProps<typeof Link> {
9
+ href: PageHref | (string & {});
10
+ hasCurrent?: string | RegExp | HasCurrentCallback;
11
+ }
12
+
13
+ const NavLink = ({ hasCurrent, href, currentPath, children, ...rest }: NavLinkProps) => {
14
+ const attrs: Omit<ComponentProps<typeof Link>, 'href'> & { 'data-current'?: string } = { ...rest };
15
+
16
+ if (!/^(?:https?:\/\/|(?:\.*\/)*shared\/)/i.test(href)) {
17
+ const linkPath = flattenPath(href);
18
+
19
+ let current = false;
20
+ if (currentPath && linkPath === currentPath) {
21
+ current = true;
22
+ attrs['aria-current'] = 'true';
23
+ } else if (hasCurrent && currentPath) {
24
+ if (typeof hasCurrent === 'string') {
25
+ current = currentPath.startsWith(hasCurrent);
26
+ } else if (typeof hasCurrent === 'function') {
27
+ current = hasCurrent(currentPath, href);
28
+ } else if (hasCurrent instanceof RegExp) {
29
+ current = hasCurrent.test(currentPath);
30
+ }
31
+ }
32
+
33
+ if (current) {
34
+ attrs['data-current'] = 'true';
35
+ }
36
+ }
37
+
38
+ return <Link href={href} currentPath={currentPath} {...attrs}>{children}</Link>;
39
+ };
40
+
41
+ export default NavLink;
@@ -0,0 +1,48 @@
1
+ ---
2
+ import Image from '@components/ui/Image.astro';
3
+ import imgAction from '@shared/img/veeva/veeva-action.png';
4
+ import imgHighlighter from '@shared/img/veeva/veeva-highlighter.png';
5
+ import imgHistoryBack from '@shared/img/veeva/veeva-history-back.png';
6
+ import imgHistoryForward from '@shared/img/veeva/veeva-history-forward.png';
7
+ import imgReactions from '@shared/img/veeva/veeva-reactions.png';
8
+ import imgNavigation from '@shared/img/veeva/veeva-navigation.png';
9
+ import imgDesktopAction from '@shared/img/veeva/veeva-desktop-action.png';
10
+ import imgDesktopPrevious from '@shared/img/veeva/veeva-desktop-previous.png';
11
+ import imgDesktopNext from '@shared/img/veeva/veeva-desktop-next.png';
12
+ import imgDesktopNavigation from '@shared/img/veeva/veeva-desktop-navigation.png';
13
+
14
+ import './VeevaControls.scss';
15
+
16
+ interface Props {
17
+ highlighter?: boolean | 'true' | 'false';
18
+ history?: boolean | 'true' | 'false';
19
+ reactions?: boolean | 'true' | 'false';
20
+ navigation?: boolean | 'true' | 'false';
21
+ }
22
+
23
+ function shouldInclude(value: boolean | string | undefined) {
24
+ return typeof value == 'string' ? value.trim().toLowerCase() !== 'false' : value !== false;
25
+ }
26
+ const highlighter = shouldInclude(Astro.props.highlighter);
27
+ const history = shouldInclude(Astro.props.history);
28
+ const reactions = shouldInclude(Astro.props.reactions);
29
+ const navigation = shouldInclude(Astro.props.navigation);
30
+ ---
31
+ <div id="veeva-action" class="veeva-control"><Image src={imgAction} /></div>
32
+ { highlighter &&
33
+ <div id="veeva-highlighter" class="veeva-control"><Image src={imgHighlighter} /></div>
34
+ }
35
+ { history &&
36
+ <div id="veeva-history-back" class:list={['veeva-control', highlighter ? 'veeva-has-highlighter' : '']}><Image src={imgHistoryBack} /></div>
37
+ <div id="veeva-history-forward" class:list={['veeva-control', highlighter ? 'veeva-has-highlighter' : '']}><Image src={imgHistoryForward} /></div>
38
+ }
39
+ { reactions &&
40
+ <div id="veeva-reactions" class="veeva-control"><Image src={imgReactions} /></div>
41
+ }
42
+ { navigation &&
43
+ <div id="veeva-navigation" class="veeva-control"><Image src={imgNavigation} /></div>
44
+ }
45
+ <div id="veeva-desktop-action" class="veeva-desktop-control"><Image src={imgDesktopAction} /></div>
46
+ <div id="veeva-desktop-previous" class="veeva-desktop-control"><Image src={imgDesktopPrevious} /></div>
47
+ <div id="veeva-desktop-next" class="veeva-desktop-control"><Image src={imgDesktopNext} /></div>
48
+ <div id="veeva-desktop-navigation" class="veeva-desktop-control"><Image src={imgDesktopNavigation} /></div>
@@ -0,0 +1,145 @@
1
+ @use "../../../scss/variables" as vars;
2
+ /**
3
+ * **********************************************************************
4
+ * DO NOT, FOR ANY REASON, CHANGE ANY STYLE OF THESE VEEVA BUTTONS
5
+ * **********************************************************************
6
+ * If you received a request to change the style of one of these
7
+ * buttons, your response should be "Sorry, we can't change that."
8
+ * If the requester persists, please direct them to CJ.
9
+ * **********************************************************************
10
+ */
11
+ #veeva-action,
12
+ #veeva-highlighter,
13
+ #veeva-history-back,
14
+ #veeva-history-forward,
15
+ #veeva-reactions,
16
+ #veeva-navigation {
17
+ position: absolute;
18
+ display: block;
19
+ z-index: 2147483647;
20
+
21
+ img {
22
+ display: block;
23
+ }
24
+ }
25
+ #veeva-desktop-action,
26
+ #veeva-desktop-previous,
27
+ #veeva-desktop-next,
28
+ #veeva-desktop-navigation {
29
+ display: none;
30
+ }
31
+
32
+ #veeva-action {
33
+ left: 8px;
34
+ top: 17px;
35
+ width: 28px;
36
+ height: 10px;
37
+
38
+ img {
39
+ width: 28px;
40
+ height: 10px;
41
+ }
42
+ }
43
+
44
+ #veeva-highlighter {
45
+ left: 50px;
46
+ top: 6px;
47
+ width: 33px;
48
+ height: 33px;
49
+
50
+ img {
51
+ width: 33px;
52
+ height: 33px;
53
+ }
54
+ }
55
+
56
+ #veeva-history-back,
57
+ #veeva-history-forward {
58
+ top: 12px;
59
+ width: 14px;
60
+ height: 22px;
61
+
62
+ img {
63
+ width: 14px;
64
+ height: 22px;
65
+ }
66
+ }
67
+
68
+ #veeva-history-back {
69
+ left: 52px;
70
+
71
+ &.veeva-has-highlighter {
72
+ left: 98px;
73
+ }
74
+ }
75
+
76
+ #veeva-history-forward {
77
+ left: 91px;
78
+
79
+ &.veeva-has-highlighter {
80
+ left: 137px;
81
+ }
82
+ }
83
+
84
+ #veeva-reactions {
85
+ left: 16px;
86
+ top: 54px;
87
+ width: 12px;
88
+ height: 88px;
89
+
90
+ img {
91
+ width: 12px;
92
+ height: 88px;
93
+ }
94
+ }
95
+
96
+ #veeva-navigation {
97
+ left: 5px;
98
+ bottom: 30px;
99
+ width: 34px;
100
+ height: 30px;
101
+
102
+ img {
103
+ width: 34px;
104
+ height: 30px;
105
+ }
106
+ }
107
+
108
+ @media screen and (min-width: 1920px) and (min-height: 1080px) { // (min-width: #{vars.$screen-width * 1.25}) and (min-height: #{vars.$screen-height * 1.25}) {
109
+ #veeva-action,
110
+ #veeva-highlighter,
111
+ #veeva-history-back,
112
+ #veeva-history-forward,
113
+ #veeva-reactions,
114
+ #veeva-navigation {
115
+ display: none;
116
+ }
117
+ #veeva-desktop-action,
118
+ #veeva-desktop-previous,
119
+ #veeva-desktop-next,
120
+ #veeva-desktop-navigation {
121
+ position: fixed;
122
+ display: block;
123
+ width: 32px;
124
+ height: 32px;
125
+ z-index: 2147483647;
126
+
127
+ img {
128
+ display: block;
129
+ width: 32px;
130
+ height: 32px;
131
+ }
132
+ }
133
+ #veeva-desktop-action,
134
+ #veeva-desktop-previous,
135
+ #veeva-desktop-next {
136
+ top: 8px;
137
+ }
138
+ #veeva-desktop-action { left: 8px; }
139
+ #veeva-desktop-previous { left: 48px; }
140
+ #veeva-desktop-next { left: 88px; }
141
+ #veeva-desktop-navigation {
142
+ left: 4px;
143
+ bottom: 5px;
144
+ }
145
+ }
@@ -0,0 +1,36 @@
1
+ ---
2
+ import type { HTMLAttributes } from "astro/types";
3
+ import { dataEvotrkToString } from "@inizioevoke/veeva-astroclm-core/lib";
4
+
5
+ interface Props extends HTMLAttributes<'a'> {
6
+ slide: string;
7
+ presentation?: string;
8
+ 'data-evotrk'?: DataEvotrk;
9
+ }
10
+
11
+ const {
12
+ slide,
13
+ presentation,
14
+ 'data-evotrk': dataEvotrk,
15
+ ...rest
16
+ } = Astro.props;
17
+
18
+ type VeevaLinkAttrs = HTMLAttributes<'a'> & {
19
+ ['data-gotoslide']?: string;
20
+ ['data-evotrk']?: string;
21
+ }
22
+
23
+ const attrs: VeevaLinkAttrs = {
24
+ ...rest
25
+ };
26
+ attrs.href = '#';
27
+
28
+
29
+ attrs['data-gotoslide'] = `${slide}${presentation ? `,${presentation}` : ''}`;
30
+
31
+ if (dataEvotrk) {
32
+ attrs['data-evotrk'] = dataEvotrkToString(dataEvotrk);
33
+ }
34
+
35
+ ---
36
+ <a {...attrs}><slot /></a>
@@ -0,0 +1,50 @@
1
+ import type { FunctionComponent } from "preact";
2
+ import type { JSX } from "preact/jsx-runtime";
3
+ import { flattenPath } from '@inizioevoke/veeva-astroclm-core/lib';
4
+
5
+ interface Page {
6
+ title: JSX.Element;
7
+ href: string;
8
+ }
9
+
10
+ const Pages = [] as const satisfies Page[];
11
+
12
+ // ----------------------------------------------------------------------------------------------------
13
+
14
+ export type PageHref = (typeof Pages)[number]["href"] extends `/${infer S}/` ? S : never;
15
+
16
+ export interface PageElement {
17
+ title: JSX.Element,
18
+ href: PageHref
19
+ }
20
+
21
+ export interface PageComponent {
22
+ title: FunctionComponent;
23
+ href: string;
24
+ }
25
+
26
+ export function toPageComponent(page: PageElement): PageComponent {
27
+ return {
28
+ ...page,
29
+ title: () => { return page.title; }
30
+ };
31
+ }
32
+
33
+ export const PageElements: PageElement[] = Pages.map((p) => {
34
+ return {
35
+ ...p,
36
+ href: p.href as PageHref
37
+ }
38
+ });
39
+
40
+ export const PageComponents: PageComponent[] = PageElements.map((p) => {
41
+ return toPageComponent(p);
42
+ });
43
+
44
+ export function getPageElement<T = PageElement | undefined>(href: PageHref | (string & {})): T {
45
+ return PageElements.find(p => p.href == flattenPath(href)) as T;
46
+ }
47
+
48
+ export function getPageComponent<T = PageComponent | undefined>(href: PageHref | (string & {})): T {
49
+ return PageComponents.find(p => p.href == flattenPath(href)) as T;
50
+ }
package/src/env.d.ts ADDED
@@ -0,0 +1,14 @@
1
+ interface Window {
2
+
3
+ }
4
+
5
+ interface GlobalLayoutProps {
6
+ title?: string;
7
+ class?: string;
8
+ }
9
+
10
+ interface DataEvotrk {
11
+ slide?: string;
12
+ type?: string;
13
+ name?: string;
14
+ }
@@ -0,0 +1,45 @@
1
+ // TODO: Make sure your project uses a unique session item name since all Veeva IVAs share the same session
2
+ const SES_CONTEXT = 'iva-context';
3
+
4
+ // TODO: Set your item key names
5
+ type ContextItemKey = 'item' | (string & {});
6
+
7
+ interface ContextItem {
8
+ expires: boolean | number;
9
+ value: any;
10
+ }
11
+
12
+ export function getContextItem<T>(key: ContextItemKey): T | undefined {
13
+ const item = _getContext(key);
14
+ if (!item) {
15
+ return undefined;
16
+ }
17
+ if (typeof item.expires === 'number' && Date.now() > item.expires) {
18
+ removeContextItem(key);
19
+ return undefined;
20
+ }
21
+ if (item.expires === true) {
22
+ _removeContext(key);
23
+ }
24
+ return item.value as T;
25
+ }
26
+
27
+ export function setContextItem(key: ContextItemKey, value: any, { expires = false }: { expires?: boolean | number } = {}) {
28
+ _setContext(key, { value, expires });
29
+ }
30
+
31
+ export function removeContextItem(key: ContextItemKey) {
32
+ _removeContext(key)
33
+ }
34
+
35
+
36
+ function _getContext(key: string): ContextItem | undefined {
37
+ const raw = sessionStorage.getItem(`${SES_CONTEXT}__${key.replace(/[^a-z0-9]/gi, '')}`);
38
+ return raw ? JSON.parse(raw) as ContextItem : undefined;
39
+ }
40
+ function _setContext(key: string, context: ContextItem) {
41
+ sessionStorage.setItem(`${SES_CONTEXT}__${key.replace(/[^a-z0-9]/gi, '')}`, JSON.stringify(context));
42
+ }
43
+ function _removeContext(key: string) {
44
+ sessionStorage.removeItem(`${SES_CONTEXT}__${key.replace(/[^a-z0-9]/gi, '')}`);
45
+ }
@@ -0,0 +1,54 @@
1
+ import { BUILD_TARGET, VEEVA_ENV, WEB_SCALING } from 'astro:env/client';
2
+ import * as IVA from '@inizioevoke/veeva-iva';
3
+ import { logError, logDebug } from '@components/ui/IvaConsole/IvaConsole';
4
+ // import swipeNav, { type SwipeNavLink, type SwipeType } from './swipe-nav';
5
+
6
+ IVA.init({
7
+ isWebEnv: BUILD_TARGET === 'web',
8
+ isSandboxEnv: VEEVA_ENV === 'evoke',
9
+
10
+ preTrack: async ({ data, event }: IVA.PreTrackHandlerParams) => {
11
+ data.name = `${data.type}_${data.name}`;
12
+ if (BUILD_TARGET === 'web') {
13
+ logDebug('track', data);
14
+ }
15
+ return data;
16
+ },
17
+ onError: ({ source, message, error }: IVA.OnErrorHandlerParams) => {
18
+ logError(source, message, error);
19
+ }
20
+ });
21
+
22
+ /*
23
+ * CUSTOM SWIPE
24
+ * If using the custom swipe, figure out which page to go to when swiping.
25
+ * This is only example. Create something different for your IVA.
26
+ */
27
+ // const swipeOrder = [
28
+ // ['/home/', 'home.zip'],
29
+ // ['/about/', 'about.zip'],
30
+ // ['/about-moa/', 'about-moa.zip']
31
+ // ];
32
+ // swipeNav({
33
+ // threshold: '1/4',
34
+ // handler: (type) => {
35
+ // let link: SwipeNavLink | undefined = undefined;
36
+ // const i = swipeOrder.findIndex(o => o[0] === location.pathname);
37
+ // if (i !== -1) {
38
+ // if (type === 'previous') {
39
+ // if (i > 0) {
40
+ // link = {
41
+ // href: swipeOrder[i-1][0],
42
+ // slide: swipeOrder[i-1][1]
43
+ // };
44
+ // }
45
+ // } else if (i < swipeOrder.length - 1) {
46
+ // link = {
47
+ // href: swipeOrder[i+1][0],
48
+ // slide: swipeOrder[i+1][1]
49
+ // };
50
+ // }
51
+ // }
52
+ // return link;
53
+ // }
54
+ // });
@@ -0,0 +1 @@
1
+ Add any scripts that are needed at runtime by the browser in this directory
@@ -0,0 +1,35 @@
1
+ import { navigate, track, getSlideData, type AnalyticsEventData } from "@inizioevoke/veeva-iva";
2
+ import { logDebug } from '@components/ui/IvaConsole/IvaConsole';
3
+ import { createSwipeListener, type SwipeThreshold } from '@inizioevoke/astro-core/lib/gestures/swipe';
4
+
5
+ export type SwipeType = 'previous' | 'next';
6
+
7
+ export interface SwipeNavLink {
8
+ href: string;
9
+ slide: string;
10
+ presentation?: string;
11
+ analytics?: AnalyticsEventData;
12
+ }
13
+
14
+ export type SwipeHandler = (type: SwipeType) => SwipeNavLink | undefined;
15
+ interface SwipeNavProps {
16
+ handler: SwipeHandler;
17
+ threshold?: SwipeThreshold;
18
+ debug?: boolean;
19
+ }
20
+ export default function({ handler, threshold = '1/3', debug }: SwipeNavProps) {
21
+ createSwipeListener('left-right', threshold, async (e) => {
22
+ const type: SwipeType = e.direction === 'left' ? 'next' : 'previous';
23
+ const link = handler(type);
24
+ if (link) {
25
+ await track({ slide: getSlideData(), type: 'swipe', name: type, ...link.analytics ?? {} });
26
+ if (debug) {
27
+ logDebug('SwipeNav: navigate', link);
28
+ } else {
29
+ navigate(link);
30
+ }
31
+ } else {
32
+ logDebug('SwipeNav: no link');
33
+ }
34
+ });
35
+ }
@@ -0,0 +1,58 @@
1
+ export const documentReady = (() => {
2
+ const p = new Promise<void>((resolve) => {
3
+ document.addEventListener('DOMContentLoaded', (e) => { resolve(); }, { passive: true });
4
+ });
5
+ return () => {
6
+ return p;
7
+ };
8
+ })();
9
+
10
+ export function getQueryStringParams(): Record<string, string | null | (string|null)[]> {
11
+ const qs: Record<string, string | null | (string|null)[]> = {};
12
+ if (location.search) {
13
+ const pairs = location.search.substring(1).split('&');
14
+ for (const pair of pairs) {
15
+ const [ key, val ] = pair.split('=');
16
+ if (qs[key] === undefined) {
17
+ qs[key] = val !== 'null' ? val : null;
18
+ } else {
19
+ if (!Array.isArray(qs[key])) {
20
+ qs[key] = [qs[key]];
21
+ }
22
+ qs[key].push(val);
23
+ }
24
+ }
25
+ }
26
+ return qs;
27
+ }
28
+
29
+ export function getQueryStringParam(key: string): string | null | (string|null)[] | undefined {
30
+ return getQueryStringParams()[key];
31
+ }
32
+
33
+ export function isScreenshotMode() {
34
+ return getQueryStringParam('screenshots') === 'true';
35
+ }
36
+
37
+ export function parse(type: 'json', val: any): any | undefined;
38
+ export function parse(type: 'number', val: string, radix?: number): number | undefined;
39
+ export function parse(type: 'json' | 'number', val: any, radix = 10): any {
40
+ switch (type) {
41
+ case 'json':
42
+ return typeof val == 'string' ? JSON.parse(val) : undefined;
43
+ case 'number':
44
+ return parseInt(val, radix);
45
+ default:
46
+ return val;
47
+ }
48
+ }
49
+
50
+ export function pageId(): string | undefined {
51
+ return document.querySelector('meta[property="page:id"]')?.getAttribute('content') ?? undefined;
52
+ }
53
+ export function pagePath(): string | undefined {
54
+ return document.querySelector('meta[property="page:path"]')?.getAttribute('content') ?? undefined;
55
+ }
56
+ export function veevaZip(): string | undefined {
57
+ return document.querySelector('meta[property="veeva:zip"]')?.getAttribute('content') ?? undefined;
58
+ }
@@ -0,0 +1 @@
1
+ Add any scripts that are needed when Astro is rendering HTML in this directory
@@ -0,0 +1,10 @@
1
+ import source from '../../scss/_variables.scss?raw';
2
+
3
+ const parsePx = (name: string): number => {
4
+ const match = source.match(new RegExp(`\\$${name}\\s*:\\s*(\\d+)px`));
5
+ if (!match) throw new Error(`screen.ts: could not find $${name} in _variables.scss`);
6
+ return Number(match[1]);
7
+ };
8
+
9
+ export const SCREEN_WIDTH = parsePx('screen-width');
10
+ export const SCREEN_HEIGHT = parsePx('screen-height');
@@ -0,0 +1,12 @@
1
+ import { defineMiddleware } from "astro:middleware";
2
+
3
+ export const onRequest = defineMiddleware((context, next) => {
4
+ const url = new URL(context.request.url);
5
+
6
+ // Map ./dir to /dir
7
+ if (url.pathname.startsWith('./dir')) {
8
+ return context.rewrite(url.pathname.replace('./dir', '/dir'));
9
+ }
10
+
11
+ return next();
12
+ });
@@ -0,0 +1 @@
1
+ @use './variables' as vars;
@@ -0,0 +1,6 @@
1
+ // $screen-width and $screen-height are parsed at build time by src/lib/server/screen.ts
2
+ // and passed to ResizeScript in GlobalLayout.astro. Keep the format as `$name: <int>px;`
3
+ // on a single line — the regex expects a literal integer followed by `px`.
4
+ $screen-width: 1366px;
5
+ $screen-height: 1024px;
6
+ $veeva-controls-height: 40px;