@yoamigo.com/core 0.3.5 → 0.3.7
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/{MarkdownText-Nvkeyr1z.d.ts → MarkdownText-DHJo0ofY.d.ts} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +64 -25
- package/dist/prod.d.ts +1 -1
- package/dist/prod.js +44 -7
- package/package.json +1 -1
|
@@ -16,7 +16,7 @@ interface ContentStoreProviderProps {
|
|
|
16
16
|
initialContent?: Record<string, string>;
|
|
17
17
|
initialMode?: EditMode;
|
|
18
18
|
}
|
|
19
|
-
declare function ContentStoreProvider({ children }: ContentStoreProviderProps): react_jsx_runtime.JSX.Element;
|
|
19
|
+
declare function ContentStoreProvider({ children, initialContent }: ContentStoreProviderProps): react_jsx_runtime.JSX.Element;
|
|
20
20
|
|
|
21
21
|
type EmbedType = 'spotify' | 'soundcloud' | 'twitter' | 'instagram' | 'custom';
|
|
22
22
|
interface EmbedFieldValue {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import React$1, { ReactNode, CSSProperties } from 'react';
|
|
3
|
-
export { C as ContentStoreProviderProd, g as EmbedFieldValue, h as EmbedType, d as MarkdownText, e as MarkdownTextProps, P as PageInfo, b as StaticImage, c as StaticImageProps, M as StaticText, S as StaticTextProps, Y as YaEmbed, f as YaEmbedProps, i as YaLink, j as YaLinkProps, p as parseEmbedUrl, s as serializeEmbedValue, u as useContentStoreProd } from './MarkdownText-
|
|
3
|
+
export { C as ContentStoreProviderProd, g as EmbedFieldValue, h as EmbedType, d as MarkdownText, e as MarkdownTextProps, P as PageInfo, b as StaticImage, c as StaticImageProps, M as StaticText, S as StaticTextProps, Y as YaEmbed, f as YaEmbedProps, i as YaLink, j as YaLinkProps, p as parseEmbedUrl, s as serializeEmbedValue, u as useContentStoreProd } from './MarkdownText-DHJo0ofY.js';
|
|
4
4
|
export { Link, LinkProps, NavigateFunction, Router, RouterProps, useNavigate } from './router.js';
|
|
5
5
|
export { Route, Switch, useParams } from 'wouter';
|
|
6
6
|
export { A as AssetResolverFn, C as ContentRegistry, c as contentRegistry, a as getAllContent, g as getContent, h as hasContent, r as registerContent, b as resolveAssetUrl, s as setAssetResolver } from './asset-resolver-BnIvDkVv.js';
|
package/dist/index.js
CHANGED
|
@@ -963,11 +963,10 @@ function ContentStoreProvider({
|
|
|
963
963
|
}
|
|
964
964
|
|
|
965
965
|
// src/components/ContentStoreProvider.prod.tsx
|
|
966
|
-
import { createContext as createContext2, useContext as useContext2 } from "react";
|
|
966
|
+
import { createContext as createContext2, useContext as useContext2, useMemo } from "react";
|
|
967
967
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
968
|
-
var
|
|
969
|
-
|
|
970
|
-
getValue: (fieldId) => contentMap2.get(fieldId) ?? "",
|
|
968
|
+
var defaultStore = {
|
|
969
|
+
getValue: () => "",
|
|
971
970
|
setValue: () => {
|
|
972
971
|
},
|
|
973
972
|
// No-op in production
|
|
@@ -980,12 +979,50 @@ var staticStore = {
|
|
|
980
979
|
// No-op, return empty unsubscribe
|
|
981
980
|
saveToWorker: void 0
|
|
982
981
|
};
|
|
983
|
-
var ContentStoreContext2 = createContext2(
|
|
982
|
+
var ContentStoreContext2 = createContext2(defaultStore);
|
|
984
983
|
function useContentStore2() {
|
|
985
984
|
return useContext2(ContentStoreContext2);
|
|
986
985
|
}
|
|
987
|
-
function ContentStoreProvider2({ children }) {
|
|
988
|
-
|
|
986
|
+
function ContentStoreProvider2({ children, initialContent }) {
|
|
987
|
+
const parentStore = useContext2(ContentStoreContext2);
|
|
988
|
+
const hasParent = parentStore !== defaultStore;
|
|
989
|
+
const store = useMemo(() => {
|
|
990
|
+
if (initialContent) {
|
|
991
|
+
return {
|
|
992
|
+
getValue: (fieldId) => initialContent[fieldId] ?? "",
|
|
993
|
+
setValue: () => {
|
|
994
|
+
},
|
|
995
|
+
// No-op in production
|
|
996
|
+
mode: "read-only",
|
|
997
|
+
setMode: () => {
|
|
998
|
+
},
|
|
999
|
+
// No-op in production
|
|
1000
|
+
subscribe: () => () => {
|
|
1001
|
+
},
|
|
1002
|
+
// No-op, return empty unsubscribe
|
|
1003
|
+
saveToWorker: void 0
|
|
1004
|
+
};
|
|
1005
|
+
}
|
|
1006
|
+
if (hasParent) {
|
|
1007
|
+
return parentStore;
|
|
1008
|
+
}
|
|
1009
|
+
const registryContent = getAllContent();
|
|
1010
|
+
return {
|
|
1011
|
+
getValue: (fieldId) => registryContent[fieldId] ?? "",
|
|
1012
|
+
setValue: () => {
|
|
1013
|
+
},
|
|
1014
|
+
// No-op in production
|
|
1015
|
+
mode: "read-only",
|
|
1016
|
+
setMode: () => {
|
|
1017
|
+
},
|
|
1018
|
+
// No-op in production
|
|
1019
|
+
subscribe: () => () => {
|
|
1020
|
+
},
|
|
1021
|
+
// No-op, return empty unsubscribe
|
|
1022
|
+
saveToWorker: void 0
|
|
1023
|
+
};
|
|
1024
|
+
}, [initialContent, hasParent, parentStore]);
|
|
1025
|
+
return /* @__PURE__ */ jsx2(ContentStoreContext2.Provider, { value: store, children });
|
|
989
1026
|
}
|
|
990
1027
|
|
|
991
1028
|
// src/components/YaText.tsx
|
|
@@ -1055,17 +1092,19 @@ import DOMPurify from "dompurify";
|
|
|
1055
1092
|
import { Fragment, jsx as jsx4, jsxs } from "react/jsx-runtime";
|
|
1056
1093
|
var ALLOWED_TAGS = ["strong", "em", "a", "span", "br", "b", "i", "u"];
|
|
1057
1094
|
var ALLOWED_ATTR = ["href", "style", "class", "target", "rel"];
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
const
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
}
|
|
1095
|
+
if (typeof window !== "undefined") {
|
|
1096
|
+
DOMPurify.addHook("uponSanitizeAttribute", (_node, data) => {
|
|
1097
|
+
if (data.attrName === "style") {
|
|
1098
|
+
const allowedStyles = ["font-size", "font-weight"];
|
|
1099
|
+
const styleValue = data.attrValue;
|
|
1100
|
+
const filteredStyles = styleValue.split(";").map((s) => s.trim()).filter((s) => {
|
|
1101
|
+
const [prop] = s.split(":").map((p) => p.trim());
|
|
1102
|
+
return allowedStyles.includes(prop);
|
|
1103
|
+
}).join("; ");
|
|
1104
|
+
data.attrValue = filteredStyles;
|
|
1105
|
+
}
|
|
1106
|
+
});
|
|
1107
|
+
}
|
|
1069
1108
|
function extractLinkDisplayText(href) {
|
|
1070
1109
|
if (!href) return { text: "link", isExternal: false };
|
|
1071
1110
|
if (href.startsWith("#")) {
|
|
@@ -1269,13 +1308,13 @@ function SafeHtml({ content, className, mode = "read-only" }) {
|
|
|
1269
1308
|
}
|
|
1270
1309
|
|
|
1271
1310
|
// src/hooks/useAnimatedText.ts
|
|
1272
|
-
import { useMemo as
|
|
1311
|
+
import { useMemo as useMemo4 } from "react";
|
|
1273
1312
|
|
|
1274
1313
|
// src/hooks/useAIEditAnimation.ts
|
|
1275
|
-
import { useState as useState3, useEffect as useEffect3, useRef as useRef4, useCallback as useCallback4, useMemo as
|
|
1314
|
+
import { useState as useState3, useEffect as useEffect3, useRef as useRef4, useCallback as useCallback4, useMemo as useMemo3 } from "react";
|
|
1276
1315
|
|
|
1277
1316
|
// src/contexts/AIEditContext.tsx
|
|
1278
|
-
import { createContext as createContext3, useContext as useContext3, useCallback as useCallback3, useRef as useRef3, useMemo } from "react";
|
|
1317
|
+
import { createContext as createContext3, useContext as useContext3, useCallback as useCallback3, useRef as useRef3, useMemo as useMemo2 } from "react";
|
|
1279
1318
|
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
1280
1319
|
var AIEditContext = createContext3(null);
|
|
1281
1320
|
function useAIEditContext() {
|
|
@@ -1387,7 +1426,7 @@ function AIEditProvider({ children, staggerDelay = 100 }) {
|
|
|
1387
1426
|
},
|
|
1388
1427
|
[notifyListeners]
|
|
1389
1428
|
);
|
|
1390
|
-
const value =
|
|
1429
|
+
const value = useMemo2(
|
|
1391
1430
|
() => ({
|
|
1392
1431
|
queueAnimation,
|
|
1393
1432
|
cancelAnimation,
|
|
@@ -1506,7 +1545,7 @@ function useAIEditAnimation(fieldId, value, options) {
|
|
|
1506
1545
|
}
|
|
1507
1546
|
};
|
|
1508
1547
|
}, []);
|
|
1509
|
-
const wrapperProps =
|
|
1548
|
+
const wrapperProps = useMemo3(
|
|
1510
1549
|
() => ({
|
|
1511
1550
|
className: phase === "animating" ? "ya-ai-editing" : phase === "complete" ? "ya-ai-complete" : "",
|
|
1512
1551
|
"data-ai-editing": phase === "animating"
|
|
@@ -1728,7 +1767,7 @@ function useAnimatedText(fieldId, content, options = {}) {
|
|
|
1728
1767
|
onStart,
|
|
1729
1768
|
onComplete
|
|
1730
1769
|
} = options;
|
|
1731
|
-
const customStrategy =
|
|
1770
|
+
const customStrategy = useMemo4(() => {
|
|
1732
1771
|
if (charDelay === 50) {
|
|
1733
1772
|
return textTypingStrategy;
|
|
1734
1773
|
}
|
|
@@ -1767,7 +1806,7 @@ function useAnimatedText(fieldId, content, options = {}) {
|
|
|
1767
1806
|
onStart,
|
|
1768
1807
|
onComplete
|
|
1769
1808
|
});
|
|
1770
|
-
const cursorPosition =
|
|
1809
|
+
const cursorPosition = useMemo4(() => {
|
|
1771
1810
|
if (!isAnimating) return null;
|
|
1772
1811
|
const diff = computeTextDiff(content, displayValue);
|
|
1773
1812
|
const { deleteDuration, typeDuration } = calculateAnimationTiming(diff, {
|
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-
|
|
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-DHJo0ofY.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, useNavigate } from './router.js';
|
package/dist/prod.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/components/ContentStoreProvider.prod.tsx
|
|
2
|
-
import { createContext, useContext } from "react";
|
|
2
|
+
import { createContext, useContext, useMemo } from "react";
|
|
3
3
|
|
|
4
4
|
// src/lib/content-registry.ts
|
|
5
5
|
var contentMap = /* @__PURE__ */ new Map();
|
|
@@ -24,9 +24,8 @@ var contentRegistry = {
|
|
|
24
24
|
|
|
25
25
|
// src/components/ContentStoreProvider.prod.tsx
|
|
26
26
|
import { jsx } from "react/jsx-runtime";
|
|
27
|
-
var
|
|
28
|
-
|
|
29
|
-
getValue: (fieldId) => contentMap2.get(fieldId) ?? "",
|
|
27
|
+
var defaultStore = {
|
|
28
|
+
getValue: () => "",
|
|
30
29
|
setValue: () => {
|
|
31
30
|
},
|
|
32
31
|
// No-op in production
|
|
@@ -39,12 +38,50 @@ var staticStore = {
|
|
|
39
38
|
// No-op, return empty unsubscribe
|
|
40
39
|
saveToWorker: void 0
|
|
41
40
|
};
|
|
42
|
-
var ContentStoreContext = createContext(
|
|
41
|
+
var ContentStoreContext = createContext(defaultStore);
|
|
43
42
|
function useContentStore() {
|
|
44
43
|
return useContext(ContentStoreContext);
|
|
45
44
|
}
|
|
46
|
-
function ContentStoreProvider({ children }) {
|
|
47
|
-
|
|
45
|
+
function ContentStoreProvider({ children, initialContent }) {
|
|
46
|
+
const parentStore = useContext(ContentStoreContext);
|
|
47
|
+
const hasParent = parentStore !== defaultStore;
|
|
48
|
+
const store = useMemo(() => {
|
|
49
|
+
if (initialContent) {
|
|
50
|
+
return {
|
|
51
|
+
getValue: (fieldId) => initialContent[fieldId] ?? "",
|
|
52
|
+
setValue: () => {
|
|
53
|
+
},
|
|
54
|
+
// No-op in production
|
|
55
|
+
mode: "read-only",
|
|
56
|
+
setMode: () => {
|
|
57
|
+
},
|
|
58
|
+
// No-op in production
|
|
59
|
+
subscribe: () => () => {
|
|
60
|
+
},
|
|
61
|
+
// No-op, return empty unsubscribe
|
|
62
|
+
saveToWorker: void 0
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
if (hasParent) {
|
|
66
|
+
return parentStore;
|
|
67
|
+
}
|
|
68
|
+
const registryContent = getAllContent();
|
|
69
|
+
return {
|
|
70
|
+
getValue: (fieldId) => registryContent[fieldId] ?? "",
|
|
71
|
+
setValue: () => {
|
|
72
|
+
},
|
|
73
|
+
// No-op in production
|
|
74
|
+
mode: "read-only",
|
|
75
|
+
setMode: () => {
|
|
76
|
+
},
|
|
77
|
+
// No-op in production
|
|
78
|
+
subscribe: () => () => {
|
|
79
|
+
},
|
|
80
|
+
// No-op, return empty unsubscribe
|
|
81
|
+
saveToWorker: void 0
|
|
82
|
+
};
|
|
83
|
+
}, [initialContent, hasParent, parentStore]);
|
|
84
|
+
return /* @__PURE__ */ jsx(ContentStoreContext.Provider, { value: store, children });
|
|
48
85
|
}
|
|
49
86
|
|
|
50
87
|
// src/components/StaticText.tsx
|