@btst/stack 1.0.0 → 1.1.0
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/README.md +237 -2
- package/dist/api/index.cjs +2 -2
- package/dist/api/index.d.cts +2 -2
- package/dist/api/index.d.mts +2 -2
- package/dist/api/index.d.ts +2 -2
- package/dist/api/index.mjs +2 -2
- package/dist/client/components/compose.cjs +68 -0
- package/dist/client/components/compose.mjs +65 -0
- package/dist/client/components/error-boundary.cjs +24 -0
- package/dist/client/components/error-boundary.mjs +22 -0
- package/dist/client/components/index.cjs +10 -0
- package/dist/client/components/index.d.cts +52 -0
- package/dist/client/components/index.d.mts +52 -0
- package/dist/client/components/index.d.ts +52 -0
- package/dist/client/components/index.mjs +2 -0
- package/dist/client/index.cjs +21 -16
- package/dist/client/index.d.cts +102 -14
- package/dist/client/index.d.mts +102 -14
- package/dist/client/index.d.ts +102 -14
- package/dist/client/index.mjs +19 -10
- package/dist/client/meta-utils.cjs +162 -0
- package/dist/client/meta-utils.mjs +160 -0
- package/dist/client/sitemap-utils.cjs +14 -0
- package/dist/client/sitemap-utils.mjs +12 -0
- package/dist/context/index.cjs +6 -51
- package/dist/context/index.d.cts +26 -26
- package/dist/context/index.d.mts +26 -26
- package/dist/context/index.d.ts +26 -26
- package/dist/context/index.mjs +1 -50
- package/dist/context/provider.cjs +51 -0
- package/dist/context/provider.mjs +46 -0
- package/dist/index.cjs +0 -2
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +0 -2
- package/dist/plugins/api/index.cjs +15 -0
- package/dist/plugins/api/index.d.cts +41 -0
- package/dist/plugins/api/index.d.mts +41 -0
- package/dist/plugins/api/index.d.ts +41 -0
- package/dist/plugins/api/index.mjs +9 -0
- package/dist/plugins/blog/api/index.cjs +11 -0
- package/dist/plugins/blog/api/index.d.cts +7 -0
- package/dist/plugins/blog/api/index.d.mts +7 -0
- package/dist/plugins/blog/api/index.d.ts +7 -0
- package/dist/plugins/blog/api/index.mjs +2 -0
- package/dist/plugins/blog/api/plugin.cjs +569 -0
- package/dist/plugins/blog/api/plugin.mjs +565 -0
- package/dist/plugins/blog/client/components/forms/image-field.cjs +133 -0
- package/dist/plugins/blog/client/components/forms/image-field.mjs +131 -0
- package/dist/plugins/blog/client/components/forms/markdown-editor-styles.css +30 -0
- package/dist/plugins/blog/client/components/forms/markdown-editor.cjs +106 -0
- package/dist/plugins/blog/client/components/forms/markdown-editor.mjs +104 -0
- package/dist/plugins/blog/client/components/forms/post-forms.cjs +401 -0
- package/dist/plugins/blog/client/components/forms/post-forms.mjs +398 -0
- package/dist/plugins/blog/client/components/forms/tags-multiselect.cjs +71 -0
- package/dist/plugins/blog/client/components/forms/tags-multiselect.mjs +65 -0
- package/dist/plugins/blog/client/components/index.cjs +17 -0
- package/dist/plugins/blog/client/components/index.d.cts +22 -0
- package/dist/plugins/blog/client/components/index.d.mts +22 -0
- package/dist/plugins/blog/client/components/index.d.ts +22 -0
- package/dist/plugins/blog/client/components/index.mjs +12 -0
- package/dist/plugins/blog/client/components/loading/form-page-skeleton.cjs +62 -0
- package/dist/plugins/blog/client/components/loading/form-page-skeleton.mjs +60 -0
- package/dist/plugins/blog/client/components/loading/index.cjs +20 -0
- package/dist/plugins/blog/client/components/loading/index.mjs +16 -0
- package/dist/plugins/blog/client/components/loading/list-page-skeleton.cjs +26 -0
- package/dist/plugins/blog/client/components/loading/list-page-skeleton.mjs +24 -0
- package/dist/plugins/blog/client/components/loading/page-header-skeleton.cjs +13 -0
- package/dist/plugins/blog/client/components/loading/page-header-skeleton.mjs +11 -0
- package/dist/plugins/blog/client/components/loading/post-card-skeleton.cjs +22 -0
- package/dist/plugins/blog/client/components/loading/post-card-skeleton.mjs +20 -0
- package/dist/plugins/blog/client/components/loading/post-page-skeleton.cjs +56 -0
- package/dist/plugins/blog/client/components/loading/post-page-skeleton.mjs +54 -0
- package/dist/plugins/blog/client/components/pages/404-page.cjs +19 -0
- package/dist/plugins/blog/client/components/pages/404-page.mjs +17 -0
- package/dist/plugins/blog/client/components/pages/edit-post-page.cjs +41 -0
- package/dist/plugins/blog/client/components/pages/edit-post-page.internal.cjs +57 -0
- package/dist/plugins/blog/client/components/pages/edit-post-page.internal.mjs +55 -0
- package/dist/plugins/blog/client/components/pages/edit-post-page.mjs +39 -0
- package/dist/plugins/blog/client/components/pages/home-page.cjs +41 -0
- package/dist/plugins/blog/client/components/pages/home-page.internal.cjs +61 -0
- package/dist/plugins/blog/client/components/pages/home-page.internal.mjs +59 -0
- package/dist/plugins/blog/client/components/pages/home-page.mjs +39 -0
- package/dist/plugins/blog/client/components/pages/new-post-page.cjs +37 -0
- package/dist/plugins/blog/client/components/pages/new-post-page.internal.cjs +53 -0
- package/dist/plugins/blog/client/components/pages/new-post-page.internal.mjs +51 -0
- package/dist/plugins/blog/client/components/pages/new-post-page.mjs +35 -0
- package/dist/plugins/blog/client/components/pages/post-page.cjs +39 -0
- package/dist/plugins/blog/client/components/pages/post-page.internal.cjs +101 -0
- package/dist/plugins/blog/client/components/pages/post-page.internal.mjs +99 -0
- package/dist/plugins/blog/client/components/pages/post-page.mjs +37 -0
- package/dist/plugins/blog/client/components/pages/tag-page.cjs +39 -0
- package/dist/plugins/blog/client/components/pages/tag-page.internal.cjs +61 -0
- package/dist/plugins/blog/client/components/pages/tag-page.internal.mjs +59 -0
- package/dist/plugins/blog/client/components/pages/tag-page.mjs +37 -0
- package/dist/plugins/blog/client/components/shared/better-blog-attribution.cjs +24 -0
- package/dist/plugins/blog/client/components/shared/better-blog-attribution.mjs +22 -0
- package/dist/plugins/blog/client/components/shared/default-error.cjs +18 -0
- package/dist/plugins/blog/client/components/shared/default-error.mjs +16 -0
- package/dist/plugins/blog/client/components/shared/defaults.cjs +13 -0
- package/dist/plugins/blog/client/components/shared/defaults.mjs +10 -0
- package/dist/plugins/blog/client/components/shared/empty-list.cjs +21 -0
- package/dist/plugins/blog/client/components/shared/empty-list.mjs +19 -0
- package/dist/plugins/blog/client/components/shared/error-placeholder.cjs +24 -0
- package/dist/plugins/blog/client/components/shared/error-placeholder.mjs +22 -0
- package/dist/plugins/blog/client/components/shared/highlight-text.cjs +53 -0
- package/dist/plugins/blog/client/components/shared/highlight-text.mjs +51 -0
- package/dist/plugins/blog/client/components/shared/markdown-content-styles.css +328 -0
- package/dist/plugins/blog/client/components/shared/markdown-content.cjs +324 -0
- package/dist/plugins/blog/client/components/shared/markdown-content.mjs +315 -0
- package/dist/plugins/blog/client/components/shared/on-this-page.cjs +161 -0
- package/dist/plugins/blog/client/components/shared/on-this-page.mjs +158 -0
- package/dist/plugins/blog/client/components/shared/page-header.cjs +40 -0
- package/dist/plugins/blog/client/components/shared/page-header.mjs +38 -0
- package/dist/plugins/blog/client/components/shared/page-layout.cjs +24 -0
- package/dist/plugins/blog/client/components/shared/page-layout.mjs +22 -0
- package/dist/plugins/blog/client/components/shared/page-wrapper.cjs +23 -0
- package/dist/plugins/blog/client/components/shared/page-wrapper.mjs +21 -0
- package/dist/plugins/blog/client/components/shared/post-card.cjs +279 -0
- package/dist/plugins/blog/client/components/shared/post-card.mjs +277 -0
- package/dist/plugins/blog/client/components/shared/post-navigation.cjs +74 -0
- package/dist/plugins/blog/client/components/shared/post-navigation.mjs +72 -0
- package/dist/plugins/blog/client/components/shared/posts-list.cjs +48 -0
- package/dist/plugins/blog/client/components/shared/posts-list.mjs +46 -0
- package/dist/plugins/blog/client/components/shared/recent-posts-carousel.cjs +59 -0
- package/dist/plugins/blog/client/components/shared/recent-posts-carousel.mjs +57 -0
- package/dist/plugins/blog/client/components/shared/search-input.cjs +136 -0
- package/dist/plugins/blog/client/components/shared/search-input.mjs +117 -0
- package/dist/plugins/blog/client/components/shared/search-modal.cjs +135 -0
- package/dist/plugins/blog/client/components/shared/search-modal.mjs +116 -0
- package/dist/plugins/blog/client/components/shared/tags-list.cjs +22 -0
- package/dist/plugins/blog/client/components/shared/tags-list.mjs +20 -0
- package/dist/plugins/blog/client/components/shared/use-route-lifecycle.cjs +50 -0
- package/dist/plugins/blog/client/components/shared/use-route-lifecycle.mjs +48 -0
- package/dist/plugins/blog/client/hooks/blog-hooks.cjs +380 -0
- package/dist/plugins/blog/client/hooks/blog-hooks.mjs +368 -0
- package/dist/plugins/blog/client/hooks/index.cjs +17 -0
- package/dist/plugins/blog/client/hooks/index.d.cts +150 -0
- package/dist/plugins/blog/client/hooks/index.d.mts +150 -0
- package/dist/plugins/blog/client/hooks/index.d.ts +150 -0
- package/dist/plugins/blog/client/hooks/index.mjs +1 -0
- package/dist/plugins/blog/client/hooks/use-debounce.cjs +16 -0
- package/dist/plugins/blog/client/hooks/use-debounce.mjs +14 -0
- package/dist/plugins/blog/client/index.cjs +7 -0
- package/dist/plugins/blog/client/index.d.cts +414 -0
- package/dist/plugins/blog/client/index.d.mts +414 -0
- package/dist/plugins/blog/client/index.d.ts +414 -0
- package/dist/plugins/blog/client/index.mjs +1 -0
- package/dist/plugins/blog/client/localization/blog-card.cjs +7 -0
- package/dist/plugins/blog/client/localization/blog-card.mjs +5 -0
- package/dist/plugins/blog/client/localization/blog-common.cjs +10 -0
- package/dist/plugins/blog/client/localization/blog-common.mjs +8 -0
- package/dist/plugins/blog/client/localization/blog-forms.cjs +40 -0
- package/dist/plugins/blog/client/localization/blog-forms.mjs +38 -0
- package/dist/plugins/blog/client/localization/blog-list.cjs +18 -0
- package/dist/plugins/blog/client/localization/blog-list.mjs +16 -0
- package/dist/plugins/blog/client/localization/blog-post.cjs +13 -0
- package/dist/plugins/blog/client/localization/blog-post.mjs +11 -0
- package/dist/plugins/blog/client/localization/index.cjs +17 -0
- package/dist/plugins/blog/client/localization/index.mjs +15 -0
- package/dist/plugins/blog/client/plugin.cjs +462 -0
- package/dist/plugins/blog/client/plugin.mjs +460 -0
- package/dist/plugins/blog/client.css +3 -0
- package/dist/plugins/blog/db.cjs +90 -0
- package/dist/plugins/blog/db.mjs +88 -0
- package/dist/plugins/blog/query-keys.cjs +181 -0
- package/dist/plugins/blog/query-keys.d.cts +530 -0
- package/dist/plugins/blog/query-keys.d.mts +530 -0
- package/dist/plugins/blog/query-keys.d.ts +530 -0
- package/dist/plugins/blog/query-keys.mjs +179 -0
- package/dist/plugins/blog/schemas.cjs +39 -0
- package/dist/plugins/blog/schemas.mjs +35 -0
- package/dist/plugins/blog/style.css +22 -0
- package/dist/plugins/blog/utils.cjs +97 -0
- package/dist/plugins/blog/utils.mjs +87 -0
- package/dist/plugins/client/index.cjs +15 -0
- package/dist/plugins/client/index.d.cts +57 -0
- package/dist/plugins/client/index.d.mts +57 -0
- package/dist/plugins/client/index.d.ts +57 -0
- package/dist/plugins/client/index.mjs +9 -0
- package/dist/{shared/stack.Br2KMECJ.cjs → plugins/utils.cjs} +1 -8
- package/dist/{shared/stack.CwGEQ10b.mjs → plugins/utils.mjs} +2 -8
- package/dist/shared/{stack.Dva9muUy.d.cts → stack.ByOugz9d.d.cts} +17 -23
- package/dist/shared/{stack.Dva9muUy.d.mts → stack.ByOugz9d.d.mts} +17 -23
- package/dist/shared/{stack.Dva9muUy.d.ts → stack.ByOugz9d.d.ts} +17 -23
- package/dist/shared/stack.Cr2JoQdo.d.cts +76 -0
- package/dist/shared/stack.Cr2JoQdo.d.mts +76 -0
- package/dist/shared/stack.Cr2JoQdo.d.ts +76 -0
- package/package.json +104 -16
- package/src/__tests__/plugins.test.tsx +539 -0
- package/src/__tests__/sitemap.test.ts +60 -0
- package/src/api/index.ts +73 -0
- package/src/client/components/compose.tsx +116 -0
- package/src/client/components/error-boundary.tsx +30 -0
- package/src/client/components/index.tsx +2 -0
- package/src/client/index.ts +107 -0
- package/src/client/meta-utils.ts +228 -0
- package/src/client/sitemap-utils.ts +46 -0
- package/src/context/index.ts +1 -0
- package/src/context/provider.tsx +157 -0
- package/src/index.ts +1 -0
- package/src/plugins/api/index.ts +51 -0
- package/src/plugins/blog/api/index.ts +2 -0
- package/src/plugins/blog/api/plugin.ts +759 -0
- package/src/plugins/blog/client/components/forms/image-field.tsx +165 -0
- package/src/plugins/blog/client/components/forms/markdown-editor-styles.css +30 -0
- package/src/plugins/blog/client/components/forms/markdown-editor.tsx +136 -0
- package/src/plugins/blog/client/components/forms/post-forms.tsx +531 -0
- package/src/plugins/blog/client/components/forms/tags-multiselect.tsx +79 -0
- package/src/plugins/blog/client/components/index.tsx +11 -0
- package/src/plugins/blog/client/components/loading/form-page-skeleton.tsx +75 -0
- package/src/plugins/blog/client/components/loading/index.tsx +27 -0
- package/src/plugins/blog/client/components/loading/list-page-skeleton.tsx +38 -0
- package/src/plugins/blog/client/components/loading/page-header-skeleton.tsx +10 -0
- package/src/plugins/blog/client/components/loading/post-card-skeleton.tsx +30 -0
- package/src/plugins/blog/client/components/loading/post-page-skeleton.tsx +75 -0
- package/src/plugins/blog/client/components/pages/404-page.tsx +23 -0
- package/src/plugins/blog/client/components/pages/edit-post-page.internal.tsx +60 -0
- package/src/plugins/blog/client/components/pages/edit-post-page.tsx +40 -0
- package/src/plugins/blog/client/components/pages/home-page.internal.tsx +71 -0
- package/src/plugins/blog/client/components/pages/home-page.tsx +42 -0
- package/src/plugins/blog/client/components/pages/new-post-page.internal.tsx +59 -0
- package/src/plugins/blog/client/components/pages/new-post-page.tsx +36 -0
- package/src/plugins/blog/client/components/pages/post-page.internal.tsx +142 -0
- package/src/plugins/blog/client/components/pages/post-page.tsx +38 -0
- package/src/plugins/blog/client/components/pages/tag-page.internal.tsx +74 -0
- package/src/plugins/blog/client/components/pages/tag-page.tsx +38 -0
- package/src/plugins/blog/client/components/shared/better-blog-attribution.tsx +19 -0
- package/src/plugins/blog/client/components/shared/default-error.tsx +20 -0
- package/src/plugins/blog/client/components/shared/defaults.tsx +9 -0
- package/src/plugins/blog/client/components/shared/empty-list.tsx +25 -0
- package/src/plugins/blog/client/components/shared/error-placeholder.tsx +20 -0
- package/src/plugins/blog/client/components/shared/highlight-text.tsx +80 -0
- package/src/plugins/blog/client/components/shared/markdown-content-styles.css +328 -0
- package/src/plugins/blog/client/components/shared/markdown-content.tsx +448 -0
- package/src/plugins/blog/client/components/shared/on-this-page.tsx +234 -0
- package/src/plugins/blog/client/components/shared/page-header.tsx +35 -0
- package/src/plugins/blog/client/components/shared/page-layout.tsx +23 -0
- package/src/plugins/blog/client/components/shared/page-wrapper.tsx +32 -0
- package/src/plugins/blog/client/components/shared/post-card.tsx +308 -0
- package/src/plugins/blog/client/components/shared/post-navigation.tsx +98 -0
- package/src/plugins/blog/client/components/shared/posts-list.tsx +67 -0
- package/src/plugins/blog/client/components/shared/recent-posts-carousel.tsx +79 -0
- package/src/plugins/blog/client/components/shared/search-input.tsx +146 -0
- package/src/plugins/blog/client/components/shared/search-modal.tsx +162 -0
- package/src/plugins/blog/client/components/shared/tags-list.tsx +34 -0
- package/src/plugins/blog/client/components/shared/use-route-lifecycle.tsx +68 -0
- package/src/plugins/blog/client/hooks/blog-hooks.tsx +623 -0
- package/src/plugins/blog/client/hooks/index.tsx +1 -0
- package/src/plugins/blog/client/hooks/use-debounce.ts +43 -0
- package/src/plugins/blog/client/index.ts +9 -0
- package/src/plugins/blog/client/localization/blog-card.ts +3 -0
- package/src/plugins/blog/client/localization/blog-common.ts +7 -0
- package/src/plugins/blog/client/localization/blog-forms.ts +45 -0
- package/src/plugins/blog/client/localization/blog-list.ts +14 -0
- package/src/plugins/blog/client/localization/blog-post.ts +9 -0
- package/src/plugins/blog/client/localization/index.ts +15 -0
- package/src/plugins/blog/client/overrides.ts +123 -0
- package/src/plugins/blog/client/plugin.tsx +672 -0
- package/src/plugins/blog/client.css +3 -0
- package/src/plugins/blog/db.ts +90 -0
- package/src/plugins/blog/query-keys.ts +267 -0
- package/src/plugins/blog/schemas.ts +39 -0
- package/src/plugins/blog/style.css +22 -0
- package/src/plugins/blog/types.ts +37 -0
- package/src/plugins/blog/utils.ts +144 -0
- package/src/plugins/client/index.ts +53 -0
- package/src/plugins/index.ts +0 -0
- package/src/plugins/utils.ts +35 -0
- package/src/types.ts +209 -0
- package/dist/plugins/index.cjs +0 -16
- package/dist/plugins/index.d.cts +0 -64
- package/dist/plugins/index.d.mts +0 -64
- package/dist/plugins/index.d.ts +0 -64
- package/dist/plugins/index.mjs +0 -11
- package/dist/shared/stack.DvFqFlOV.d.cts +0 -22
- package/dist/shared/stack.DvFqFlOV.d.mts +0 -22
- package/dist/shared/stack.DvFqFlOV.d.ts +0 -22
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
function metaElementsToObject(metaElements) {
|
|
2
|
+
const metadata = { title: "" };
|
|
3
|
+
const nameHandlers = {
|
|
4
|
+
title: (c) => {
|
|
5
|
+
metadata.title = c;
|
|
6
|
+
},
|
|
7
|
+
description: (c) => {
|
|
8
|
+
metadata.description = c;
|
|
9
|
+
},
|
|
10
|
+
keywords: (c) => {
|
|
11
|
+
const parts = c.split(",").map((k) => k.trim()).filter(Boolean);
|
|
12
|
+
metadata.keywords = parts.length > 0 ? parts : void 0;
|
|
13
|
+
},
|
|
14
|
+
"application-name": (c) => {
|
|
15
|
+
metadata.applicationName = c;
|
|
16
|
+
},
|
|
17
|
+
generator: (c) => {
|
|
18
|
+
metadata.generator = c;
|
|
19
|
+
},
|
|
20
|
+
referrer: (c) => {
|
|
21
|
+
const allowedReferrers = /* @__PURE__ */ new Set([
|
|
22
|
+
"no-referrer",
|
|
23
|
+
"origin",
|
|
24
|
+
"no-referrer-when-downgrade",
|
|
25
|
+
"origin-when-cross-origin",
|
|
26
|
+
"same-origin",
|
|
27
|
+
"strict-origin",
|
|
28
|
+
"strict-origin-when-cross-origin",
|
|
29
|
+
"unsafe-url"
|
|
30
|
+
]);
|
|
31
|
+
if (allowedReferrers.has(c)) {
|
|
32
|
+
metadata.referrer = c;
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"theme-color": (c) => {
|
|
36
|
+
metadata.themeColor = c;
|
|
37
|
+
},
|
|
38
|
+
viewport: (c) => {
|
|
39
|
+
metadata.viewport = c;
|
|
40
|
+
},
|
|
41
|
+
creator: (c) => {
|
|
42
|
+
metadata.creator = c;
|
|
43
|
+
},
|
|
44
|
+
publisher: (c) => {
|
|
45
|
+
metadata.publisher = c;
|
|
46
|
+
},
|
|
47
|
+
author: (c) => {
|
|
48
|
+
metadata.authors = [{ name: c }];
|
|
49
|
+
},
|
|
50
|
+
abstract: (c) => {
|
|
51
|
+
metadata.abstract = c;
|
|
52
|
+
},
|
|
53
|
+
robots: (c) => {
|
|
54
|
+
metadata.robots = c;
|
|
55
|
+
},
|
|
56
|
+
// Twitter
|
|
57
|
+
"twitter:title": (c) => {
|
|
58
|
+
if (!metadata.twitter) metadata.twitter = {};
|
|
59
|
+
metadata.twitter.title = c;
|
|
60
|
+
},
|
|
61
|
+
"twitter:description": (c) => {
|
|
62
|
+
if (!metadata.twitter) metadata.twitter = {};
|
|
63
|
+
metadata.twitter.description = c;
|
|
64
|
+
},
|
|
65
|
+
"twitter:site": (c) => {
|
|
66
|
+
if (!metadata.twitter) metadata.twitter = {};
|
|
67
|
+
metadata.twitter.site = c;
|
|
68
|
+
},
|
|
69
|
+
"twitter:creator": (c) => {
|
|
70
|
+
if (!metadata.twitter) metadata.twitter = {};
|
|
71
|
+
metadata.twitter.creator = c;
|
|
72
|
+
},
|
|
73
|
+
"twitter:image": (c) => {
|
|
74
|
+
if (!metadata.twitter) metadata.twitter = {};
|
|
75
|
+
const currentImages = metadata.twitter.images;
|
|
76
|
+
if (!currentImages) {
|
|
77
|
+
metadata.twitter.images = [c];
|
|
78
|
+
} else if (Array.isArray(currentImages)) {
|
|
79
|
+
metadata.twitter.images = [...currentImages, c];
|
|
80
|
+
} else {
|
|
81
|
+
metadata.twitter.images = [currentImages, c];
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
const propertyHandlers = {
|
|
86
|
+
"og:title": (c) => {
|
|
87
|
+
if (!metadata.openGraph) metadata.openGraph = {};
|
|
88
|
+
metadata.openGraph.title = c;
|
|
89
|
+
},
|
|
90
|
+
"og:description": (c) => {
|
|
91
|
+
if (!metadata.openGraph) metadata.openGraph = {};
|
|
92
|
+
metadata.openGraph.description = c;
|
|
93
|
+
},
|
|
94
|
+
"og:url": (c) => {
|
|
95
|
+
if (!metadata.openGraph) metadata.openGraph = {};
|
|
96
|
+
metadata.openGraph.url = c;
|
|
97
|
+
metadata.alternates = {
|
|
98
|
+
...metadata.alternates ?? {},
|
|
99
|
+
canonical: c
|
|
100
|
+
};
|
|
101
|
+
},
|
|
102
|
+
"og:site_name": (c) => {
|
|
103
|
+
if (!metadata.openGraph) metadata.openGraph = {};
|
|
104
|
+
metadata.openGraph.siteName = c;
|
|
105
|
+
},
|
|
106
|
+
"og:locale": (c) => {
|
|
107
|
+
if (!metadata.openGraph) metadata.openGraph = {};
|
|
108
|
+
metadata.openGraph.locale = c;
|
|
109
|
+
},
|
|
110
|
+
"og:image": (c) => {
|
|
111
|
+
if (!metadata.openGraph) metadata.openGraph = {};
|
|
112
|
+
const currentImages = metadata.openGraph.images;
|
|
113
|
+
if (!currentImages) {
|
|
114
|
+
metadata.openGraph.images = [c];
|
|
115
|
+
} else if (Array.isArray(currentImages)) {
|
|
116
|
+
metadata.openGraph.images = [...currentImages, c];
|
|
117
|
+
} else {
|
|
118
|
+
metadata.openGraph.images = [currentImages, c];
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
"og:video": (c) => {
|
|
122
|
+
if (!metadata.openGraph) metadata.openGraph = {};
|
|
123
|
+
const currentVideos = metadata.openGraph.videos;
|
|
124
|
+
if (!currentVideos) {
|
|
125
|
+
metadata.openGraph.videos = [c];
|
|
126
|
+
} else if (Array.isArray(currentVideos)) {
|
|
127
|
+
metadata.openGraph.videos = [...currentVideos, c];
|
|
128
|
+
} else {
|
|
129
|
+
metadata.openGraph.videos = [currentVideos, c];
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
"og:audio": (c) => {
|
|
133
|
+
if (!metadata.openGraph) metadata.openGraph = {};
|
|
134
|
+
const currentAudio = metadata.openGraph.audio;
|
|
135
|
+
if (!currentAudio) {
|
|
136
|
+
metadata.openGraph.audio = [c];
|
|
137
|
+
} else if (Array.isArray(currentAudio)) {
|
|
138
|
+
metadata.openGraph.audio = [...currentAudio, c];
|
|
139
|
+
} else {
|
|
140
|
+
metadata.openGraph.audio = [currentAudio, c];
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
for (const meta of metaElements) {
|
|
145
|
+
if (!meta) continue;
|
|
146
|
+
if ("name" in meta && "content" in meta) {
|
|
147
|
+
const handler = nameHandlers[String(meta.name)];
|
|
148
|
+
if (handler) handler(String(meta.content));
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
if ("property" in meta && "content" in meta) {
|
|
152
|
+
const handler = propertyHandlers[String(meta.property)];
|
|
153
|
+
if (handler) handler(String(meta.content));
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return metadata;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export { metaElementsToObject };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function sitemapEntryToXmlString(entries) {
|
|
4
|
+
const xml = `<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">` + entries.map((entry) => {
|
|
5
|
+
const url = `<loc>${entry.url}</loc>`;
|
|
6
|
+
const lastModified = entry.lastModified ? `<lastmod>${entry.lastModified instanceof Date ? entry.lastModified.toISOString() : entry.lastModified}</lastmod>` : "";
|
|
7
|
+
const changeFrequency = entry.changeFrequency ? `<changefreq>${entry.changeFrequency}</changefreq>` : "";
|
|
8
|
+
const priority = entry.priority !== void 0 ? `<priority>${entry.priority}</priority>` : "";
|
|
9
|
+
return `<url>${url}${lastModified}${changeFrequency}${priority}</url>`;
|
|
10
|
+
}).join("") + `</urlset>`;
|
|
11
|
+
return xml;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
exports.sitemapEntryToXmlString = sitemapEntryToXmlString;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
function sitemapEntryToXmlString(entries) {
|
|
2
|
+
const xml = `<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">` + entries.map((entry) => {
|
|
3
|
+
const url = `<loc>${entry.url}</loc>`;
|
|
4
|
+
const lastModified = entry.lastModified ? `<lastmod>${entry.lastModified instanceof Date ? entry.lastModified.toISOString() : entry.lastModified}</lastmod>` : "";
|
|
5
|
+
const changeFrequency = entry.changeFrequency ? `<changefreq>${entry.changeFrequency}</changefreq>` : "";
|
|
6
|
+
const priority = entry.priority !== void 0 ? `<priority>${entry.priority}</priority>` : "";
|
|
7
|
+
return `<url>${url}${lastModified}${changeFrequency}${priority}</url>`;
|
|
8
|
+
}).join("") + `</urlset>`;
|
|
9
|
+
return xml;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { sitemapEntryToXmlString };
|
package/dist/context/index.cjs
CHANGED
|
@@ -1,55 +1,10 @@
|
|
|
1
|
-
"use client";
|
|
2
1
|
'use strict';
|
|
3
2
|
|
|
4
|
-
const
|
|
5
|
-
const react = require('react');
|
|
3
|
+
const provider = require('./provider.cjs');
|
|
6
4
|
|
|
7
|
-
const BetterStackContext = react.createContext(
|
|
8
|
-
null
|
|
9
|
-
);
|
|
10
|
-
function BetterStackProvider({
|
|
11
|
-
children,
|
|
12
|
-
overrides
|
|
13
|
-
}) {
|
|
14
|
-
const value = {
|
|
15
|
-
overrides
|
|
16
|
-
};
|
|
17
|
-
return /* @__PURE__ */ jsxRuntime.jsx(BetterStackContext.Provider, { value, children });
|
|
18
|
-
}
|
|
19
|
-
function useBetterStack() {
|
|
20
|
-
const context = react.useContext(
|
|
21
|
-
BetterStackContext
|
|
22
|
-
);
|
|
23
|
-
if (!context) {
|
|
24
|
-
throw new Error(
|
|
25
|
-
"useBetterStack must be used within BetterStackProvider. Wrap your app with <BetterStackProvider> in your layout file."
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
return context;
|
|
29
|
-
}
|
|
30
|
-
function usePluginOverrides(pluginName) {
|
|
31
|
-
const context = useBetterStack();
|
|
32
|
-
const overrides = context.overrides[pluginName];
|
|
33
|
-
if (!overrides) {
|
|
34
|
-
throw new Error(
|
|
35
|
-
`Plugin "${pluginName}" not found in BetterStackProvider. Available plugins: ${Object.keys(context.overrides).join(", ")}`
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
return overrides;
|
|
39
|
-
}
|
|
40
|
-
function usePluginOverride(pluginName, overrideKey) {
|
|
41
|
-
const overrides = usePluginOverrides(pluginName);
|
|
42
|
-
const override = overrides[overrideKey];
|
|
43
|
-
if (override === void 0) {
|
|
44
|
-
const availableKeys = overrides && typeof overrides === "object" ? Object.keys(overrides).join(", ") : "none";
|
|
45
|
-
throw new Error(
|
|
46
|
-
`Override "${overrideKey}" not found for plugin "${pluginName}". Available overrides: ${availableKeys}`
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
return override;
|
|
50
|
-
}
|
|
51
5
|
|
|
52
|
-
|
|
53
|
-
exports.
|
|
54
|
-
exports.
|
|
55
|
-
exports.
|
|
6
|
+
|
|
7
|
+
exports.BetterStackProvider = provider.BetterStackProvider;
|
|
8
|
+
exports.useBasePath = provider.useBasePath;
|
|
9
|
+
exports.useBetterStack = provider.useBetterStack;
|
|
10
|
+
exports.usePluginOverrides = provider.usePluginOverrides;
|
package/dist/context/index.d.cts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use client";
|
|
2
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
2
|
import { ReactNode } from 'react';
|
|
4
3
|
|
|
@@ -7,7 +6,14 @@ import { ReactNode } from 'react';
|
|
|
7
6
|
* Generic over the shape of all plugin overrides
|
|
8
7
|
*/
|
|
9
8
|
interface BetterStackContextValue<TPluginOverrides extends Record<string, any>> {
|
|
9
|
+
/**
|
|
10
|
+
* The overrides for the plugin.
|
|
11
|
+
*/
|
|
10
12
|
overrides: TPluginOverrides;
|
|
13
|
+
/**
|
|
14
|
+
* The base path where the client router is mounted.
|
|
15
|
+
*/
|
|
16
|
+
basePath: string;
|
|
11
17
|
}
|
|
12
18
|
/**
|
|
13
19
|
* Provider component for BetterStack context
|
|
@@ -38,49 +44,43 @@ interface BetterStackContextValue<TPluginOverrides extends Record<string, any>>
|
|
|
38
44
|
* </BetterStackProvider>
|
|
39
45
|
* ```
|
|
40
46
|
*/
|
|
41
|
-
declare function BetterStackProvider<TPluginOverrides extends Record<string, any> = Record<string, any>>({ children, overrides, }: {
|
|
42
|
-
children
|
|
47
|
+
declare function BetterStackProvider<TPluginOverrides extends Record<string, any> = Record<string, any>>({ children, overrides, basePath, }: {
|
|
48
|
+
children?: ReactNode;
|
|
43
49
|
overrides: TPluginOverrides;
|
|
50
|
+
basePath: string;
|
|
44
51
|
}): react_jsx_runtime.JSX.Element;
|
|
45
52
|
/**
|
|
46
53
|
* Hook to access the entire context
|
|
47
54
|
* Useful if you need access to multiple plugins or the full context
|
|
48
55
|
*/
|
|
49
56
|
declare function useBetterStack<TPluginOverrides extends Record<string, any> = Record<string, any>>(): BetterStackContextValue<TPluginOverrides>;
|
|
57
|
+
type OverridesResult<TOverrides, TDefaults> = undefined extends TDefaults ? TOverrides : TOverrides & Required<Pick<TDefaults & {}, keyof TDefaults>>;
|
|
50
58
|
/**
|
|
51
59
|
* Hook to access overrides for a specific plugin
|
|
52
60
|
* This is type-safe and will only expose the overrides defined by that plugin
|
|
53
61
|
*
|
|
62
|
+
* When default values are provided, properties with defaults are guaranteed to be non-null.
|
|
63
|
+
*
|
|
54
64
|
* @example
|
|
55
65
|
* ```tsx
|
|
56
|
-
* //
|
|
66
|
+
* // Without defaults - trusts plugin is configured
|
|
57
67
|
* function TodosList() {
|
|
58
|
-
* const {
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
* <Link href="/todos/add">
|
|
62
|
-
* <button onClick={() => navigate("/todos")}>
|
|
63
|
-
* Add Todo
|
|
64
|
-
* </button>
|
|
65
|
-
* </Link>
|
|
66
|
-
* );
|
|
68
|
+
* const { navigate } = usePluginOverrides<TodosPluginOverrides>("todos");
|
|
69
|
+
* // navigate is (path: string) => void (required fields are non-nullable)
|
|
70
|
+
* navigate("/todos/add");
|
|
67
71
|
* }
|
|
68
|
-
* ```
|
|
69
|
-
*/
|
|
70
|
-
declare function usePluginOverrides<TOverrides = any>(pluginName: string): TOverrides;
|
|
71
|
-
/**
|
|
72
|
-
* Hook to access a specific override from a plugin
|
|
73
|
-
* Provides fine-grained access with full type safety
|
|
74
72
|
*
|
|
75
|
-
*
|
|
76
|
-
* ```tsx
|
|
73
|
+
* // With defaults - optional fields with defaults become required
|
|
77
74
|
* function TodosList() {
|
|
78
|
-
* const
|
|
79
|
-
*
|
|
80
|
-
*
|
|
75
|
+
* const { localization } = usePluginOverrides<TodosPluginOverrides, Partial<TodosPluginOverrides>>("todos", {
|
|
76
|
+
* localization: DEFAULT_LOCALIZATION
|
|
77
|
+
* });
|
|
78
|
+
* // localization is Localization (guaranteed to exist because we provided a default)
|
|
79
|
+
* console.log(localization.SOME_KEY);
|
|
81
80
|
* }
|
|
82
81
|
* ```
|
|
83
82
|
*/
|
|
84
|
-
declare function
|
|
83
|
+
declare function usePluginOverrides<TOverrides = any, TDefaults extends Partial<TOverrides> | undefined = undefined>(pluginName: string, defaultValues?: TDefaults): OverridesResult<TOverrides, TDefaults>;
|
|
84
|
+
declare function useBasePath(): string;
|
|
85
85
|
|
|
86
|
-
export { BetterStackProvider,
|
|
86
|
+
export { BetterStackProvider, useBasePath, useBetterStack, usePluginOverrides };
|
package/dist/context/index.d.mts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use client";
|
|
2
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
2
|
import { ReactNode } from 'react';
|
|
4
3
|
|
|
@@ -7,7 +6,14 @@ import { ReactNode } from 'react';
|
|
|
7
6
|
* Generic over the shape of all plugin overrides
|
|
8
7
|
*/
|
|
9
8
|
interface BetterStackContextValue<TPluginOverrides extends Record<string, any>> {
|
|
9
|
+
/**
|
|
10
|
+
* The overrides for the plugin.
|
|
11
|
+
*/
|
|
10
12
|
overrides: TPluginOverrides;
|
|
13
|
+
/**
|
|
14
|
+
* The base path where the client router is mounted.
|
|
15
|
+
*/
|
|
16
|
+
basePath: string;
|
|
11
17
|
}
|
|
12
18
|
/**
|
|
13
19
|
* Provider component for BetterStack context
|
|
@@ -38,49 +44,43 @@ interface BetterStackContextValue<TPluginOverrides extends Record<string, any>>
|
|
|
38
44
|
* </BetterStackProvider>
|
|
39
45
|
* ```
|
|
40
46
|
*/
|
|
41
|
-
declare function BetterStackProvider<TPluginOverrides extends Record<string, any> = Record<string, any>>({ children, overrides, }: {
|
|
42
|
-
children
|
|
47
|
+
declare function BetterStackProvider<TPluginOverrides extends Record<string, any> = Record<string, any>>({ children, overrides, basePath, }: {
|
|
48
|
+
children?: ReactNode;
|
|
43
49
|
overrides: TPluginOverrides;
|
|
50
|
+
basePath: string;
|
|
44
51
|
}): react_jsx_runtime.JSX.Element;
|
|
45
52
|
/**
|
|
46
53
|
* Hook to access the entire context
|
|
47
54
|
* Useful if you need access to multiple plugins or the full context
|
|
48
55
|
*/
|
|
49
56
|
declare function useBetterStack<TPluginOverrides extends Record<string, any> = Record<string, any>>(): BetterStackContextValue<TPluginOverrides>;
|
|
57
|
+
type OverridesResult<TOverrides, TDefaults> = undefined extends TDefaults ? TOverrides : TOverrides & Required<Pick<TDefaults & {}, keyof TDefaults>>;
|
|
50
58
|
/**
|
|
51
59
|
* Hook to access overrides for a specific plugin
|
|
52
60
|
* This is type-safe and will only expose the overrides defined by that plugin
|
|
53
61
|
*
|
|
62
|
+
* When default values are provided, properties with defaults are guaranteed to be non-null.
|
|
63
|
+
*
|
|
54
64
|
* @example
|
|
55
65
|
* ```tsx
|
|
56
|
-
* //
|
|
66
|
+
* // Without defaults - trusts plugin is configured
|
|
57
67
|
* function TodosList() {
|
|
58
|
-
* const {
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
* <Link href="/todos/add">
|
|
62
|
-
* <button onClick={() => navigate("/todos")}>
|
|
63
|
-
* Add Todo
|
|
64
|
-
* </button>
|
|
65
|
-
* </Link>
|
|
66
|
-
* );
|
|
68
|
+
* const { navigate } = usePluginOverrides<TodosPluginOverrides>("todos");
|
|
69
|
+
* // navigate is (path: string) => void (required fields are non-nullable)
|
|
70
|
+
* navigate("/todos/add");
|
|
67
71
|
* }
|
|
68
|
-
* ```
|
|
69
|
-
*/
|
|
70
|
-
declare function usePluginOverrides<TOverrides = any>(pluginName: string): TOverrides;
|
|
71
|
-
/**
|
|
72
|
-
* Hook to access a specific override from a plugin
|
|
73
|
-
* Provides fine-grained access with full type safety
|
|
74
72
|
*
|
|
75
|
-
*
|
|
76
|
-
* ```tsx
|
|
73
|
+
* // With defaults - optional fields with defaults become required
|
|
77
74
|
* function TodosList() {
|
|
78
|
-
* const
|
|
79
|
-
*
|
|
80
|
-
*
|
|
75
|
+
* const { localization } = usePluginOverrides<TodosPluginOverrides, Partial<TodosPluginOverrides>>("todos", {
|
|
76
|
+
* localization: DEFAULT_LOCALIZATION
|
|
77
|
+
* });
|
|
78
|
+
* // localization is Localization (guaranteed to exist because we provided a default)
|
|
79
|
+
* console.log(localization.SOME_KEY);
|
|
81
80
|
* }
|
|
82
81
|
* ```
|
|
83
82
|
*/
|
|
84
|
-
declare function
|
|
83
|
+
declare function usePluginOverrides<TOverrides = any, TDefaults extends Partial<TOverrides> | undefined = undefined>(pluginName: string, defaultValues?: TDefaults): OverridesResult<TOverrides, TDefaults>;
|
|
84
|
+
declare function useBasePath(): string;
|
|
85
85
|
|
|
86
|
-
export { BetterStackProvider,
|
|
86
|
+
export { BetterStackProvider, useBasePath, useBetterStack, usePluginOverrides };
|
package/dist/context/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use client";
|
|
2
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
2
|
import { ReactNode } from 'react';
|
|
4
3
|
|
|
@@ -7,7 +6,14 @@ import { ReactNode } from 'react';
|
|
|
7
6
|
* Generic over the shape of all plugin overrides
|
|
8
7
|
*/
|
|
9
8
|
interface BetterStackContextValue<TPluginOverrides extends Record<string, any>> {
|
|
9
|
+
/**
|
|
10
|
+
* The overrides for the plugin.
|
|
11
|
+
*/
|
|
10
12
|
overrides: TPluginOverrides;
|
|
13
|
+
/**
|
|
14
|
+
* The base path where the client router is mounted.
|
|
15
|
+
*/
|
|
16
|
+
basePath: string;
|
|
11
17
|
}
|
|
12
18
|
/**
|
|
13
19
|
* Provider component for BetterStack context
|
|
@@ -38,49 +44,43 @@ interface BetterStackContextValue<TPluginOverrides extends Record<string, any>>
|
|
|
38
44
|
* </BetterStackProvider>
|
|
39
45
|
* ```
|
|
40
46
|
*/
|
|
41
|
-
declare function BetterStackProvider<TPluginOverrides extends Record<string, any> = Record<string, any>>({ children, overrides, }: {
|
|
42
|
-
children
|
|
47
|
+
declare function BetterStackProvider<TPluginOverrides extends Record<string, any> = Record<string, any>>({ children, overrides, basePath, }: {
|
|
48
|
+
children?: ReactNode;
|
|
43
49
|
overrides: TPluginOverrides;
|
|
50
|
+
basePath: string;
|
|
44
51
|
}): react_jsx_runtime.JSX.Element;
|
|
45
52
|
/**
|
|
46
53
|
* Hook to access the entire context
|
|
47
54
|
* Useful if you need access to multiple plugins or the full context
|
|
48
55
|
*/
|
|
49
56
|
declare function useBetterStack<TPluginOverrides extends Record<string, any> = Record<string, any>>(): BetterStackContextValue<TPluginOverrides>;
|
|
57
|
+
type OverridesResult<TOverrides, TDefaults> = undefined extends TDefaults ? TOverrides : TOverrides & Required<Pick<TDefaults & {}, keyof TDefaults>>;
|
|
50
58
|
/**
|
|
51
59
|
* Hook to access overrides for a specific plugin
|
|
52
60
|
* This is type-safe and will only expose the overrides defined by that plugin
|
|
53
61
|
*
|
|
62
|
+
* When default values are provided, properties with defaults are guaranteed to be non-null.
|
|
63
|
+
*
|
|
54
64
|
* @example
|
|
55
65
|
* ```tsx
|
|
56
|
-
* //
|
|
66
|
+
* // Without defaults - trusts plugin is configured
|
|
57
67
|
* function TodosList() {
|
|
58
|
-
* const {
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
* <Link href="/todos/add">
|
|
62
|
-
* <button onClick={() => navigate("/todos")}>
|
|
63
|
-
* Add Todo
|
|
64
|
-
* </button>
|
|
65
|
-
* </Link>
|
|
66
|
-
* );
|
|
68
|
+
* const { navigate } = usePluginOverrides<TodosPluginOverrides>("todos");
|
|
69
|
+
* // navigate is (path: string) => void (required fields are non-nullable)
|
|
70
|
+
* navigate("/todos/add");
|
|
67
71
|
* }
|
|
68
|
-
* ```
|
|
69
|
-
*/
|
|
70
|
-
declare function usePluginOverrides<TOverrides = any>(pluginName: string): TOverrides;
|
|
71
|
-
/**
|
|
72
|
-
* Hook to access a specific override from a plugin
|
|
73
|
-
* Provides fine-grained access with full type safety
|
|
74
72
|
*
|
|
75
|
-
*
|
|
76
|
-
* ```tsx
|
|
73
|
+
* // With defaults - optional fields with defaults become required
|
|
77
74
|
* function TodosList() {
|
|
78
|
-
* const
|
|
79
|
-
*
|
|
80
|
-
*
|
|
75
|
+
* const { localization } = usePluginOverrides<TodosPluginOverrides, Partial<TodosPluginOverrides>>("todos", {
|
|
76
|
+
* localization: DEFAULT_LOCALIZATION
|
|
77
|
+
* });
|
|
78
|
+
* // localization is Localization (guaranteed to exist because we provided a default)
|
|
79
|
+
* console.log(localization.SOME_KEY);
|
|
81
80
|
* }
|
|
82
81
|
* ```
|
|
83
82
|
*/
|
|
84
|
-
declare function
|
|
83
|
+
declare function usePluginOverrides<TOverrides = any, TDefaults extends Partial<TOverrides> | undefined = undefined>(pluginName: string, defaultValues?: TDefaults): OverridesResult<TOverrides, TDefaults>;
|
|
84
|
+
declare function useBasePath(): string;
|
|
85
85
|
|
|
86
|
-
export { BetterStackProvider,
|
|
86
|
+
export { BetterStackProvider, useBasePath, useBetterStack, usePluginOverrides };
|
package/dist/context/index.mjs
CHANGED
|
@@ -1,50 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { jsx } from 'react/jsx-runtime';
|
|
3
|
-
import { createContext, useContext } from 'react';
|
|
4
|
-
|
|
5
|
-
const BetterStackContext = createContext(
|
|
6
|
-
null
|
|
7
|
-
);
|
|
8
|
-
function BetterStackProvider({
|
|
9
|
-
children,
|
|
10
|
-
overrides
|
|
11
|
-
}) {
|
|
12
|
-
const value = {
|
|
13
|
-
overrides
|
|
14
|
-
};
|
|
15
|
-
return /* @__PURE__ */ jsx(BetterStackContext.Provider, { value, children });
|
|
16
|
-
}
|
|
17
|
-
function useBetterStack() {
|
|
18
|
-
const context = useContext(
|
|
19
|
-
BetterStackContext
|
|
20
|
-
);
|
|
21
|
-
if (!context) {
|
|
22
|
-
throw new Error(
|
|
23
|
-
"useBetterStack must be used within BetterStackProvider. Wrap your app with <BetterStackProvider> in your layout file."
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
return context;
|
|
27
|
-
}
|
|
28
|
-
function usePluginOverrides(pluginName) {
|
|
29
|
-
const context = useBetterStack();
|
|
30
|
-
const overrides = context.overrides[pluginName];
|
|
31
|
-
if (!overrides) {
|
|
32
|
-
throw new Error(
|
|
33
|
-
`Plugin "${pluginName}" not found in BetterStackProvider. Available plugins: ${Object.keys(context.overrides).join(", ")}`
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
return overrides;
|
|
37
|
-
}
|
|
38
|
-
function usePluginOverride(pluginName, overrideKey) {
|
|
39
|
-
const overrides = usePluginOverrides(pluginName);
|
|
40
|
-
const override = overrides[overrideKey];
|
|
41
|
-
if (override === void 0) {
|
|
42
|
-
const availableKeys = overrides && typeof overrides === "object" ? Object.keys(overrides).join(", ") : "none";
|
|
43
|
-
throw new Error(
|
|
44
|
-
`Override "${overrideKey}" not found for plugin "${pluginName}". Available overrides: ${availableKeys}`
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
return override;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export { BetterStackProvider, useBetterStack, usePluginOverride, usePluginOverrides };
|
|
1
|
+
export { BetterStackProvider, useBasePath, useBetterStack, usePluginOverrides } from './provider.mjs';
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
const React = require('react');
|
|
6
|
+
|
|
7
|
+
const BetterStackContext = React.createContext(
|
|
8
|
+
null
|
|
9
|
+
);
|
|
10
|
+
function BetterStackProvider({
|
|
11
|
+
children,
|
|
12
|
+
overrides,
|
|
13
|
+
basePath
|
|
14
|
+
}) {
|
|
15
|
+
const value = {
|
|
16
|
+
overrides,
|
|
17
|
+
basePath
|
|
18
|
+
};
|
|
19
|
+
return /* @__PURE__ */ jsxRuntime.jsx(BetterStackContext.Provider, { value, children });
|
|
20
|
+
}
|
|
21
|
+
function useBetterStack() {
|
|
22
|
+
const context = React.useContext(
|
|
23
|
+
BetterStackContext
|
|
24
|
+
);
|
|
25
|
+
if (!context) {
|
|
26
|
+
throw new Error(
|
|
27
|
+
"useBetterStack must be used within BetterStackProvider. Wrap your app with <BetterStackProvider> in your layout file."
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
return context;
|
|
31
|
+
}
|
|
32
|
+
function usePluginOverrides(pluginName, defaultValues) {
|
|
33
|
+
const context = useBetterStack();
|
|
34
|
+
const pluginOverrides = context.overrides[pluginName];
|
|
35
|
+
const overrides = defaultValues ? { ...defaultValues, ...pluginOverrides } : pluginOverrides;
|
|
36
|
+
return overrides;
|
|
37
|
+
}
|
|
38
|
+
function useBasePath() {
|
|
39
|
+
const context = useBetterStack();
|
|
40
|
+
if (!context) {
|
|
41
|
+
throw new Error(
|
|
42
|
+
"useBasePath must be used within BetterStackProvider. Wrap your app with <BetterStackProvider> in your layout file."
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
return context.basePath;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
exports.BetterStackProvider = BetterStackProvider;
|
|
49
|
+
exports.useBasePath = useBasePath;
|
|
50
|
+
exports.useBetterStack = useBetterStack;
|
|
51
|
+
exports.usePluginOverrides = usePluginOverrides;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { createContext, useContext } from 'react';
|
|
4
|
+
|
|
5
|
+
const BetterStackContext = createContext(
|
|
6
|
+
null
|
|
7
|
+
);
|
|
8
|
+
function BetterStackProvider({
|
|
9
|
+
children,
|
|
10
|
+
overrides,
|
|
11
|
+
basePath
|
|
12
|
+
}) {
|
|
13
|
+
const value = {
|
|
14
|
+
overrides,
|
|
15
|
+
basePath
|
|
16
|
+
};
|
|
17
|
+
return /* @__PURE__ */ jsx(BetterStackContext.Provider, { value, children });
|
|
18
|
+
}
|
|
19
|
+
function useBetterStack() {
|
|
20
|
+
const context = useContext(
|
|
21
|
+
BetterStackContext
|
|
22
|
+
);
|
|
23
|
+
if (!context) {
|
|
24
|
+
throw new Error(
|
|
25
|
+
"useBetterStack must be used within BetterStackProvider. Wrap your app with <BetterStackProvider> in your layout file."
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
return context;
|
|
29
|
+
}
|
|
30
|
+
function usePluginOverrides(pluginName, defaultValues) {
|
|
31
|
+
const context = useBetterStack();
|
|
32
|
+
const pluginOverrides = context.overrides[pluginName];
|
|
33
|
+
const overrides = defaultValues ? { ...defaultValues, ...pluginOverrides } : pluginOverrides;
|
|
34
|
+
return overrides;
|
|
35
|
+
}
|
|
36
|
+
function useBasePath() {
|
|
37
|
+
const context = useBetterStack();
|
|
38
|
+
if (!context) {
|
|
39
|
+
throw new Error(
|
|
40
|
+
"useBasePath must be used within BetterStackProvider. Wrap your app with <BetterStackProvider> in your layout file."
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
return context.basePath;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export { BetterStackProvider, useBasePath, useBetterStack, usePluginOverrides };
|