@yoamigo.com/core 0.1.3 → 0.1.5
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 +3 -0
- package/dist/prod.js +69 -1
- package/package.json +3 -1
package/dist/prod.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
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, u as useContentStore } from './MarkdownText-mylt-QX-.js';
|
|
2
2
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
3
|
import React from 'react';
|
|
4
|
+
export { Link, LinkProps, NavigateFunction, Router, RouterProps, useNavigate } from './router.js';
|
|
5
|
+
export { Route, Switch } from 'wouter';
|
|
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';
|
|
4
7
|
|
|
5
8
|
interface StaticLinkProps {
|
|
6
9
|
fieldId: string;
|
package/dist/prod.js
CHANGED
|
@@ -3,12 +3,24 @@ import { createContext, useContext } from "react";
|
|
|
3
3
|
|
|
4
4
|
// src/lib/content-registry.ts
|
|
5
5
|
var contentMap = /* @__PURE__ */ new Map();
|
|
6
|
+
function registerContent(content) {
|
|
7
|
+
contentMap = new Map(Object.entries(content));
|
|
8
|
+
}
|
|
6
9
|
function getContent(fieldId) {
|
|
7
10
|
return contentMap.get(fieldId) ?? "";
|
|
8
11
|
}
|
|
9
12
|
function getAllContent() {
|
|
10
13
|
return Object.fromEntries(contentMap);
|
|
11
14
|
}
|
|
15
|
+
function hasContent(fieldId) {
|
|
16
|
+
return contentMap.has(fieldId);
|
|
17
|
+
}
|
|
18
|
+
var contentRegistry = {
|
|
19
|
+
registerContent,
|
|
20
|
+
getContent,
|
|
21
|
+
getAllContent,
|
|
22
|
+
hasContent
|
|
23
|
+
};
|
|
12
24
|
|
|
13
25
|
// src/components/ContentStoreProvider.prod.tsx
|
|
14
26
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -51,6 +63,9 @@ function MpText({ fieldId, className, as: Component = "span", children }) {
|
|
|
51
63
|
|
|
52
64
|
// src/lib/asset-resolver.ts
|
|
53
65
|
var assetResolver = (path) => path;
|
|
66
|
+
function setAssetResolver(resolver) {
|
|
67
|
+
assetResolver = resolver;
|
|
68
|
+
}
|
|
54
69
|
function resolveAssetUrl(path) {
|
|
55
70
|
if (!path) return "";
|
|
56
71
|
if (path.startsWith("http://") || path.startsWith("https://")) {
|
|
@@ -281,15 +296,68 @@ function MarkdownText({ content, className }) {
|
|
|
281
296
|
const elements = parseMarkdownToElements(content);
|
|
282
297
|
return /* @__PURE__ */ jsx6("span", { className, children: elements });
|
|
283
298
|
}
|
|
299
|
+
|
|
300
|
+
// src/router/Link.tsx
|
|
301
|
+
import { Link as WouterLink } from "wouter";
|
|
302
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
303
|
+
function Link({ to, href, children, className, onClick, replace, ...props }) {
|
|
304
|
+
const target = href ?? to ?? "/";
|
|
305
|
+
return /* @__PURE__ */ jsx7(WouterLink, { href: target, className, onClick, replace, ...props, children });
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
// src/router/useNavigate.ts
|
|
309
|
+
import { useLocation as useLocation2 } from "wouter";
|
|
310
|
+
function useNavigate() {
|
|
311
|
+
const [, setLocation] = useLocation2();
|
|
312
|
+
return (to, options) => {
|
|
313
|
+
if (options?.replace) {
|
|
314
|
+
window.history.replaceState(null, "", to);
|
|
315
|
+
setLocation(to);
|
|
316
|
+
} else {
|
|
317
|
+
setLocation(to);
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
// src/router/Router.tsx
|
|
323
|
+
import { Router as WouterRouter } from "wouter";
|
|
324
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
325
|
+
function detectBasename() {
|
|
326
|
+
if (typeof window === "undefined") return "";
|
|
327
|
+
const sessionMatch = window.location.pathname.match(/^\/session\/[^/]+/);
|
|
328
|
+
if (sessionMatch) return sessionMatch[0];
|
|
329
|
+
const previewMatch = window.location.pathname.match(/^\/deploy-preview\/[^/]+/);
|
|
330
|
+
if (previewMatch) return previewMatch[0];
|
|
331
|
+
return "";
|
|
332
|
+
}
|
|
333
|
+
function Router({ children, base }) {
|
|
334
|
+
const basename = base ?? detectBasename();
|
|
335
|
+
return /* @__PURE__ */ jsx8(WouterRouter, { base: basename, children });
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
// src/router/index.ts
|
|
339
|
+
import { Route, Switch } from "wouter";
|
|
284
340
|
export {
|
|
285
341
|
ContentStoreProvider,
|
|
342
|
+
Link,
|
|
286
343
|
MarkdownText,
|
|
344
|
+
Route,
|
|
345
|
+
Router,
|
|
287
346
|
SafeHtml,
|
|
288
347
|
MpImage as StaticImage,
|
|
289
348
|
StaticLink,
|
|
290
349
|
MpText as StaticText,
|
|
350
|
+
Switch,
|
|
291
351
|
MpImage as YaImage,
|
|
292
352
|
StaticLink as YaLink,
|
|
293
353
|
MpText as YaText,
|
|
294
|
-
|
|
354
|
+
contentRegistry,
|
|
355
|
+
getAllContent,
|
|
356
|
+
getContent,
|
|
357
|
+
hasContent,
|
|
358
|
+
registerContent,
|
|
359
|
+
resolveAssetUrl,
|
|
360
|
+
setAssetResolver,
|
|
361
|
+
useContentStore,
|
|
362
|
+
useNavigate
|
|
295
363
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yoamigo.com/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Core components, router, and utilities for YoAmigo templates",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -95,6 +95,8 @@
|
|
|
95
95
|
"vite": "^7.2.4"
|
|
96
96
|
},
|
|
97
97
|
"peerDependencies": {
|
|
98
|
+
"@vitejs/plugin-react": "^5.0.0",
|
|
99
|
+
"@preact/preset-vite": "^2.0.0",
|
|
98
100
|
"react": "^18.0.0 || ^19.0.0",
|
|
99
101
|
"react-dom": "^18.0.0 || ^19.0.0",
|
|
100
102
|
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0"
|