@linktr.ee/linkapp 0.0.10 → 0.0.11

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 (61) hide show
  1. package/dev-server/classic/main.tsx +45 -24
  2. package/dev-server/classic.html +58 -0
  3. package/dev-server/featured/main.tsx +45 -24
  4. package/dev-server/featured.html +58 -0
  5. package/dev-server/preview/Preview.tsx +425 -14
  6. package/dist/cli.js +9 -3
  7. package/dist/cli.js.map +1 -1
  8. package/dist/commands/add.js +3 -3
  9. package/dist/commands/add.js.map +1 -1
  10. package/dist/commands/deploy.d.ts.map +1 -1
  11. package/dist/commands/deploy.js +10 -4
  12. package/dist/commands/deploy.js.map +1 -1
  13. package/dist/components/ThemeStyle.d.ts +30 -0
  14. package/dist/components/ThemeStyle.d.ts.map +1 -0
  15. package/dist/components/ThemeStyle.js +33 -0
  16. package/dist/components/ThemeStyle.js.map +1 -0
  17. package/dist/components/index.d.ts +2 -0
  18. package/dist/components/index.d.ts.map +1 -0
  19. package/dist/components/index.js +2 -0
  20. package/dist/components/index.js.map +1 -0
  21. package/dist/lib/build/detect-layouts.d.ts.map +1 -1
  22. package/dist/lib/build/detect-layouts.js +1 -4
  23. package/dist/lib/build/detect-layouts.js.map +1 -1
  24. package/dist/lib/deploy/generate-manifest-files.d.ts.map +1 -1
  25. package/dist/lib/deploy/generate-manifest-files.js +6 -0
  26. package/dist/lib/deploy/generate-manifest-files.js.map +1 -1
  27. package/dist/lib/deploy/pack-project.d.ts.map +1 -1
  28. package/dist/lib/deploy/pack-project.js +32 -5
  29. package/dist/lib/deploy/pack-project.js.map +1 -1
  30. package/dist/lib/deploy/upload.d.ts +1 -0
  31. package/dist/lib/deploy/upload.d.ts.map +1 -1
  32. package/dist/lib/deploy/upload.js +12 -2
  33. package/dist/lib/deploy/upload.js.map +1 -1
  34. package/dist/lib/deploy/validation.d.ts.map +1 -1
  35. package/dist/lib/deploy/validation.js +4 -61
  36. package/dist/lib/deploy/validation.js.map +1 -1
  37. package/dist/lib/utils/setup-runtime.d.ts.map +1 -1
  38. package/dist/lib/utils/setup-runtime.js +48 -17
  39. package/dist/lib/utils/setup-runtime.js.map +1 -1
  40. package/dist/schema/config.schema.d.ts +50 -114
  41. package/dist/schema/config.schema.d.ts.map +1 -1
  42. package/dist/schema/config.schema.js +94 -18
  43. package/dist/schema/config.schema.js.map +1 -1
  44. package/dist/sdk/index.d.ts +21 -0
  45. package/dist/sdk/index.d.ts.map +1 -0
  46. package/dist/sdk/index.js +21 -0
  47. package/dist/sdk/index.js.map +1 -0
  48. package/dist/sdk/send-message.d.ts +16 -0
  49. package/dist/sdk/send-message.d.ts.map +1 -0
  50. package/dist/sdk/send-message.js +34 -0
  51. package/dist/sdk/send-message.js.map +1 -0
  52. package/dist/sdk/use-open-popup.d.ts +23 -0
  53. package/dist/sdk/use-open-popup.d.ts.map +1 -0
  54. package/dist/sdk/use-open-popup.js +29 -0
  55. package/dist/sdk/use-open-popup.js.map +1 -0
  56. package/dist/types.d.ts +149 -31
  57. package/dist/types.d.ts.map +1 -1
  58. package/dist/types.js +37 -1
  59. package/dist/types.js.map +1 -1
  60. package/package.json +11 -3
  61. package/runtime/index.html +58 -0
@@ -1,41 +1,62 @@
1
- import { StrictMode } from 'react'
2
- import { createRoot } from 'react-dom/client'
3
- import Layout from '@/app/layout'
4
- import Classic from '@/app/classic'
5
- import '@/app/globals.css'
1
+ import Classic from "@/app/classic";
2
+ import { StrictMode } from "react";
3
+ import { createRoot } from "react-dom/client";
4
+ import "@/app/globals.css";
5
+
6
+ // Conditionally import Layout if it exists
7
+ const layoutModules = import.meta.glob("@/app/layout.{ts,tsx}", {
8
+ eager: true,
9
+ });
10
+ const Layout = Object.values(layoutModules)[0]?.default as
11
+ | React.ComponentType<{ children: React.ReactNode; theme?: any }>
12
+ | undefined;
6
13
 
7
14
  // Preview props injected by dev server via Vite define
8
- declare const __PREVIEW_PROPS__: Record<string, unknown>
15
+ declare const __PREVIEW_PROPS__: Record<string, unknown>;
9
16
 
10
17
  const previewProps = __PREVIEW_PROPS__ || {
11
- linkUrl: 'https://example.com/demo',
18
+ linkUrl: "https://example.com/demo",
12
19
  theme: {
13
- textColor: '#000000',
14
- backgroundColor: '#ffffff',
15
- borderRadius: '12px',
16
- borderColor: '#e5e7eb',
17
- isOutlineStyle: false,
18
- contrastColor: '#ffffff',
19
- textHoverColor: '#111827',
20
+ cssVariables: {
21
+ "--button-style-text": "#000000",
22
+ "--button-style-background": "#ffffff",
23
+ "--button-style-inner-radius": "12px",
24
+ "--button-style-border-color": "#e5e7eb",
25
+ "--button-style-background-hover": "#f3f4f6",
26
+ "--button-style-contrast-color": "#ffffff",
27
+ "--profileBackground": "#ffffff",
28
+ },
29
+ // Legacy properties (deprecated)
30
+ textColor: "#000000",
31
+ backgroundColor: "#ffffff",
32
+ borderRadius: "12px",
33
+ borderColor: "#e5e7eb",
34
+ backgroundHover: "#f3f4f6",
35
+ contrastColor: "#ffffff",
36
+ textHoverColor: "#111827",
20
37
  },
21
- locale: 'en-US',
22
- currency: 'USD',
23
- username: 'demo-user',
38
+ locale: "en-US",
39
+ currency: "USD",
40
+ username: "demo-user",
24
41
  viewport: {
25
42
  width: 680,
26
43
  height: 800,
27
44
  },
28
- }
45
+ };
29
46
 
30
- const rootElement = document.getElementById('root')
47
+ const rootElement = document.getElementById("root");
31
48
  if (!rootElement) {
32
- throw new Error('Root element not found')
49
+ throw new Error("Root element not found");
33
50
  }
34
51
 
35
52
  createRoot(rootElement).render(
36
53
  <StrictMode>
37
- <Layout>
54
+ {Layout ? (
55
+ <Layout theme={previewProps.theme}>
56
+ <Classic {...previewProps} />
57
+ </Layout>
58
+ ) : (
38
59
  <Classic {...previewProps} />
39
- </Layout>
40
- </StrictMode>
41
- )
60
+ )}
61
+ </StrictMode>,
62
+ );
@@ -4,6 +4,64 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>Classic - LinkApp</title>
7
+
8
+ <!-- Linktree theme variables will be injected here -->
9
+ <style id="linktree-theme"></style>
10
+
11
+ <script>
12
+ /**
13
+ * Helper function to convert CSS variables object to CSS string
14
+ * @param {Record<string, string>} vars - Object with CSS variable names as keys
15
+ * @returns {string} CSS string like "--var1: value1; --var2: value2;"
16
+ */
17
+ function renderCssVariables(vars) {
18
+ return Object.entries(vars)
19
+ .map((entry) => entry.join(': '))
20
+ .join('; ') + ';'
21
+ }
22
+
23
+ /**
24
+ * Listen for theme updates from parent window
25
+ * Applies CSS variables to the document root
26
+ */
27
+ window.addEventListener('message', function(event) {
28
+ // Only process messages with the correct structure
29
+ if (
30
+ event.data &&
31
+ typeof event.data === 'object' &&
32
+ event.data.type === 'THEME_UPDATE'
33
+ ) {
34
+ const themeUpdate = event.data
35
+
36
+ // Get the style element where theme variables are injected
37
+ const themeStyle = document.getElementById('linktree-theme')
38
+
39
+ if (!themeStyle) {
40
+ console.warn('linktree-theme style element not found')
41
+ return
42
+ }
43
+
44
+ // Inject CSS variables into :root
45
+ themeStyle.textContent = ':root { ' + renderCssVariables(themeUpdate.payload.variables) + ' }'
46
+
47
+ // Remove any existing theme classes
48
+ const classesToRemove = []
49
+ document.documentElement.classList.forEach((className) => {
50
+ if (className.startsWith('linktree-theme-')) {
51
+ classesToRemove.push(className)
52
+ }
53
+ })
54
+ classesToRemove.forEach((className) => {
55
+ document.documentElement.classList.remove(className)
56
+ })
57
+
58
+ // Add theme class for additional styling hooks
59
+ if (themeUpdate.payload.name && themeUpdate.payload.name !== 'legacy') {
60
+ document.documentElement.classList.add('linktree-theme-' + themeUpdate.payload.name)
61
+ }
62
+ }
63
+ }, false)
64
+ </script>
7
65
  </head>
8
66
  <body>
9
67
  <div id="root"></div>
@@ -1,41 +1,62 @@
1
- import { StrictMode } from 'react'
2
- import { createRoot } from 'react-dom/client'
3
- import Layout from '@/app/layout'
4
- import Featured from '@/app/featured'
5
- import '@/app/globals.css'
1
+ import Featured from "@/app/featured";
2
+ import { StrictMode } from "react";
3
+ import { createRoot } from "react-dom/client";
4
+ import "@/app/globals.css";
5
+
6
+ // Conditionally import Layout if it exists
7
+ const layoutModules = import.meta.glob("@/app/layout.{ts,tsx}", {
8
+ eager: true,
9
+ });
10
+ const Layout = Object.values(layoutModules)[0]?.default as
11
+ | React.ComponentType<{ children: React.ReactNode; theme?: any }>
12
+ | undefined;
6
13
 
7
14
  // Preview props injected by dev server via Vite define
8
- declare const __PREVIEW_PROPS__: Record<string, unknown>
15
+ declare const __PREVIEW_PROPS__: Record<string, unknown>;
9
16
 
10
17
  const previewProps = __PREVIEW_PROPS__ || {
11
- linkUrl: 'https://example.com/demo',
18
+ linkUrl: "https://example.com/demo",
12
19
  theme: {
13
- textColor: '#000000',
14
- backgroundColor: '#ffffff',
15
- borderRadius: '12px',
16
- borderColor: '#e5e7eb',
17
- isOutlineStyle: false,
18
- contrastColor: '#ffffff',
19
- textHoverColor: '#111827',
20
+ cssVariables: {
21
+ "--button-style-text": "#000000",
22
+ "--button-style-background": "#ffffff",
23
+ "--button-style-inner-radius": "12px",
24
+ "--button-style-border-color": "#e5e7eb",
25
+ "--button-style-background-hover": "#f3f4f6",
26
+ "--button-style-contrast-color": "#ffffff",
27
+ "--profileBackground": "#ffffff",
28
+ },
29
+ // Legacy properties (deprecated)
30
+ textColor: "#000000",
31
+ backgroundColor: "#ffffff",
32
+ borderRadius: "12px",
33
+ borderColor: "#e5e7eb",
34
+ backgroundHover: "#f3f4f6",
35
+ contrastColor: "#ffffff",
36
+ textHoverColor: "#111827",
20
37
  },
21
- locale: 'en-US',
22
- currency: 'USD',
23
- username: 'demo-user',
38
+ locale: "en-US",
39
+ currency: "USD",
40
+ username: "demo-user",
24
41
  viewport: {
25
42
  width: 680,
26
43
  height: 800,
27
44
  },
28
- }
45
+ };
29
46
 
30
- const rootElement = document.getElementById('root')
47
+ const rootElement = document.getElementById("root");
31
48
  if (!rootElement) {
32
- throw new Error('Root element not found')
49
+ throw new Error("Root element not found");
33
50
  }
34
51
 
35
52
  createRoot(rootElement).render(
36
53
  <StrictMode>
37
- <Layout>
54
+ {Layout ? (
55
+ <Layout theme={previewProps.theme}>
56
+ <Featured {...previewProps} />
57
+ </Layout>
58
+ ) : (
38
59
  <Featured {...previewProps} />
39
- </Layout>
40
- </StrictMode>
41
- )
60
+ )}
61
+ </StrictMode>,
62
+ );
@@ -4,6 +4,64 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>Featured - LinkApp</title>
7
+
8
+ <!-- Linktree theme variables will be injected here -->
9
+ <style id="linktree-theme"></style>
10
+
11
+ <script>
12
+ /**
13
+ * Helper function to convert CSS variables object to CSS string
14
+ * @param {Record<string, string>} vars - Object with CSS variable names as keys
15
+ * @returns {string} CSS string like "--var1: value1; --var2: value2;"
16
+ */
17
+ function renderCssVariables(vars) {
18
+ return Object.entries(vars)
19
+ .map((entry) => entry.join(': '))
20
+ .join('; ') + ';'
21
+ }
22
+
23
+ /**
24
+ * Listen for theme updates from parent window
25
+ * Applies CSS variables to the document root
26
+ */
27
+ window.addEventListener('message', function(event) {
28
+ // Only process messages with the correct structure
29
+ if (
30
+ event.data &&
31
+ typeof event.data === 'object' &&
32
+ event.data.type === 'THEME_UPDATE'
33
+ ) {
34
+ const themeUpdate = event.data
35
+
36
+ // Get the style element where theme variables are injected
37
+ const themeStyle = document.getElementById('linktree-theme')
38
+
39
+ if (!themeStyle) {
40
+ console.warn('linktree-theme style element not found')
41
+ return
42
+ }
43
+
44
+ // Inject CSS variables into :root
45
+ themeStyle.textContent = ':root { ' + renderCssVariables(themeUpdate.payload.variables) + ' }'
46
+
47
+ // Remove any existing theme classes
48
+ const classesToRemove = []
49
+ document.documentElement.classList.forEach((className) => {
50
+ if (className.startsWith('linktree-theme-')) {
51
+ classesToRemove.push(className)
52
+ }
53
+ })
54
+ classesToRemove.forEach((className) => {
55
+ document.documentElement.classList.remove(className)
56
+ })
57
+
58
+ // Add theme class for additional styling hooks
59
+ if (themeUpdate.payload.name && themeUpdate.payload.name !== 'legacy') {
60
+ document.documentElement.classList.add('linktree-theme-' + themeUpdate.payload.name)
61
+ }
62
+ }
63
+ }, false)
64
+ </script>
7
65
  </head>
8
66
  <body>
9
67
  <div id="root"></div>