@jamwidgets/astro 0.6.6 → 0.6.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/README.md +4 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -1
- package/package.json +2 -2
- package/src/Embed.astro +9 -3
- package/src/Poll.astro +9 -3
- package/src/index.ts +5 -0
package/README.md
CHANGED
|
@@ -257,6 +257,10 @@ import SubscribeForm from "@jamwidgets/astro/SubscribeForm";
|
|
|
257
257
|
</SubscribeForm>
|
|
258
258
|
```
|
|
259
259
|
|
|
260
|
+
### Missing content
|
|
261
|
+
|
|
262
|
+
`Poll`, `Embed` polls, `Gallery` and `RandomPhoto` render nothing when their slug doesn't exist or isn't published, and log a `console.warn` naming it. Create or publish the content in the Jamwidgets dashboard and it appears on the next page load. Other failures still show a short error.
|
|
263
|
+
|
|
260
264
|
## JavaScript API
|
|
261
265
|
|
|
262
266
|
For advanced use cases, use the JavaScript API directly:
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export { DEFAULT_ENDPOINT, API_PATH, VISITOR_STORAGE_KEY, type JamwidgetsConfig, type SeriphConfig, // deprecated alias
|
|
8
8
|
type Comment, type ReactionCounts, type FormSubmitResponse, type SubscribeResponse, type JamwidgetsPost, type JamwidgetsGallery, type GalleryPhoto, type GallerySummary, type SeriphPost, // deprecated alias
|
|
9
|
-
type Announcement, type AnnouncementType, type Poll, type PollOption, type PollSettings, type PollWithResults, type ShowResultsMode, type FeedbackType, buildUrl, getSiteKey, getVisitorId, setVisitorId, type SubmitFormOptions, submitForm, type FetchCommentsOptions, fetchComments, type PostCommentOptions, postComment, type FetchReactionsOptions, type FetchReactionsResponse, fetchReactions, type AddReactionOptions, addReaction, type RemoveReactionOptions, removeReaction, type SubscribeOptions, subscribe, type JoinWaitlistOptions, type JoinWaitlistResponse, joinWaitlist, type ViewCountsOptions, type ViewCounts, type RecordViewResponse, getViewCounts, recordView, type SubmitFeedbackOptions, type SubmitFeedbackResponse, submitFeedback, type FetchPollOptions, fetchPoll, type VotePollOptions, type VotePollResponse, votePoll, type FetchAnnouncementsOptions, fetchAnnouncements, type DismissAnnouncementOptions, dismissAnnouncement, type FetchPostsOptions, fetchPosts, type FetchPostOptions, fetchPost, type FetchGalleriesOptions, fetchGalleries, type FetchGalleryOptions, fetchGallery, type FetchRandomPhotoOptions, fetchRandomPhoto, type SiteConfig, fetchSiteConfig, POWERED_BY_URL, POWERED_BY_LABEL, type ControllerStatus, type ControllerListener, type SubscribeState, type FormState, type ReactionsState, type CommentsState, type WaitlistState, type ViewCountsState, type FeedbackState, type PollState, type AnnouncementsState, SubscribeController, WaitlistController, FormController, ReactionsController, CommentsController, ViewCountsController, FeedbackController, PollController, AnnouncementsController, } from "@jamwidgets/core";
|
|
9
|
+
type Announcement, type AnnouncementType, type Poll, type PollOption, type PollSettings, type PollWithResults, type ShowResultsMode, type FeedbackType, buildUrl, getSiteKey, getVisitorId, setVisitorId, type SubmitFormOptions, submitForm, type FetchCommentsOptions, fetchComments, type PostCommentOptions, postComment, type FetchReactionsOptions, type FetchReactionsResponse, fetchReactions, type AddReactionOptions, addReaction, type RemoveReactionOptions, removeReaction, type SubscribeOptions, subscribe, type JoinWaitlistOptions, type JoinWaitlistResponse, joinWaitlist, type ViewCountsOptions, type ViewCounts, type RecordViewResponse, getViewCounts, recordView, type SubmitFeedbackOptions, type SubmitFeedbackResponse, submitFeedback, type FetchPollOptions, fetchPoll, type VotePollOptions, type VotePollResponse, votePoll, type FetchAnnouncementsOptions, fetchAnnouncements, type DismissAnnouncementOptions, dismissAnnouncement, type FetchPostsOptions, fetchPosts, type FetchPostOptions, fetchPost, type FetchGalleriesOptions, fetchGalleries, type FetchGalleryOptions, fetchGallery, type FetchRandomPhotoOptions, fetchRandomPhoto, JamwidgetsApiError, apiError, isNotFound, type SiteConfig, fetchSiteConfig, POWERED_BY_URL, POWERED_BY_LABEL, type ControllerStatus, type ControllerListener, type SubscribeState, type FormState, type ReactionsState, type CommentsState, type WaitlistState, type ViewCountsState, type FeedbackState, type PollState, type AnnouncementsState, SubscribeController, WaitlistController, FormController, ReactionsController, CommentsController, ViewCountsController, FeedbackController, PollController, AnnouncementsController, } from "@jamwidgets/core";
|
|
10
10
|
export { jamwidgetsPostsLoader, seriphPostsLoader, // deprecated alias
|
|
11
11
|
type JamwidgetsPostsLoaderOptions, type SeriphPostsLoaderOptions, // deprecated alias
|
|
12
12
|
jamwidgetsGalleriesLoader, type JamwidgetsGalleriesLoaderOptions, } from "./loader.js";
|
package/dist/index.js
CHANGED
|
@@ -9,7 +9,9 @@ export {
|
|
|
9
9
|
// Constants
|
|
10
10
|
DEFAULT_ENDPOINT, API_PATH, VISITOR_STORAGE_KEY,
|
|
11
11
|
// Helpers
|
|
12
|
-
buildUrl, getSiteKey, getVisitorId, setVisitorId, submitForm, fetchComments, postComment, fetchReactions, addReaction, removeReaction, subscribe, joinWaitlist, getViewCounts, recordView, submitFeedback, fetchPoll, votePoll, fetchAnnouncements, dismissAnnouncement, fetchPosts, fetchPost, fetchGalleries, fetchGallery, fetchRandomPhoto,
|
|
12
|
+
buildUrl, getSiteKey, getVisitorId, setVisitorId, submitForm, fetchComments, postComment, fetchReactions, addReaction, removeReaction, subscribe, joinWaitlist, getViewCounts, recordView, submitFeedback, fetchPoll, votePoll, fetchAnnouncements, dismissAnnouncement, fetchPosts, fetchPost, fetchGalleries, fetchGallery, fetchRandomPhoto,
|
|
13
|
+
// Errors
|
|
14
|
+
JamwidgetsApiError, apiError, isNotFound, fetchSiteConfig, POWERED_BY_URL, POWERED_BY_LABEL, SubscribeController, WaitlistController, FormController, ReactionsController, CommentsController, ViewCountsController, FeedbackController, PollController, AnnouncementsController, } from "@jamwidgets/core";
|
|
13
15
|
// Re-export loader (Astro-specific)
|
|
14
16
|
export { jamwidgetsPostsLoader, seriphPostsLoader, // deprecated alias
|
|
15
17
|
jamwidgetsGalleriesLoader, } from "./loader.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jamwidgets/astro",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.7",
|
|
4
4
|
"description": "Astro components and content loaders for Jamwidgets",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
],
|
|
61
61
|
"license": "MIT",
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@jamwidgets/core": "^0.
|
|
63
|
+
"@jamwidgets/core": "^0.7.0"
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
66
66
|
"astro": "^5.9.0 || ^6.0.0 || ^7.0.0"
|
package/src/Embed.astro
CHANGED
|
@@ -64,7 +64,7 @@ import Theme from "./Theme.astro";
|
|
|
64
64
|
userVotes?: string[];
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
import { apiError, getVisitorId } from "@jamwidgets/core";
|
|
67
|
+
import { apiError, getVisitorId, warnMissingContent } from "@jamwidgets/core";
|
|
68
68
|
|
|
69
69
|
class JamwidgetsEmbed extends HTMLElement {
|
|
70
70
|
connectedCallback() {
|
|
@@ -134,8 +134,14 @@ import Theme from "./Theme.astro";
|
|
|
134
134
|
|
|
135
135
|
async function loadPoll() {
|
|
136
136
|
try {
|
|
137
|
-
const response = await fetch(`${config.endpoint}/polls/${config.slug}`, { headers });
|
|
138
|
-
if (
|
|
137
|
+
const response = await fetch(`${config.endpoint}/polls/${encodeURIComponent(config.slug)}`, { headers });
|
|
138
|
+
if (response.status === 404) {
|
|
139
|
+
// Missing or unpublished poll: show readers nothing.
|
|
140
|
+
container.style.display = "none";
|
|
141
|
+
warnMissingContent("Embedded poll", config.slug);
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
if (!response.ok) throw await apiError(response, "Failed to load poll");
|
|
139
145
|
const data = await response.json();
|
|
140
146
|
poll = data.poll_with_results;
|
|
141
147
|
renderPoll();
|
package/src/Poll.astro
CHANGED
|
@@ -89,7 +89,7 @@ import Theme from "./Theme.astro";
|
|
|
89
89
|
userVotes?: string[];
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
import { apiError, getVisitorId } from "@jamwidgets/core";
|
|
92
|
+
import { apiError, getVisitorId, warnMissingContent } from "@jamwidgets/core";
|
|
93
93
|
|
|
94
94
|
document.querySelectorAll("[data-jamwidgets-poll]").forEach((container) => {
|
|
95
95
|
const endpoint = (container as HTMLElement).dataset.endpoint;
|
|
@@ -118,8 +118,14 @@ import Theme from "./Theme.astro";
|
|
|
118
118
|
|
|
119
119
|
async function loadPoll() {
|
|
120
120
|
try {
|
|
121
|
-
const response = await fetch(`${endpoint}/polls/${pollSlug}`, { headers });
|
|
122
|
-
if (
|
|
121
|
+
const response = await fetch(`${endpoint}/polls/${encodeURIComponent(pollSlug!)}`, { headers });
|
|
122
|
+
if (response.status === 404) {
|
|
123
|
+
// Missing or unpublished poll: show visitors nothing.
|
|
124
|
+
(container as HTMLElement).style.display = "none";
|
|
125
|
+
warnMissingContent("Poll", pollSlug!);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
if (!response.ok) throw await apiError(response, "Failed to load poll");
|
|
123
129
|
const data = await response.json();
|
|
124
130
|
poll = data.poll_with_results;
|
|
125
131
|
renderPoll();
|
package/src/index.ts
CHANGED