lytx 0.3.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 (213) hide show
  1. package/.env.example +37 -0
  2. package/README.md +486 -0
  3. package/alchemy.run.ts +155 -0
  4. package/cli/bootstrap-admin.ts +284 -0
  5. package/cli/deploy-staging.ts +692 -0
  6. package/cli/import-events.ts +628 -0
  7. package/cli/import-sites.ts +518 -0
  8. package/cli/index.ts +609 -0
  9. package/cli/init-db.ts +269 -0
  10. package/cli/migrate-to-durable-objects.ts +564 -0
  11. package/cli/migration-worker.ts +300 -0
  12. package/cli/performance-test.ts +588 -0
  13. package/cli/pg/client.ts +4 -0
  14. package/cli/pg/new-site.ts +153 -0
  15. package/cli/rollback-durable-objects.ts +622 -0
  16. package/cli/seed-data.ts +459 -0
  17. package/cli/setup.js +18 -0
  18. package/cli/setup.ts +463 -0
  19. package/cli/validate-migration.ts +200 -0
  20. package/cli/wrangler-migration.jsonc +28 -0
  21. package/db/adapter.ts +166 -0
  22. package/db/analytics_engine/client.ts +0 -0
  23. package/db/analytics_engine/sites.ts +0 -0
  24. package/db/client.ts +16 -0
  25. package/db/d1/client.ts +8 -0
  26. package/db/d1/drizzle.config.ts +35 -0
  27. package/db/d1/migrations/0000_true_maelstrom.sql +165 -0
  28. package/db/d1/migrations/0001_wonderful_bloodaxe.sql +12 -0
  29. package/db/d1/migrations/0002_late_frightful_four.sql +1 -0
  30. package/db/d1/migrations/0003_cuddly_obadiah_stane.sql +16 -0
  31. package/db/d1/migrations/0004_mute_stardust.sql +1 -0
  32. package/db/d1/migrations/0005_awesome_silvermane.sql +3 -0
  33. package/db/d1/migrations/0006_volatile_shriek.sql +2 -0
  34. package/db/d1/migrations/0007_superb_lila_cheney.sql +1 -0
  35. package/db/d1/migrations/0008_bitter_longshot.sql +17 -0
  36. package/db/d1/migrations/0009_wonderful_madame_masque.sql +28 -0
  37. package/db/d1/migrations/meta/0000_snapshot.json +1112 -0
  38. package/db/d1/migrations/meta/0001_snapshot.json +1187 -0
  39. package/db/d1/migrations/meta/0002_snapshot.json +1194 -0
  40. package/db/d1/migrations/meta/0003_snapshot.json +1296 -0
  41. package/db/d1/migrations/meta/0004_snapshot.json +1303 -0
  42. package/db/d1/migrations/meta/0005_snapshot.json +1325 -0
  43. package/db/d1/migrations/meta/0006_snapshot.json +1339 -0
  44. package/db/d1/migrations/meta/0007_snapshot.json +1347 -0
  45. package/db/d1/migrations/meta/0008_snapshot.json +1464 -0
  46. package/db/d1/migrations/meta/0009_snapshot.json +1648 -0
  47. package/db/d1/migrations/meta/_journal.json +76 -0
  48. package/db/d1/schema.ts +407 -0
  49. package/db/d1/sites.ts +374 -0
  50. package/db/d1/teamAiUsage.ts +101 -0
  51. package/db/d1/teams.ts +127 -0
  52. package/db/durable/drizzle.config.ts +8 -0
  53. package/db/durable/durableObjectClient.ts +480 -0
  54. package/db/durable/events.ts +100 -0
  55. package/db/durable/migrations/0000_fair_bucky.sql +38 -0
  56. package/db/durable/migrations/meta/0000_snapshot.json +278 -0
  57. package/db/durable/migrations/meta/_journal.json +13 -0
  58. package/db/durable/migrations/migrations.js +10 -0
  59. package/db/durable/schema.ts +5 -0
  60. package/db/durable/siteDurableObject.ts +1352 -0
  61. package/db/durable/types.ts +53 -0
  62. package/db/postgres/client.ts +13 -0
  63. package/db/postgres/drizzle.config.ts +12 -0
  64. package/db/postgres/migrations/0000_brainy_sprite.sql +116 -0
  65. package/db/postgres/migrations/meta/0000_snapshot.json +681 -0
  66. package/db/postgres/migrations/meta/_journal.json +13 -0
  67. package/db/postgres/schema.ts +145 -0
  68. package/db/postgres/sites.ts +118 -0
  69. package/db/tranformReports.ts +595 -0
  70. package/db/types.ts +55 -0
  71. package/endpoints/api_worker.tsx +1854 -0
  72. package/endpoints/site_do_worker.ts +11 -0
  73. package/index.d.ts +63 -0
  74. package/index.ts +83 -0
  75. package/lib/auth.ts +279 -0
  76. package/lib/geojson/world_countries.json +45307 -0
  77. package/lib/random_name.ts +41 -0
  78. package/lib/sendMail.ts +252 -0
  79. package/package.json +142 -0
  80. package/public/favicon.ico +0 -0
  81. package/public/images/android-chrome-192x192.png +0 -0
  82. package/public/images/android-chrome-512x512.png +0 -0
  83. package/public/images/apple-touch-icon.png +0 -0
  84. package/public/images/favicon-16x16.png +0 -0
  85. package/public/images/favicon-32x32.png +0 -0
  86. package/public/images/lytx_dark_dashboard.png +0 -0
  87. package/public/images/lytx_light_dashboard.png +0 -0
  88. package/public/images/safari-pinned-tab.svg +4 -0
  89. package/public/logo.png +0 -0
  90. package/public/site.webmanifest +26 -0
  91. package/public/sw.js +107 -0
  92. package/src/Document.tsx +86 -0
  93. package/src/api/ai_api.ts +1156 -0
  94. package/src/api/authMiddleware.ts +45 -0
  95. package/src/api/auth_api.ts +465 -0
  96. package/src/api/event_labels_api.ts +193 -0
  97. package/src/api/events_api.ts +210 -0
  98. package/src/api/queueWorker.ts +303 -0
  99. package/src/api/reports_api.ts +278 -0
  100. package/src/api/seed_api.ts +288 -0
  101. package/src/api/sites_api.ts +904 -0
  102. package/src/api/tag_api.ts +458 -0
  103. package/src/api/tag_api_v2.ts +289 -0
  104. package/src/api/team_api.ts +456 -0
  105. package/src/app/Dashboard.tsx +1339 -0
  106. package/src/app/Events.tsx +974 -0
  107. package/src/app/Explore.tsx +312 -0
  108. package/src/app/Layout.tsx +58 -0
  109. package/src/app/Settings.tsx +1302 -0
  110. package/src/app/components/DashboardCard.tsx +118 -0
  111. package/src/app/components/EditableCell.tsx +123 -0
  112. package/src/app/components/EventForm.tsx +93 -0
  113. package/src/app/components/MarketingFooter.tsx +49 -0
  114. package/src/app/components/MarketingNav.tsx +150 -0
  115. package/src/app/components/Nav.tsx +755 -0
  116. package/src/app/components/NewSiteSetup.tsx +298 -0
  117. package/src/app/components/SQLEditor.tsx +740 -0
  118. package/src/app/components/SiteSelector.tsx +126 -0
  119. package/src/app/components/SiteTag.tsx +42 -0
  120. package/src/app/components/SiteTagInstallCard.tsx +241 -0
  121. package/src/app/components/WorldMapCard.tsx +337 -0
  122. package/src/app/components/charts/ChartComponents.tsx +1481 -0
  123. package/src/app/components/charts/EventFunnel.tsx +45 -0
  124. package/src/app/components/charts/EventSummary.tsx +194 -0
  125. package/src/app/components/charts/SankeyFlows.tsx +72 -0
  126. package/src/app/components/marketing/CheckIcon.tsx +16 -0
  127. package/src/app/components/marketing/MarketingLayout.tsx +23 -0
  128. package/src/app/components/marketing/SectionHeading.tsx +35 -0
  129. package/src/app/components/reports/AskAiWorkspace.tsx +371 -0
  130. package/src/app/components/reports/CreateReportStarter.tsx +74 -0
  131. package/src/app/components/reports/DashboardRouteFiltersContext.tsx +14 -0
  132. package/src/app/components/reports/DashboardToolbar.tsx +154 -0
  133. package/src/app/components/reports/DashboardWorkspaceLayout.tsx +63 -0
  134. package/src/app/components/reports/DashboardWorkspaceShell.tsx +118 -0
  135. package/src/app/components/reports/ReportBuilderWorkspace.tsx +76 -0
  136. package/src/app/components/reports/custom/CustomReportBuilderPage.tsx +1667 -0
  137. package/src/app/components/reports/custom/ReportWidgetChart.tsx +297 -0
  138. package/src/app/components/reports/custom/buildWidgetSql.ts +151 -0
  139. package/src/app/components/reports/custom/chartPalettes.ts +18 -0
  140. package/src/app/components/reports/custom/types.ts +50 -0
  141. package/src/app/components/reports/reportBuilderMenuItems.ts +17 -0
  142. package/src/app/components/reports/useDashboardToolbarControls.tsx +235 -0
  143. package/src/app/components/ui/AlertBanner.tsx +101 -0
  144. package/src/app/components/ui/Button.tsx +55 -0
  145. package/src/app/components/ui/Card.tsx +80 -0
  146. package/src/app/components/ui/Input.tsx +72 -0
  147. package/src/app/components/ui/Link.tsx +23 -0
  148. package/src/app/components/ui/ReportBuilderMenu.tsx +246 -0
  149. package/src/app/components/ui/ThemeToggle.tsx +54 -0
  150. package/src/app/constants.ts +6 -0
  151. package/src/app/headers.ts +33 -0
  152. package/src/app/providers/AuthProvider.tsx +189 -0
  153. package/src/app/providers/ClientProviders.tsx +18 -0
  154. package/src/app/providers/QueryProvider.tsx +23 -0
  155. package/src/app/providers/ThemeProvider.tsx +88 -0
  156. package/src/app/utils/chartThemes.ts +146 -0
  157. package/src/app/utils/keybinds.ts +96 -0
  158. package/src/app/utils/media.tsx +24 -0
  159. package/src/client.tsx +114 -0
  160. package/src/config/createLytxAppConfig.ts +252 -0
  161. package/src/config/resourceNames.ts +88 -0
  162. package/src/db/index.ts +67 -0
  163. package/src/index.css +285 -0
  164. package/src/lib/featureFlags.ts +69 -0
  165. package/src/pages/GetStarted.tsx +290 -0
  166. package/src/pages/Home.tsx +268 -0
  167. package/src/pages/Login.tsx +283 -0
  168. package/src/pages/PrivacyPolicy.tsx +120 -0
  169. package/src/pages/Signup.tsx +267 -0
  170. package/src/pages/TermsOfService.tsx +126 -0
  171. package/src/pages/VerifyEmail.tsx +56 -0
  172. package/src/session/durableObject.ts +7 -0
  173. package/src/session/siteSchema.ts +86 -0
  174. package/src/session/types.ts +36 -0
  175. package/src/templates/README.md +80 -0
  176. package/src/templates/cleanFunctions.js +44 -0
  177. package/src/templates/embedFunctions.js +52 -0
  178. package/src/templates/lytx-shared.ts +662 -0
  179. package/src/templates/lytxpixel-core.ts +144 -0
  180. package/src/templates/lytxpixel.ts +267 -0
  181. package/src/templates/lytxpixelBrowser.js +634 -0
  182. package/src/templates/lytxpixelBrowser.mjs +634 -0
  183. package/src/templates/parseData.js +12 -0
  184. package/src/templates/script.ts +31 -0
  185. package/src/templates/template.tsx +50 -0
  186. package/src/templates/test.js +3 -0
  187. package/src/templates/trackWebEvents.ts +177 -0
  188. package/src/templates/vendors/clickcease.ts +8 -0
  189. package/src/templates/vendors/google.ts +174 -0
  190. package/src/templates/vendors/linkedin.ts +23 -0
  191. package/src/templates/vendors/meta.ts +56 -0
  192. package/src/templates/vendors/quantcast.ts +22 -0
  193. package/src/templates/vendors/simplfi.ts +7 -0
  194. package/src/types/app-context.ts +16 -0
  195. package/src/utilities/dashboardParams.ts +188 -0
  196. package/src/utilities/dashboardQueries.ts +537 -0
  197. package/src/utilities/dashboardTransforms.ts +167 -0
  198. package/src/utilities/dataValidation.ts +414 -0
  199. package/src/utilities/detector.ts +73 -0
  200. package/src/utilities/encrypt.ts +103 -0
  201. package/src/utilities/index.ts +13 -0
  202. package/src/utilities/parser.ts +117 -0
  203. package/src/utilities/performanceMonitoring.ts +570 -0
  204. package/src/utilities/route_interuptors.ts +24 -0
  205. package/src/worker.tsx +675 -0
  206. package/tsconfig.json +78 -0
  207. package/types/env.d.ts +16 -0
  208. package/types/rw.d.ts +7 -0
  209. package/types/shims.d.ts +53 -0
  210. package/types/vite.d.ts +19 -0
  211. package/vite/vite-plugin-pixel-bundle.ts +126 -0
  212. package/vite.config.ts +53 -0
  213. package/worker-configuration.d.ts +8401 -0
package/tsconfig.json ADDED
@@ -0,0 +1,78 @@
1
+ {
2
+ "compilerOptions": {
3
+ /* Visit https://aka.ms/tsconfig.json to read more about this file */
4
+ /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
5
+ "target": "es2021",
6
+ /* Specify a set of bundled library declaration files that describe the target runtime environment. */
7
+ "lib": [
8
+ "DOM",
9
+ "DOM.Iterable",
10
+ "ESNext",
11
+ "ES2022"
12
+ ],
13
+ "allowJs": true,
14
+ /* Specify what JSX code is generated. */
15
+ "jsx": "react-jsx",
16
+ /* Specify what module code is generated. */
17
+ "module": "es2022",
18
+ /* Specify how TypeScript looks up a file from a given module specifier. */
19
+ "moduleResolution": "bundler",
20
+ /* Specify type package names to be included without being referenced in a source file. */
21
+ "types": [
22
+ "./worker-configuration.d.ts",
23
+ "./types/rw.d.ts",
24
+ "./types/vite.d.ts",
25
+ "./types/env.d.ts",
26
+ "./types/shims.d.ts"
27
+ ],
28
+ "paths": {
29
+ "@/*": [
30
+ "./src/*"
31
+ ],
32
+ "@cli/*": [
33
+ "./cli/*"
34
+ ],
35
+ "@app/*": [
36
+ "./src/app/*"
37
+ ],
38
+ "@utilities/*": [
39
+ "./src/utilities/*"
40
+ ],
41
+ "@components/*": [
42
+ "./src/app/components/*"
43
+ ],
44
+ "@pages/*": [
45
+ "./src/pages/*"
46
+ ],
47
+ "@api/*": [
48
+ "./src/api/*"
49
+ ],
50
+ "@lib/*": [
51
+ "./lib/*"
52
+ ],
53
+ "@db/*": [
54
+ "./db/*"
55
+ ],
56
+ "@generated/*": [
57
+ "./generated/*"
58
+ ]
59
+ },
60
+ /* Enable importing .json files */
61
+ "resolveJsonModule": true,
62
+ /* Enable error reporting in type-checked JavaScript files. */
63
+ "checkJs": false,
64
+ /* Disable emitting files from a compilation. */
65
+ "noEmit": true,
66
+ /* Ensure that each file can be safely transpiled without relying on other imports. */
67
+ "isolatedModules": true,
68
+ /* Allow 'import x from y' when a module doesn't have a default export. */
69
+ "allowSyntheticDefaultImports": true,
70
+ /* Ensure that casing is correct in imports. */
71
+ "forceConsistentCasingInFileNames": true,
72
+ /* Enable all strict type-checking options. */
73
+ "strict": true,
74
+ "noImplicitAny": true,
75
+ /* Skip type checking all .d.ts files. */
76
+ "skipLibCheck": true
77
+ }
78
+ }
package/types/env.d.ts ADDED
@@ -0,0 +1,16 @@
1
+ // Auto-generated Cloudflare binding types.
2
+ // @see https://alchemy.run/concepts/bindings/#type-safe-bindings
3
+
4
+ import type { worker } from "../alchemy.run.ts";
5
+
6
+ export type CloudflareEnv = typeof worker.Env;
7
+
8
+ declare global {
9
+ type Env = CloudflareEnv;
10
+ }
11
+
12
+ declare module "cloudflare:workers" {
13
+ namespace Cloudflare {
14
+ export interface Env extends CloudflareEnv { }
15
+ }
16
+ }
package/types/rw.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ import type { AppContext } from "../src/types/app-context";
2
+
3
+ declare module "rwsdk/worker" {
4
+ interface DefaultAppContext extends AppContext {}
5
+ }
6
+
7
+
@@ -0,0 +1,53 @@
1
+ declare module "@opentui/core" {
2
+ export type ParsedKey = {
3
+ name?: string;
4
+ ctrl?: boolean;
5
+ shift?: boolean;
6
+ };
7
+
8
+ export class CliRenderer {
9
+ [key: string]: any;
10
+ terminalWidth: number;
11
+ terminalHeight: number;
12
+ console: { toggle: () => void };
13
+ constructor(...args: any[]);
14
+ start(): void;
15
+ stop(): void;
16
+ auto(): void;
17
+ toggleDebugOverlay(): void;
18
+ dumpHitGrid(): void;
19
+ add(...args: any[]): void;
20
+ setBackgroundColor(...args: any[]): void;
21
+ }
22
+
23
+ export class BoxRenderable {
24
+ [key: string]: any;
25
+ constructor(...args: any[]);
26
+ add(...args: any[]): void;
27
+ }
28
+
29
+ export class TextRenderable {
30
+ [key: string]: any;
31
+ constructor(...args: any[]);
32
+ }
33
+
34
+ export function createCliRenderer(...args: any[]): CliRenderer;
35
+ export function getKeyHandler(): {
36
+ on: (event: string, cb: (key: ParsedKey) => void) => void;
37
+ off: (event: string, cb: (key: ParsedKey) => void) => void;
38
+ };
39
+ }
40
+
41
+ declare module "react-simple-maps" {
42
+ import type { ComponentType } from "react";
43
+
44
+ export const ComposableMap: ComponentType<any>;
45
+ export const Geographies: ComponentType<any>;
46
+ export const Geography: ComponentType<any>;
47
+ export const Marker: ComponentType<any>;
48
+ export const ZoomableGroup: ComponentType<any>;
49
+ }
50
+
51
+ declare module "@supabase/supabase-js" {
52
+ export function createClient<T = any>(url: string, key: string): any;
53
+ }
@@ -0,0 +1,19 @@
1
+ // Stub declarations used by tsconfig.json.
2
+ // Vite/RWSDK types are primarily provided by generated worker/runtime types.
3
+
4
+ /**
5
+ * Virtual module: Lytx Pixel Bundle
6
+ *
7
+ * This module is generated at build time by vite-plugin-pixel-bundle.
8
+ * It contains the bundled JavaScript code for the Lytx tracking pixel.
9
+ *
10
+ * Two bundles are available:
11
+ * - script_tag_manager: Full version with third-party vendors (tag_manager = true)
12
+ * - script_core: Core version without vendors (tag_manager = false)
13
+ */
14
+ declare module 'virtual:lytx-pixel-raw' {
15
+ /** Full bundled JavaScript with all third-party vendor integrations (tag_manager = true) */
16
+ export const script_tag_manager: string;
17
+ /** Core bundled JavaScript without third-party vendor integrations (tag_manager = false) */
18
+ export const script_core: string;
19
+ }
@@ -0,0 +1,126 @@
1
+ /**
2
+ * Vite Plugin: Lytx Pixel Bundle
3
+ *
4
+ * This plugin bundles the lytxpixel scripts at build time and exposes them
5
+ * as virtual modules. This replaces the manual rawScriptString.ts build step.
6
+ *
7
+ * Two bundles are generated:
8
+ * - Full version (with third-party vendors): for tag_manager = true
9
+ * - Core version (no vendors): for tag_manager = false
10
+ *
11
+ * Usage:
12
+ * import { script_tag_manager, script_core } from 'virtual:lytx-pixel-raw';
13
+ */
14
+ import { build } from 'esbuild';
15
+ import path from 'path';
16
+ import type { Plugin } from 'vite';
17
+
18
+ const VIRTUAL_MODULE_ID = 'virtual:lytx-pixel-raw';
19
+ const RESOLVED_VIRTUAL_ID = '\0' + VIRTUAL_MODULE_ID;
20
+
21
+ interface CachedBundles {
22
+ full: string | null;
23
+ core: string | null;
24
+ }
25
+
26
+ export function lytxPixelBundlePlugin(): Plugin {
27
+ let cachedBundles: CachedBundles = { full: null, core: null };
28
+ let rootDir: string;
29
+
30
+ return {
31
+ name: 'vite-plugin-lytx-pixel-bundle',
32
+
33
+ configResolved(config) {
34
+ rootDir = config.root;
35
+ },
36
+
37
+ resolveId(id) {
38
+ if (id === VIRTUAL_MODULE_ID) {
39
+ return RESOLVED_VIRTUAL_ID;
40
+ }
41
+ },
42
+
43
+ async load(id) {
44
+ if (id === RESOLVED_VIRTUAL_ID) {
45
+ // Build both bundles in parallel if not cached
46
+ const [fullBundle, coreBundle] = await Promise.all([
47
+ cachedBundles.full ?? bundlePixelScript(rootDir, 'full'),
48
+ cachedBundles.core ?? bundlePixelScript(rootDir, 'core'),
49
+ ]);
50
+
51
+ cachedBundles.full = fullBundle;
52
+ cachedBundles.core = coreBundle;
53
+
54
+ return `
55
+ export const script_tag_manager = ${JSON.stringify(fullBundle)};
56
+ export const script_core = ${JSON.stringify(coreBundle)};
57
+ `;
58
+ }
59
+ },
60
+
61
+ // Invalidate cache in dev mode when source files change
62
+ handleHotUpdate({ file }) {
63
+ if (
64
+ file.includes('templates/lytxpixel') ||
65
+ file.includes('templates/vendors') ||
66
+ file.includes('templates/trackWebEvents')
67
+ ) {
68
+ cachedBundles = { full: null, core: null };
69
+ }
70
+ },
71
+ };
72
+ }
73
+
74
+ async function bundlePixelScript(rootDir: string, variant: 'full' | 'core'): Promise<string> {
75
+ const entryFile = variant === 'full' ? 'lytxpixel.ts' : 'lytxpixel-core.ts';
76
+ const entryPoint = path.resolve(rootDir, `src/templates/${entryFile}`);
77
+
78
+ // Log info about tracking domain (only on first bundle to avoid duplicate logs)
79
+ if (variant === 'full') {
80
+ console.log('');
81
+ console.log(' ╔══════════════════════════════════════════════════════════╗');
82
+ console.log(' ║ ║');
83
+ console.log(' ║ 🔗 LYTX TRACKING SCRIPT ║');
84
+ console.log(' ║ ║');
85
+ console.log(' ║ 📡 Domain is set dynamically at runtime from request ║');
86
+ console.log(' ║ ║');
87
+ console.log(' ╚══════════════════════════════════════════════════════════╝');
88
+ console.log('');
89
+ }
90
+
91
+ const result = await build({
92
+ entryPoints: [entryPoint],
93
+ bundle: true,
94
+ write: false,
95
+ target: 'es2017',
96
+ format: 'esm',
97
+ treeShaking: true,
98
+ charset: 'utf8',
99
+ minify: true,
100
+ });
101
+
102
+ let code = result.outputFiles[0].text;
103
+
104
+ // Convert named exports to variable assignments (e.g., "export{L as parseData}" -> "var parseData=L;")
105
+ // This preserves the exported names so they can be called from the wrapper script
106
+ code = code
107
+ .replace(/export\s*\{([^}]+)\};?/g, (match, exports) => {
108
+ // Parse exports like "L as parseData, M as trackEvents" or just "parseData"
109
+ return exports.split(',').map((exp: string) => {
110
+ const parts = exp.trim().split(/\s+as\s+/);
111
+ if (parts.length === 2) {
112
+ // "L as parseData" -> "var parseData=L;"
113
+ return `var ${parts[1].trim()}=${parts[0].trim()};`;
114
+ } else {
115
+ // "parseData" -> already available, no action needed
116
+ return '';
117
+ }
118
+ }).join('');
119
+ })
120
+ .replace(/export\s+default\s+[^;]+;?/g, '')
121
+ .trim();
122
+
123
+ return code;
124
+ }
125
+
126
+ export default lytxPixelBundlePlugin;
package/vite.config.ts ADDED
@@ -0,0 +1,53 @@
1
+ import { defineConfig } from 'vite';
2
+ import tailwindcss from '@tailwindcss/vite';
3
+ import alchemy from "alchemy/cloudflare/redwood";
4
+ import react from "@vitejs/plugin-react";
5
+ import path from 'path';
6
+ import { lytxPixelBundlePlugin } from './vite/vite-plugin-pixel-bundle';
7
+
8
+ function sqlPlugin() {
9
+ return {
10
+ name: "vite-plugin-sql",
11
+ transform(content: string, id: string) {
12
+ if (id.endsWith(".sql")) {
13
+ return {
14
+ code: `export default ${JSON.stringify(content)};`,
15
+ map: null,
16
+ };
17
+ }
18
+ },
19
+ };
20
+ }
21
+
22
+ export default defineConfig({
23
+ plugins: [
24
+ lytxPixelBundlePlugin(),
25
+ sqlPlugin(),
26
+ react({
27
+ babel: {
28
+ plugins: ["babel-plugin-react-compiler"],
29
+ },
30
+ }),
31
+ alchemy(),
32
+ tailwindcss()
33
+ ],
34
+ resolve: {
35
+ alias: {
36
+ '@': path.resolve(__dirname, './src'),
37
+ '@cli': path.resolve(__dirname, './cli'),
38
+ '@app': path.resolve(__dirname, './src/app'),
39
+ '@utilities': path.resolve(__dirname, './src/utilities'),
40
+ '@components': path.resolve(__dirname, './src/app/components'),
41
+ '@pages': path.resolve(__dirname, './src/pages'),
42
+ '@api': path.resolve(__dirname, './src/api'),
43
+ '@lib': path.resolve(__dirname, './lib'),
44
+ '@db': path.resolve(__dirname, './db'),
45
+ '@generated': path.resolve(__dirname, './generated'),
46
+ }
47
+ },
48
+ server: {
49
+ host: "0.0.0.0",
50
+ allowedHosts: true,
51
+ port: 6123
52
+ }
53
+ });