@yoamigo.com/core 0.4.0 → 0.4.2

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/dist/prod.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { a as ContentStore, E as ContentStoreMode, C as ContentStoreProvider, d as MarkdownText, e as MarkdownTextProps, P as PageInfo, b as StaticImage, c as StaticImageProps, M as StaticText, S as StaticTextProps, b as YaImage, c as YaImageProps, M as YaText, S as YaTextProps, p as parseEmbedUrl, u as useContentStore } from './MarkdownText-_ykp-njt.js';
1
+ export { a as ContentStore, E as ContentStoreMode, C as ContentStoreProvider, f as MarkdownText, g as MarkdownTextProps, P as PageInfo, c as StaticImage, d as StaticImageProps, M as StaticText, S as StaticTextProps, c as YaImage, d as YaImageProps, M as YaText, S as YaTextProps, b as background, e as embed, i as image, p as parseEmbedUrl, t as text, u as useContentStore, v as video } from './content-helpers-kWphH5Tn.js';
2
2
  import * as react_jsx_runtime from 'react/jsx-runtime';
3
3
  import React, { CSSProperties, ReactNode } from 'react';
4
4
  export { Link, LinkProps, NavigateFunction, Router, RouterProps, ScrollRestoration, useNavigate } from './router.js';
package/dist/prod.js CHANGED
@@ -241,9 +241,9 @@ function StaticLink({ fieldId, href: defaultHref = "#", className, style, as: Co
241
241
  // src/components/MarkdownText.tsx
242
242
  import { Fragment } from "react";
243
243
  import { jsx as jsx6 } from "react/jsx-runtime";
244
- function tokenize(text) {
244
+ function tokenize(text2) {
245
245
  const tokens = [];
246
- let remaining = text;
246
+ let remaining = text2;
247
247
  const patterns = [
248
248
  // Bold: **text**
249
249
  { regex: /^\*\*(.+?)\*\*/, type: "bold" },
@@ -515,12 +515,12 @@ function StaticVideo({
515
515
  (e) => {
516
516
  if ((e.key === " " || e.key === "Enter") && videoData.type === "upload" && controls) {
517
517
  e.preventDefault();
518
- const video = videoRef.current;
519
- if (video) {
520
- if (video.paused) {
521
- video.play();
518
+ const video2 = videoRef.current;
519
+ if (video2) {
520
+ if (video2.paused) {
521
+ video2.play();
522
522
  } else {
523
- video.pause();
523
+ video2.pause();
524
524
  }
525
525
  }
526
526
  }
@@ -1051,6 +1051,23 @@ function ScrollRestoration() {
1051
1051
 
1052
1052
  // src/router/index.ts
1053
1053
  import { Route, Switch, useParams } from "wouter";
1054
+
1055
+ // src/lib/content-helpers.ts
1056
+ function text(content) {
1057
+ return content;
1058
+ }
1059
+ function image(config) {
1060
+ return JSON.stringify(config);
1061
+ }
1062
+ function background(config) {
1063
+ return JSON.stringify(config);
1064
+ }
1065
+ function video(config) {
1066
+ return JSON.stringify(config);
1067
+ }
1068
+ function embed(config) {
1069
+ return JSON.stringify(config);
1070
+ }
1054
1071
  export {
1055
1072
  ContentStoreProvider,
1056
1073
  Link,
@@ -1072,10 +1089,13 @@ export {
1072
1089
  StaticLink as YaLink,
1073
1090
  MpText as YaText,
1074
1091
  StaticVideo as YaVideo,
1092
+ background,
1075
1093
  contentRegistry,
1094
+ embed,
1076
1095
  getAllContent,
1077
1096
  getContent,
1078
1097
  hasContent,
1098
+ image,
1079
1099
  parseBackgroundConfig,
1080
1100
  parseEmbedUrl,
1081
1101
  registerContent,
@@ -1084,7 +1104,9 @@ export {
1084
1104
  serializeEmbedValue,
1085
1105
  serializeVideoValue,
1086
1106
  setAssetResolver,
1107
+ text,
1087
1108
  useContentStore,
1088
1109
  useNavigate,
1089
- useParams
1110
+ useParams,
1111
+ video
1090
1112
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yoamigo.com/core",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "Core components, router, and utilities for YoAmigo templates",
5
5
  "type": "module",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -62,7 +62,6 @@
62
62
  "prepublishOnly": "pnpm build"
63
63
  },
64
64
  "dependencies": {
65
- "@floating-ui/react": "^0.27.16",
66
65
  "clsx": "^2.1.1",
67
66
  "html2canvas-pro": "^1.6.1",
68
67
  "wouter": "^3.8.0"
@@ -1,157 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import React$1, { ReactNode } from 'react';
3
-
4
- type EditMode = 'read-only' | 'inline-edit';
5
- interface ContentStore {
6
- getValue: (fieldId: string) => string;
7
- setValue: (fieldId: string, value: string) => void;
8
- mode: EditMode;
9
- setMode: (mode: EditMode) => void;
10
- subscribe: (listener: () => void) => () => void;
11
- saveToWorker?: (fieldId: string, value: string) => Promise<void>;
12
- }
13
- declare function useContentStore(): ContentStore;
14
- interface ContentStoreProviderProps {
15
- children: ReactNode;
16
- initialContent?: Record<string, string>;
17
- initialMode?: EditMode;
18
- }
19
- declare function ContentStoreProvider({ children, initialContent }: ContentStoreProviderProps): react_jsx_runtime.JSX.Element;
20
-
21
- type EmbedType = 'spotify' | 'soundcloud' | 'twitter' | 'instagram' | 'custom';
22
- interface EmbedFieldValue {
23
- /** Embed platform type */
24
- type: EmbedType;
25
- /** Embed URL or ID (platform-specific) */
26
- src: string;
27
- /** Original URL pasted by user (for editing) */
28
- originalUrl?: string;
29
- /** CSS aspect-ratio (e.g., "16/9", "1/1") */
30
- aspectRatio?: string;
31
- /** Fixed height in pixels (for audio players) */
32
- height?: number;
33
- /** Spotify-specific: content type */
34
- spotifyType?: 'track' | 'album' | 'playlist' | 'episode' | 'show';
35
- }
36
- interface YaEmbedProps {
37
- fieldId: string;
38
- className?: string;
39
- /** Default aspect ratio from props */
40
- aspectRatio?: string;
41
- /** Max width constraint */
42
- maxWidth?: number;
43
- /** Loading strategy */
44
- loading?: 'lazy' | 'eager';
45
- /** Default embed value (used when nothing in content store) */
46
- defaultValue?: EmbedFieldValue;
47
- }
48
- interface ParsedEmbed {
49
- type: EmbedType;
50
- src: string;
51
- originalUrl: string;
52
- aspectRatio?: string;
53
- height?: number;
54
- spotifyType?: EmbedFieldValue['spotifyType'];
55
- }
56
- /**
57
- * Parse a URL and detect the embed platform
58
- */
59
- declare function parseEmbedUrl(url: string): ParsedEmbed | null;
60
- /**
61
- * Serialize embed field value for storage
62
- */
63
- declare function serializeEmbedValue(value: EmbedFieldValue): string;
64
- declare function YaEmbed({ fieldId, className, aspectRatio: propAspectRatio, maxWidth, loading, defaultValue, }: YaEmbedProps): react_jsx_runtime.JSX.Element;
65
-
66
- interface PageInfo {
67
- path: string;
68
- label: string;
69
- }
70
- interface YaLinkProps {
71
- fieldId: string;
72
- /** Default href if not set in content store */
73
- href?: string;
74
- className?: string;
75
- /** Inline styles to apply to the link element */
76
- style?: React$1.CSSProperties;
77
- as?: 'a' | 'span';
78
- children?: React$1.ReactNode;
79
- /** Available pages for href dropdown (injected by template) */
80
- availablePages?: PageInfo[];
81
- /** Optional click handler called after navigation */
82
- onClick?: () => void;
83
- /** Target attribute for the link (e.g., "_blank" to open in new tab) */
84
- target?: string;
85
- /** Rel attribute for the link (e.g., "noopener noreferrer" for security) */
86
- rel?: string;
87
- }
88
- declare module '@tiptap/core' {
89
- interface Commands<ReturnType> {
90
- fontSize: {
91
- setFontSize: (fontSize: string) => ReturnType;
92
- unsetFontSize: () => ReturnType;
93
- };
94
- fontWeight: {
95
- setFontWeight: (fontWeight: string) => ReturnType;
96
- unsetFontWeight: () => ReturnType;
97
- };
98
- }
99
- }
100
- declare function YaLink({ fieldId, href: defaultHref, className, style, as: Component, children, availablePages, onClick, target, rel }: YaLinkProps): react_jsx_runtime.JSX.Element;
101
-
102
- /**
103
- * StaticText Component - Production-only static text renderer
104
- *
105
- * This component replaces MpText in production builds via Vite alias.
106
- * No editing capabilities, no Tiptap, no DOMPurify - minimal bundle size.
107
- *
108
- * Content from content.json is trusted because:
109
- * 1. It's created in the builder using Tiptap (which controls allowed markup)
110
- * 2. It's sanitized by SafeHtml when displayed in the builder
111
- * 3. Users can't inject arbitrary HTML
112
- */
113
- /** Common HTML elements that MpText can render as */
114
- type MpTextElement = 'span' | 'div' | 'p' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'label' | 'strong' | 'em';
115
- interface MpTextProps {
116
- fieldId: string;
117
- className?: string;
118
- as?: MpTextElement;
119
- /** Optional fallback content (used if fieldId not in store) */
120
- children?: React.ReactNode;
121
- }
122
- declare function MpText({ fieldId, className, as: Component, children }: MpTextProps): react_jsx_runtime.JSX.Element;
123
-
124
- type StaticTextProps = MpTextProps;
125
-
126
- /**
127
- * StaticImage Component - Production-only static image renderer
128
- *
129
- * This component replaces MpImage in production builds via Vite alias.
130
- * No editing overlay, no click handlers, no postMessage - minimal bundle size.
131
- */
132
- interface MpImageProps {
133
- fieldId: string;
134
- className?: string;
135
- alt?: string;
136
- objectFit?: 'cover' | 'contain' | 'fill';
137
- objectPosition?: string;
138
- loading?: 'lazy' | 'eager';
139
- /** Fallback for backward compatibility with config.ts images */
140
- fallbackSrc?: string;
141
- /** Fallback alt text */
142
- fallbackAlt?: string;
143
- }
144
- declare function MpImage({ fieldId, className, alt, objectFit: propObjectFit, objectPosition: propObjectPosition, loading, fallbackSrc, fallbackAlt, }: MpImageProps): react_jsx_runtime.JSX.Element;
145
-
146
- type StaticImageProps = MpImageProps;
147
-
148
- interface MarkdownTextProps {
149
- content: string;
150
- className?: string;
151
- }
152
- /**
153
- * MarkdownText component - renders markdown content safely
154
- */
155
- declare function MarkdownText({ content, className }: MarkdownTextProps): react_jsx_runtime.JSX.Element;
156
-
157
- export { ContentStoreProvider as C, type EditMode as E, MpText as M, type PageInfo as P, type StaticTextProps as S, YaEmbed as Y, type ContentStore as a, MpImage as b, type StaticImageProps as c, MarkdownText as d, type MarkdownTextProps as e, type EmbedFieldValue as f, type YaEmbedProps as g, type EmbedType as h, YaLink as i, type YaLinkProps as j, parseEmbedUrl as p, serializeEmbedValue as s, useContentStore as u };