astro-tractstack 2.0.0-rc.15 → 2.0.0-rc.17

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro-tractstack",
3
- "version": "2.0.0-rc.15",
3
+ "version": "2.0.0-rc.17",
4
4
  "description": "Astro integration for TractStack - redeeming the web from boring experiences",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1,7 +1,4 @@
1
1
  ---
2
- // CodeHook Dispatcher - Minimal Version
3
- // Framework components are always available, custom components are commented for guidance
4
-
5
2
  import FeaturedContent from '@/components/codehooks/FeaturedContent.astro';
6
3
  import ListContent from '@/components/codehooks/ListContent.astro';
7
4
  import BunnyVideoWrapper from '@/components/codehooks/BunnyVideoWrapper.astro';
@@ -12,6 +9,7 @@ import type { FullContentMapItem } from '@/types/tractstack';
12
9
  export interface Props {
13
10
  target: string;
14
11
  fullContentMap: FullContentMapItem[];
12
+ resourcesPayload?: Record<string, any[]>;
15
13
  options?: {
16
14
  params?: {
17
15
  options?: string;
@@ -19,7 +17,7 @@ export interface Props {
19
17
  };
20
18
  }
21
19
 
22
- const { target, options, fullContentMap } = Astro.props;
20
+ const { target, options, fullContentMap /* resourcesPayload */ } = Astro.props;
23
21
 
24
22
  export const components = {
25
23
  'featured-content': true,
@@ -1,7 +1,4 @@
1
1
  ---
2
- // V2 Custom Routes - Minimal Version
3
- // This is a stub - implement your custom routes here
4
-
5
2
  export interface Props {
6
3
  route: string;
7
4
  slug: string;
@@ -15,9 +12,6 @@ const { route, slug, resources } = Astro.props;
15
12
  export const routes = {
16
13
  // collections: true, // Uncomment to enable collections route
17
14
  };
18
-
19
- // Example implementation for collections:
20
- // const payload = resources; // V2 resources are already filtered by backend
21
15
  ---
22
16
 
23
17
  {
@@ -1,7 +1,4 @@
1
1
  ---
2
- // V2 CodeHook Dispatcher - With Examples
3
- // Framework components and custom examples are available
4
-
5
2
  import CustomHero from './CustomHero.astro';
6
3
  import FeaturedContent from '@/components/codehooks/FeaturedContent.astro';
7
4
  import ListContent from '@/components/codehooks/ListContent.astro';
@@ -12,6 +9,7 @@ import type { FullContentMapItem } from '@/types/tractstack';
12
9
  export interface Props {
13
10
  target: string;
14
11
  fullContentMap: FullContentMapItem[];
12
+ resourcesPayload?: Record<string, any[]>;
15
13
  options?: {
16
14
  params?: {
17
15
  options?: string;
@@ -19,7 +17,7 @@ export interface Props {
19
17
  };
20
18
  }
21
19
 
22
- const { target, options, fullContentMap } = Astro.props;
20
+ const { target, options, fullContentMap /* resourcesPayload */ } = Astro.props;
23
21
 
24
22
  export const components = {
25
23
  'custom-hero': true,
@@ -1,7 +1,4 @@
1
1
  ---
2
- // V2 Custom Routes - With Examples
3
- // Full Collections implementation included
4
-
5
2
  import Collections from './pages/Collections.astro';
6
3
 
7
4
  export interface Props {
@@ -17,7 +14,6 @@ export const routes = {
17
14
  collections: true,
18
15
  };
19
16
 
20
- // V2: Resources are already filtered by backend, no client-side extraction needed
21
17
  const payload = resources;
22
18
  ---
23
19
 
@@ -51,26 +51,40 @@ const PanelVisibilityWrapper = ({
51
51
  const currentWrapper = wrapperRef.current;
52
52
  if (!currentWrapper) return;
53
53
 
54
- // Always observe the panel, regardless of active state
54
+ // Skip intersection observer for 'add' panels - they behave differently
55
+ if (panelType === 'add') {
56
+ return;
57
+ }
58
+
55
59
  const observer = new IntersectionObserver(
56
60
  (entries) => {
57
- // Only take action if this panel is currently active and not intersecting
58
- if (!entries[0].isIntersecting && isActive) {
59
- nodesCtx.closeAllPanels();
61
+ // Add delay to prevent immediate closing during panel activation
62
+ if (isActive) {
63
+ setTimeout(() => {
64
+ // Double-check the panel is still active before closing
65
+ const currentActiveMode = nodesCtx.activePaneMode.get();
66
+ const stillActive =
67
+ currentActiveMode.panel === panelType &&
68
+ currentActiveMode.paneId === nodeId;
69
+ if (!entries[0].isIntersecting && stillActive) {
70
+ console.log('❌ CLOSING PANEL DUE TO INTERSECTION OBSERVER!', {
71
+ panelType,
72
+ nodeId,
73
+ });
74
+ nodesCtx.closeAllPanels();
75
+ }
76
+ }, 100); // Small delay to allow panel to render
60
77
  }
61
78
  },
62
79
  {
63
- threshold: 0.1, // Close when 90% of the panel is out of view
64
- rootMargin: '-10px', // Small margin to make detection a bit more forgiving
80
+ threshold: 0.1,
81
+ rootMargin: '-10px',
65
82
  }
66
83
  );
67
84
 
68
85
  observer.observe(currentWrapper);
69
-
70
- return () => {
71
- observer.disconnect();
72
- };
73
- }, [nodeId, panelType, nodesCtx, isActive]); // Include isActive in dependencies
86
+ return () => observer.disconnect();
87
+ }, [nodeId, panelType, nodesCtx, isActive]);
74
88
 
75
89
  return (
76
90
  <div
@@ -29,7 +29,7 @@ const CodeHookContainer = ({
29
29
  value && (
30
30
  <div key={key} className="flex items-start">
31
31
  <span className="min-w-24 font-bold text-gray-600">{key}:</span>
32
- <span className="ml-2 text-gray-800">
32
+ <span className="ml-2 truncate text-gray-800">
33
33
  {JSON.stringify(value)}
34
34
  </span>
35
35
  </div>
@@ -312,6 +312,7 @@ const PanelSwitch = ({
312
312
 
313
313
  case 'style-code-config':
314
314
  if (clickedNode) return <StyleWidgetConfigPanel node={clickedNode} />;
315
+ break;
315
316
 
316
317
  case 'style-code-add':
317
318
  case 'style-code-container-add':
@@ -153,7 +153,8 @@ const AddPaneCodeHookPanel = ({
153
153
  font-weight: bold;
154
154
  }
155
155
  .hook-item-available:hover {
156
- background-color: rgba(8, 145, 178, 0.1); /* bg-cyan-600/10 */
156
+ background-color: #0891b2;
157
+ color: #fff;
157
158
  }
158
159
  .hook-item-disabled {
159
160
  background-color: #f9fafb; /* bg-gray-50 */
@@ -68,6 +68,7 @@ const ConfigPanePanel = ({ nodeId }: ConfigPanePanelProps) => {
68
68
  };
69
69
 
70
70
  const handleCodeHookConfig = () => {
71
+ ctx.toolModeValStore.set({ value: 'styles' });
71
72
  settingsPanelStore.set({
72
73
  action: 'setup-codehook',
73
74
  nodeId: nodeId,
@@ -5,6 +5,7 @@ import { StylesMemory } from '@/components/edit/state/StylesMemory';
5
5
  import SelectedTailwindClass from '@/components/fields/SelectedTailwindClass';
6
6
  import { isMarkdownPaneFragmentNode } from '@/utils/compositor/typeGuards';
7
7
  import { widgetMeta } from '@/constants';
8
+ import { getCtx } from '@/stores/nodes';
8
9
  import type {
9
10
  FlatNode,
10
11
  MarkdownPaneFragmentNode,
@@ -271,6 +272,7 @@ const StyleWidgetPanel = ({
271
272
  };
272
273
 
273
274
  const handleWidgetConfig = () => {
275
+ getCtx().toolModeValStore.set({ value: 'styles' });
274
276
  settingsPanelStore.set({
275
277
  action: `style-code-config`,
276
278
  nodeId: node.id,
@@ -505,62 +505,56 @@ export default function SaveModal({
505
505
  const { dirtyPaneIds, classes: dirtyClasses } =
506
506
  ctx.getDirtyNodesClassData();
507
507
 
508
- if (dirtyClasses.length === 0) {
509
- addDebugMessage(
510
- 'No dirty classes to process, skipping Tailwind update'
511
- );
512
- } else {
513
- // STEP 1: Generate CSS using Astro API
514
- const astroEndpoint = `/api/tailwind`;
515
- const astroPayload = { dirtyPaneIds, dirtyClasses };
516
- const astroResponse = await fetch(astroEndpoint, {
517
- method: 'POST',
518
- headers: {
519
- 'Content-Type': 'application/json',
520
- 'X-Tenant-ID': tenantId,
521
- },
522
- credentials: 'include',
523
- body: JSON.stringify(astroPayload),
524
- });
525
-
526
- if (!astroResponse.ok) {
527
- throw new Error(
528
- `CSS generation failed! status: ${astroResponse.status}`
529
- );
530
- }
508
+ // STEP 1: Generate CSS using Astro API
509
+ const astroEndpoint = `/api/tailwind`;
510
+ const astroPayload = { dirtyPaneIds, dirtyClasses };
511
+ const astroResponse = await fetch(astroEndpoint, {
512
+ method: 'POST',
513
+ headers: {
514
+ 'Content-Type': 'application/json',
515
+ 'X-Tenant-ID': tenantId,
516
+ },
517
+ credentials: 'include',
518
+ body: JSON.stringify(astroPayload),
519
+ });
531
520
 
532
- const astroResult = await astroResponse.json();
521
+ if (!astroResponse.ok) {
522
+ throw new Error(
523
+ `CSS generation failed! status: ${astroResponse.status}`
524
+ );
525
+ }
533
526
 
534
- if (!astroResult.success || !astroResult.generatedCss) {
535
- throw new Error('CSS generation failed: no CSS returned');
536
- }
527
+ const astroResult = await astroResponse.json();
537
528
 
538
- addDebugMessage(
539
- `CSS generated: ${astroResult.generatedCss.length} bytes for ${dirtyClasses.length} classes`
540
- );
529
+ if (!astroResult.success || !astroResult.generatedCss) {
530
+ throw new Error('CSS generation failed: no CSS returned');
531
+ }
541
532
 
542
- // STEP 2: Save CSS to Go backend
543
- const goEndpoint = `${goBackend}/api/v1/tailwind/update`;
544
- const goPayload = { frontendCss: astroResult.generatedCss };
545
- const goResponse = await fetch(goEndpoint, {
546
- method: 'POST',
547
- headers: {
548
- 'Content-Type': 'application/json',
549
- 'X-Tenant-ID': tenantId,
550
- },
551
- credentials: 'include',
552
- body: JSON.stringify(goPayload),
553
- });
533
+ addDebugMessage(
534
+ `CSS generated: ${astroResult.generatedCss.length} bytes for ${dirtyClasses.length} classes`
535
+ );
554
536
 
555
- if (!goResponse.ok) {
556
- throw new Error(`CSS save failed! status: ${goResponse.status}`);
557
- }
537
+ // STEP 2: Save CSS to Go backend
538
+ const goEndpoint = `${goBackend}/api/v1/tailwind/update`;
539
+ const goPayload = { frontendCss: astroResult.generatedCss };
540
+ const goResponse = await fetch(goEndpoint, {
541
+ method: 'POST',
542
+ headers: {
543
+ 'Content-Type': 'application/json',
544
+ 'X-Tenant-ID': tenantId,
545
+ },
546
+ credentials: 'include',
547
+ body: JSON.stringify(goPayload),
548
+ });
558
549
 
559
- const goResult = await goResponse.json();
560
- addDebugMessage(
561
- `CSS saved successfully: stylesVer ${goResult.stylesVer}`
562
- );
550
+ if (!goResponse.ok) {
551
+ throw new Error(`CSS save failed! status: ${goResponse.status}`);
563
552
  }
553
+
554
+ const goResult = await goResponse.json();
555
+ addDebugMessage(
556
+ `CSS saved successfully: stylesVer ${goResult.stylesVer}`
557
+ );
564
558
  } catch (error) {
565
559
  const errorMsg =
566
560
  error instanceof Error ? error.message : 'Unknown error';
@@ -50,19 +50,30 @@ const isDev = import.meta.env.DEV;
50
50
  // Get site status from the store
51
51
  const isInitialized = !freshInstallStore.get().needsSetup;
52
52
 
53
- // Conditionally set asset paths based on initialization status
54
- const cssBasePath = isInitialized ? '/media/css' : '/styles';
55
- const fontBasePath = isInitialized ? '/media/fonts' : '/fonts';
56
- const mainStylesUrl =
57
- isStoryKeep || isDev
58
- ? `${cssBasePath}/storykeep.css`
59
- : `${cssBasePath}/frontend.css`;
53
+ // ensure we have brand config!
60
54
  const goBackend = import.meta.env.PUBLIC_GO_BACKEND || 'http://localhost:8080';
61
55
  const tenantId =
62
56
  Astro.locals.tenant?.id || import.meta.env.PUBLIC_TENANTID || 'default';
57
+ const brandConfig = propBrandConfig || (await getBrandConfig(tenantId));
58
+
59
+ // Conditionally set asset paths based on initialization status
60
+ const cssBasePath = isInitialized ? '/media/css' : '/styles';
61
+ const fontBasePath = isInitialized ? '/media/fonts' : '/fonts';
62
+ const mainStylesUrl = (() => {
63
+ const baseUrl =
64
+ isStoryKeep || isDev
65
+ ? `${cssBasePath}/storykeep.css`
66
+ : `${cssBasePath}/frontend.css`;
67
+
68
+ // Only add version for frontend.css (the dynamic one)
69
+ if (!isStoryKeep && !isDev && brandConfig?.STYLES_VER) {
70
+ return `${baseUrl}?v=${brandConfig.STYLES_VER}`;
71
+ }
72
+
73
+ return baseUrl;
74
+ })();
63
75
 
64
76
  // Social media and SEO setup
65
- const brandConfig = propBrandConfig || (await getBrandConfig(tenantId));
66
77
  const defaultFavIcon = brandConfig.FAVICON || `/brand/favicon.ico`;
67
78
  const defaultSocialImageURL = ogImage || brandConfig.OG || `/brand/og.png`;
68
79
  const defaultSocialLogoURL = brandConfig.OGLOGO || `/brand/oglogo.png`;
@@ -7,6 +7,7 @@ export interface StoryData {
7
7
  slug: string;
8
8
  paneIds: string[];
9
9
  codeHookTargets: Record<string, string>;
10
+ resourcesPayload: Record<string, any[]>;
10
11
  impressions: ImpressionNode[];
11
12
  fragments: Record<string, string>;
12
13
  menu: any;
@@ -43,6 +43,7 @@ const storyfragmentId = storyData.id;
43
43
  const storyfragmentTitle = storyData.title || 'Untitled Story';
44
44
  const paneIds = storyData.paneIds || [];
45
45
  const codeHookTargets = storyData.codeHookTargets || {};
46
+ const resourcesPayload = storyData.resourcesPayload || {};
46
47
 
47
48
  if (paneIds.length === 0) {
48
49
  console.log(`Empty Story Fragment. Redirecting to /storykeep`);
@@ -134,6 +135,7 @@ if (!brandConfig.SITE_INIT) {
134
135
  target={codeHookTargets[paneId]}
135
136
  paneId={paneId}
136
137
  fullContentMap={fullContentMap}
138
+ resourcesPayload={resourcesPayload}
137
139
  noPaneId={true}
138
140
  />
139
141
  </div>
@@ -59,6 +59,7 @@ try {
59
59
  const paneId = contextPaneData.id;
60
60
  const paneTitle = contextPaneData.title || 'Context';
61
61
  const codeHookTarget = contextPaneData.codeHookTarget || null;
62
+ const resourcesPayload = storyData.resourcesPayload || {};
62
63
 
63
64
  // Get rendered fragment for the context pane
64
65
  let fragmentData = '';
@@ -123,7 +124,11 @@ if (!brandConfig.SITE_INIT) {
123
124
  >
124
125
  {
125
126
  codeHookTarget ? (
126
- <CodeHook target={codeHookTarget} fullContentMap={fullContentMap} />
127
+ <CodeHook
128
+ target={codeHookTarget}
129
+ resourcesPayload={resourcesPayload}
130
+ fullContentMap={fullContentMap}
131
+ />
127
132
  ) : (
128
133
  <Fragment set:html={fragmentData} />
129
134
  )
@@ -113,9 +113,9 @@ export function setupLayoutObservers(): void {
113
113
  toolModeNav.style.left = '0';
114
114
 
115
115
  // Add margin to main content when nav becomes fixed (nav no longer takes flex space)
116
- if (mainContent) {
117
- mainContent.classList.add('md:ml-16');
118
- }
116
+ //if (mainContent) {
117
+ // mainContent.classList.add('md:ml-16');
118
+ //}
119
119
  } else {
120
120
  // Normal static positioning when header is visible
121
121
  toolModeNav.classList.remove('md:fixed');
@@ -124,9 +124,9 @@ export function setupLayoutObservers(): void {
124
124
  toolModeNav.style.left = '';
125
125
 
126
126
  // Remove margin from main content when nav is static (nav takes flex space naturally)
127
- if (mainContent) {
128
- mainContent.classList.remove('md:ml-16');
129
- }
127
+ //if (mainContent) {
128
+ // mainContent.classList.remove('md:ml-16');
129
+ //}
130
130
  }
131
131
  }
132
132
  };