@nuxt/scripts 1.0.0-beta.6 → 1.0.0-rc.1
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/devtools-client/200.html +1 -0
- package/dist/devtools-client/404.html +1 -0
- package/dist/devtools-client/_fonts/4ppnHhMi-pBsWSPo7mY0avYxlDoAg1N3PTzCwXLZ5rA-d9oibkGnTd1JL3tc_xnaVgBLYmOB8kjrK2cvZaqwj9s.woff2 +0 -0
- package/dist/devtools-client/_fonts/4qBuU9MRVUlPZNPSF7Xom_sK8RBEnfYu-9VXFrdq8A8-8TDwLE1HAj1sQn7XxVWtM_7sIaPM-DTdO3Pf8U2DF1U.woff2 +0 -0
- package/dist/devtools-client/_fonts/6dYsbWUd_BpKJ7mdDihgOcya1gHXLpJBuMYXux3WMjE-q3fYNS8YbW5n7ZeXI2vSNgkRWW5VDPKAl51SNTjG2qk.woff2 +0 -0
- package/dist/devtools-client/_fonts/Lr-hqqZZsYmCt0ITUlr1CUrWim9fsKvoDFZliMxgNHY-iTa_Yt_PzhOY9TX7ZXdSlEPim6iRt92xhECwaxWxd5w.woff2 +0 -0
- package/dist/devtools-client/_fonts/OknHvWI6KtYn1JQBzX7eSpNDBQ8520F9TvSUJYkVf6A-xeZn9253svK_8Q2LD0XEruY_MnEsuCRO5LenPoggC0Y.woff2 +0 -0
- package/dist/devtools-client/_fonts/PV2hrQG6wq5BlIPDjdL1IcOflycaghyt5MHzlBqZtlo-lb_WexLz3VZqfTN0oi554iBH5tT2j2UFEV-XErCAS3E.woff2 +0 -0
- package/dist/devtools-client/_fonts/UA7OtwYHwGN_HjcVGTdmiQxUit7FlqkCwxVUWSeXVnQ-B4OXCFOL_tWrYODpQTc07aMaj0c2cewTOmBRWR9tD-A.woff2 +0 -0
- package/dist/devtools-client/_fonts/VE4cDVCv5MxbFM7ZLoLCGbIpNd71zhp7MDI9lmN5Y7I-xZyDYCUVrd6LV8eVGF3Um3UZjBFuUtDGtvdyTBBRYBo.woff2 +0 -0
- package/dist/devtools-client/_fonts/fVoGbnMbBFd5L9BBp9fUPavUSkZ_EmsQNSyadkT-108-U4T0khaeLQSIhtt9eVvaCEKJjtWJ4ioRJOf8hvqkWY0.woff2 +0 -0
- package/dist/devtools-client/_fonts/lQAxeCEs1R0Lw-H9XRU1RlOARQN8J6npRsPjyEDMe5s-_DUSLEkO3tKTuun_gSnDLoQPVEnpOnyqZMOw0ByZ6PA.woff2 +0 -0
- package/dist/devtools-client/_fonts/lntlqNHKLV2n82yTwMde70QqOjcfLE2XJ5oKZ3vRPWc-z6TxpIZQdWXztWLr9_OFWqt_WJJoeGtuK_-XQMZGQwE.woff2 +0 -0
- package/dist/devtools-client/_fonts/qxAYvKsXWeYv731eb-h5TRurcdIP_W44mpNdX-HABAk-zUDeMEFlNtNbrwvT9JxLEBg0TphGy70O6RfIoIX_ZwU.woff2 +0 -0
- package/dist/devtools-client/_nuxt/B3kN3DAy.js +1 -0
- package/dist/devtools-client/_nuxt/B8PEiB0p.js +1 -0
- package/dist/devtools-client/_nuxt/C8jhSQ8l.js +1 -0
- package/dist/devtools-client/_nuxt/CJD6wrkT.js +188 -0
- package/dist/devtools-client/_nuxt/CfOsp0mU.js +1 -0
- package/dist/devtools-client/_nuxt/DKL6PHO3.js +1 -0
- package/dist/devtools-client/_nuxt/ajngqPCs.js +1 -0
- package/dist/devtools-client/_nuxt/builds/latest.json +1 -0
- package/dist/devtools-client/_nuxt/builds/meta/b800a0be-5cab-4ea6-89e3-dd3a85690a73.json +1 -0
- package/dist/devtools-client/_nuxt/dlaR8P-P.js +1 -0
- package/dist/devtools-client/_nuxt/entry.BwpOBArY.css +1 -0
- package/dist/devtools-client/_nuxt/error-404.CvOVjXeC.css +1 -0
- package/dist/devtools-client/_nuxt/error-500.BIm53nmx.css +1 -0
- package/dist/devtools-client/_nuxt/first-party.C8Ha4JLM.css +1 -0
- package/dist/devtools-client/_nuxt/index.CA-OpSj0.css +1 -0
- package/dist/devtools-client/_nuxt/registry.B9lnjF_b.css +1 -0
- package/dist/devtools-client/_nuxt/wDzz0qaB.js +1 -0
- package/dist/devtools-client/docs/index.html +1 -0
- package/dist/devtools-client/first-party/index.html +1 -0
- package/dist/devtools-client/index.html +1 -0
- package/dist/devtools-client/registry/index.html +1 -0
- package/dist/module.d.mts +29 -84
- package/dist/module.d.ts +121 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +941 -757
- package/dist/registry.d.mts +91 -4
- package/dist/registry.d.ts +93 -0
- package/dist/registry.mjs +669 -324
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.d.vue.ts +15 -79
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.vue +78 -180
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.vue.d.ts +15 -79
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsAdvancedMarkerElement.d.vue.ts +6 -55
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsAdvancedMarkerElement.vue +12 -83
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsAdvancedMarkerElement.vue.d.ts +6 -55
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsCircle.d.vue.ts +5 -1
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsCircle.vue +24 -38
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsCircle.vue.d.ts +5 -1
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsGeoJson.d.vue.ts +43 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsGeoJson.vue +60 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsGeoJson.vue.d.ts +43 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsHeatmapLayer.d.vue.ts +4 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsHeatmapLayer.vue +22 -26
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsHeatmapLayer.vue.d.ts +4 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsInfoWindow.d.vue.ts +9 -5
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsInfoWindow.vue +56 -57
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsInfoWindow.vue.d.ts +9 -5
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarker.d.vue.ts +24 -41
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarker.vue +69 -73
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarker.vue.d.ts +24 -41
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarkerClusterer.d.vue.ts +36 -4
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarkerClusterer.vue +82 -37
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarkerClusterer.vue.d.ts +36 -4
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsOverlayView.d.vue.ts +78 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsOverlayView.vue +222 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsOverlayView.vue.d.ts +78 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPinElement.d.vue.ts +10 -3
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPinElement.vue +9 -41
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPinElement.vue.d.ts +10 -3
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolygon.d.vue.ts +7 -3
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolygon.vue +23 -38
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolygon.vue.d.ts +7 -3
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolyline.d.vue.ts +7 -3
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolyline.vue +23 -38
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolyline.vue.d.ts +7 -3
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsRectangle.d.vue.ts +7 -3
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsRectangle.vue +24 -38
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsRectangle.vue.d.ts +7 -3
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsStaticMap.d.vue.ts +200 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsStaticMap.vue +165 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsStaticMap.vue.d.ts +200 -0
- package/dist/runtime/components/GoogleMaps/bindGoogleMapsEvents.d.ts +13 -0
- package/dist/runtime/components/GoogleMaps/bindGoogleMapsEvents.js +8 -0
- package/dist/runtime/components/GoogleMaps/injectionKeys.d.ts +10 -0
- package/dist/runtime/components/GoogleMaps/injectionKeys.js +2 -0
- package/dist/runtime/components/GoogleMaps/useGoogleMapsResource.d.ts +48 -0
- package/dist/runtime/components/GoogleMaps/useGoogleMapsResource.js +51 -0
- package/dist/runtime/components/ScriptBlueskyEmbed.d.vue.ts +85 -0
- package/dist/runtime/components/ScriptBlueskyEmbed.vue +88 -0
- package/dist/runtime/components/ScriptBlueskyEmbed.vue.d.ts +85 -0
- package/dist/runtime/components/ScriptCrisp.vue +1 -1
- package/dist/runtime/components/ScriptGoogleAdsense.vue +1 -1
- package/dist/runtime/components/ScriptGravatar.d.vue.ts +22 -0
- package/dist/runtime/components/ScriptGravatar.vue +46 -0
- package/dist/runtime/components/ScriptGravatar.vue.d.ts +22 -0
- package/dist/runtime/components/ScriptInstagramEmbed.d.vue.ts +1 -2
- package/dist/runtime/components/ScriptInstagramEmbed.vue +8 -3
- package/dist/runtime/components/ScriptInstagramEmbed.vue.d.ts +1 -2
- package/dist/runtime/components/ScriptIntercom.vue +4 -3
- package/dist/runtime/components/ScriptPayPalButtons.d.vue.ts +43 -32
- package/dist/runtime/components/ScriptPayPalButtons.vue +48 -79
- package/dist/runtime/components/ScriptPayPalButtons.vue.d.ts +43 -32
- package/dist/runtime/components/ScriptPayPalMessages.d.vue.ts +37 -23
- package/dist/runtime/components/ScriptPayPalMessages.vue +46 -50
- package/dist/runtime/components/ScriptPayPalMessages.vue.d.ts +37 -23
- package/dist/runtime/components/ScriptStripePricingTable.vue +2 -2
- package/dist/runtime/components/ScriptVimeoPlayer.d.vue.ts +9 -0
- package/dist/runtime/components/ScriptVimeoPlayer.vue +13 -10
- package/dist/runtime/components/ScriptVimeoPlayer.vue.d.ts +9 -0
- package/dist/runtime/components/ScriptXEmbed.d.vue.ts +0 -2
- package/dist/runtime/components/ScriptXEmbed.vue +14 -8
- package/dist/runtime/components/ScriptXEmbed.vue.d.ts +0 -2
- package/dist/runtime/components/ScriptYouTubePlayer.d.vue.ts +2 -2
- package/dist/runtime/components/ScriptYouTubePlayer.vue +11 -5
- package/dist/runtime/components/ScriptYouTubePlayer.vue.d.ts +2 -2
- package/dist/runtime/composables/useScript.js +148 -8
- package/dist/runtime/composables/useScriptEventPage.js +2 -2
- package/dist/runtime/composables/useScriptTriggerConsent.d.ts +10 -0
- package/dist/runtime/composables/useScriptTriggerConsent.js +33 -20
- package/dist/runtime/composables/useScriptTriggerElement.js +1 -1
- package/dist/runtime/composables/useScriptTriggerIdleTimeout.js +1 -1
- package/dist/runtime/devtools-standalone-bridge.client.d.ts +8 -0
- package/dist/runtime/devtools-standalone-bridge.client.js +50 -0
- package/dist/runtime/registry/bing-uet.d.ts +20 -0
- package/dist/runtime/registry/bing-uet.js +29 -0
- package/dist/runtime/registry/bluesky-embed.d.ts +116 -0
- package/dist/runtime/registry/bluesky-embed.js +72 -0
- package/dist/runtime/registry/clarity.d.ts +10 -15
- package/dist/runtime/registry/clarity.js +22 -31
- package/dist/runtime/registry/cloudflare-web-analytics.d.ts +2 -13
- package/dist/runtime/registry/cloudflare-web-analytics.js +2 -14
- package/dist/runtime/registry/crisp.d.ts +10 -40
- package/dist/runtime/registry/crisp.js +2 -33
- package/dist/runtime/registry/databuddy-analytics.d.ts +2 -35
- package/dist/runtime/registry/databuddy-analytics.js +20 -45
- package/dist/runtime/registry/fathom-analytics.d.ts +7 -26
- package/dist/runtime/registry/fathom-analytics.js +3 -25
- package/dist/runtime/registry/google-adsense.d.ts +3 -11
- package/dist/runtime/registry/google-adsense.js +2 -11
- package/dist/runtime/registry/google-analytics.d.ts +3 -5
- package/dist/runtime/registry/google-analytics.js +3 -8
- package/dist/runtime/registry/google-maps.d.ts +3 -9
- package/dist/runtime/registry/google-maps.js +2 -8
- package/dist/runtime/registry/google-recaptcha.d.ts +2 -6
- package/dist/runtime/registry/google-recaptcha.js +4 -12
- package/dist/runtime/registry/google-sign-in.d.ts +2 -13
- package/dist/runtime/registry/google-sign-in.js +2 -22
- package/dist/runtime/registry/google-tag-manager.d.ts +3 -28
- package/dist/runtime/registry/google-tag-manager.js +4 -27
- package/dist/runtime/registry/gravatar.d.ts +26 -0
- package/dist/runtime/registry/gravatar.js +36 -0
- package/dist/runtime/registry/hotjar.d.ts +4 -6
- package/dist/runtime/registry/hotjar.js +2 -5
- package/dist/runtime/registry/instagram-embed.d.ts +3 -18
- package/dist/runtime/registry/instagram-embed.js +4 -19
- package/dist/runtime/registry/intercom.d.ts +5 -13
- package/dist/runtime/registry/intercom.js +2 -12
- package/dist/runtime/registry/matomo-analytics.d.ts +3 -12
- package/dist/runtime/registry/matomo-analytics.js +3 -12
- package/dist/runtime/registry/meta-pixel.d.ts +4 -6
- package/dist/runtime/registry/meta-pixel.js +2 -4
- package/dist/runtime/registry/mixpanel-analytics.d.ts +22 -0
- package/dist/runtime/registry/mixpanel-analytics.js +46 -0
- package/dist/runtime/registry/npm.d.ts +3 -7
- package/dist/runtime/registry/npm.js +2 -9
- package/dist/runtime/registry/paypal.d.ts +4 -25
- package/dist/runtime/registry/paypal.js +3 -66
- package/dist/runtime/registry/plausible-analytics.js +19 -14
- package/dist/runtime/registry/posthog.d.ts +10 -12
- package/dist/runtime/registry/posthog.js +4 -13
- package/dist/runtime/registry/reddit-pixel.d.ts +5 -6
- package/dist/runtime/registry/reddit-pixel.js +2 -4
- package/dist/runtime/registry/rybbit-analytics.d.ts +2 -14
- package/dist/runtime/registry/rybbit-analytics.js +10 -20
- package/dist/runtime/registry/schemas.d.ts +982 -0
- package/dist/runtime/registry/schemas.js +937 -0
- package/dist/runtime/registry/segment.d.ts +2 -5
- package/dist/runtime/registry/segment.js +2 -5
- package/dist/runtime/registry/snapchat-pixel.d.ts +5 -34
- package/dist/runtime/registry/snapchat-pixel.js +2 -20
- package/dist/runtime/registry/stripe.d.ts +3 -4
- package/dist/runtime/registry/stripe.js +2 -4
- package/dist/runtime/registry/tiktok-pixel.d.ts +4 -7
- package/dist/runtime/registry/tiktok-pixel.js +2 -6
- package/dist/runtime/registry/umami-analytics.d.ts +2 -31
- package/dist/runtime/registry/umami-analytics.js +2 -36
- package/dist/runtime/registry/vercel-analytics.d.ts +29 -0
- package/dist/runtime/registry/vercel-analytics.js +84 -0
- package/dist/runtime/registry/vimeo-player.d.ts +2 -2
- package/dist/runtime/registry/vimeo-player.js +1 -1
- package/dist/runtime/registry/x-embed.d.ts +3 -17
- package/dist/runtime/registry/x-embed.js +3 -18
- package/dist/runtime/registry/x-pixel.d.ts +4 -7
- package/dist/runtime/registry/x-pixel.js +2 -5
- package/dist/runtime/registry/youtube-player.d.ts +7 -7
- package/dist/runtime/registry/youtube-player.js +1 -1
- package/dist/runtime/server/bluesky-embed-image.d.ts +2 -0
- package/dist/runtime/server/bluesky-embed-image.js +7 -0
- package/dist/runtime/server/bluesky-embed.d.ts +16 -0
- package/dist/runtime/server/bluesky-embed.js +59 -0
- package/dist/runtime/server/google-maps-geocode-proxy.d.ts +2 -0
- package/dist/runtime/server/google-maps-geocode-proxy.js +34 -0
- package/dist/runtime/server/google-static-maps-proxy.js +2 -13
- package/dist/runtime/server/gravatar-proxy.d.ts +2 -0
- package/dist/runtime/server/gravatar-proxy.js +46 -0
- package/dist/runtime/server/instagram-embed-asset.js +8 -41
- package/dist/runtime/server/instagram-embed-image.js +6 -53
- package/dist/runtime/server/instagram-embed.d.ts +16 -0
- package/dist/runtime/server/instagram-embed.js +176 -35
- package/dist/runtime/server/proxy-handler.js +142 -95
- package/dist/runtime/server/utils/image-proxy.d.ts +12 -0
- package/dist/runtime/server/utils/image-proxy.js +70 -0
- package/dist/runtime/server/utils/privacy.d.ts +1 -10
- package/dist/runtime/server/utils/privacy.js +60 -40
- package/dist/runtime/server/x-embed-image.js +5 -49
- package/dist/runtime/server/x-embed.js +3 -2
- package/dist/runtime/types.d.ts +272 -51
- package/dist/runtime/types.js +0 -2
- package/dist/runtime/utils/pure.d.ts +1 -1
- package/dist/runtime/utils.d.ts +6 -4
- package/dist/runtime/utils.js +31 -14
- package/dist/stats.d.mts +202 -0
- package/dist/stats.d.ts +202 -0
- package/dist/stats.mjs +3875 -0
- package/dist/types-source.d.mts +17 -0
- package/dist/types-source.d.ts +17 -0
- package/dist/types-source.mjs +3414 -0
- package/dist/types.d.mts +4 -2
- package/package.json +35 -61
- package/README.md +0 -86
- package/dist/client/200.html +0 -1
- package/dist/client/404.html +0 -1
- package/dist/client/_nuxt/BPQ3VLAy.js +0 -1
- package/dist/client/_nuxt/BpR-tlZc.js +0 -1
- package/dist/client/_nuxt/CBbMDhE2.js +0 -162
- package/dist/client/_nuxt/CEMAW3aB.js +0 -1
- package/dist/client/_nuxt/MWkREqzj.js +0 -1
- package/dist/client/_nuxt/builds/latest.json +0 -1
- package/dist/client/_nuxt/builds/meta/762d443a-0880-424f-bda8-2b32b39d43ec.json +0 -1
- package/dist/client/_nuxt/entry.D45OuV0w.css +0 -1
- package/dist/client/_nuxt/error-404.B57D-jUQ.css +0 -1
- package/dist/client/_nuxt/error-500.DTHUW7BI.css +0 -1
- package/dist/client/index.html +0 -1
- package/dist/runtime/components/ScriptPayPalMarks.d.vue.ts +0 -52
- package/dist/runtime/components/ScriptPayPalMarks.vue +0 -69
- package/dist/runtime/components/ScriptPayPalMarks.vue.d.ts +0 -52
- package/dist/runtime/validation/mock.d.ts +0 -42
- package/dist/runtime/validation/mock.js +0 -21
- package/dist/runtime/validation/valibot.d.ts +0 -1
- package/dist/runtime/validation/valibot.js +0 -1
- /package/dist/{client → devtools-client}/_nuxt/CVO1_9PV.js +0 -0
- /package/dist/{client → devtools-client}/_nuxt/Cp-IABpG.js +0 -0
- /package/dist/{client → devtools-client}/_nuxt/D0r3Knsf.js +0 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { useRuntimeConfig } from "#imports";
|
|
2
|
+
import { createError, defineEventHandler, getQuery, setHeader } from "h3";
|
|
3
|
+
import { $fetch } from "ofetch";
|
|
4
|
+
import { withQuery } from "ufo";
|
|
5
|
+
export default defineEventHandler(async (event) => {
|
|
6
|
+
const runtimeConfig = useRuntimeConfig();
|
|
7
|
+
const privateConfig = runtimeConfig["nuxt-scripts"]?.googleMapsGeocodeProxy;
|
|
8
|
+
const apiKey = privateConfig?.apiKey;
|
|
9
|
+
if (!apiKey) {
|
|
10
|
+
throw createError({
|
|
11
|
+
statusCode: 500,
|
|
12
|
+
statusMessage: "Google Maps API key not configured for geocode proxy"
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
const query = getQuery(event);
|
|
16
|
+
const { key: _clientKey, ...safeQuery } = query;
|
|
17
|
+
const geocodeUrl = withQuery("https://maps.googleapis.com/maps/api/geocode/json", {
|
|
18
|
+
...safeQuery,
|
|
19
|
+
key: apiKey
|
|
20
|
+
});
|
|
21
|
+
const data = await $fetch(geocodeUrl, {
|
|
22
|
+
headers: {
|
|
23
|
+
"User-Agent": "Nuxt Scripts Google Geocode Proxy"
|
|
24
|
+
}
|
|
25
|
+
}).catch((error) => {
|
|
26
|
+
throw createError({
|
|
27
|
+
statusCode: error.statusCode || 500,
|
|
28
|
+
statusMessage: error.statusMessage || "Failed to geocode"
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
setHeader(event, "Content-Type", "application/json");
|
|
32
|
+
setHeader(event, "Cache-Control", "public, max-age=86400, s-maxage=86400");
|
|
33
|
+
return data;
|
|
34
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useRuntimeConfig } from "#imports";
|
|
2
|
+
import { createError, defineEventHandler, getQuery, setHeader } from "h3";
|
|
2
3
|
import { $fetch } from "ofetch";
|
|
3
4
|
import { withQuery } from "ufo";
|
|
4
|
-
import { useRuntimeConfig } from "#imports";
|
|
5
5
|
export default defineEventHandler(async (event) => {
|
|
6
6
|
const runtimeConfig = useRuntimeConfig();
|
|
7
7
|
const publicConfig = runtimeConfig.public["nuxt-scripts"]?.googleStaticMapsProxy;
|
|
@@ -19,17 +19,6 @@ export default defineEventHandler(async (event) => {
|
|
|
19
19
|
statusMessage: "Google Maps API key not configured for proxy"
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
|
-
const referer = getHeader(event, "referer");
|
|
23
|
-
const host = getHeader(event, "host");
|
|
24
|
-
if (referer && host) {
|
|
25
|
-
const refererUrl = new URL(referer).host;
|
|
26
|
-
if (refererUrl !== host) {
|
|
27
|
-
throw createError({
|
|
28
|
-
statusCode: 403,
|
|
29
|
-
statusMessage: "Invalid referer"
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
22
|
const query = getQuery(event);
|
|
34
23
|
const { key: _clientKey, ...safeQuery } = query;
|
|
35
24
|
const googleMapsUrl = withQuery("https://maps.googleapis.com/maps/api/staticmap", {
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { useRuntimeConfig } from "#imports";
|
|
2
|
+
import { createError, defineEventHandler, getQuery, setHeader } from "h3";
|
|
3
|
+
import { $fetch } from "ofetch";
|
|
4
|
+
import { withQuery } from "ufo";
|
|
5
|
+
export default defineEventHandler(async (event) => {
|
|
6
|
+
const runtimeConfig = useRuntimeConfig();
|
|
7
|
+
const proxyConfig = runtimeConfig.public["nuxt-scripts"]?.gravatarProxy;
|
|
8
|
+
const query = getQuery(event);
|
|
9
|
+
let hash = query.hash;
|
|
10
|
+
const email = query.email;
|
|
11
|
+
if (!hash && email) {
|
|
12
|
+
const encoder = new TextEncoder();
|
|
13
|
+
const data = encoder.encode(email.trim().toLowerCase());
|
|
14
|
+
const hashBuffer = await crypto.subtle.digest("SHA-256", data);
|
|
15
|
+
hash = Array.from(new Uint8Array(hashBuffer), (b) => b.toString(16).padStart(2, "0")).join("");
|
|
16
|
+
}
|
|
17
|
+
if (!hash) {
|
|
18
|
+
throw createError({
|
|
19
|
+
statusCode: 400,
|
|
20
|
+
statusMessage: "Either hash or email parameter is required"
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
const size = query.s || "80";
|
|
24
|
+
const defaultImg = query.d || "mp";
|
|
25
|
+
const rating = query.r || "g";
|
|
26
|
+
const gravatarUrl = withQuery(`https://www.gravatar.com/avatar/${hash}`, {
|
|
27
|
+
s: size,
|
|
28
|
+
d: defaultImg,
|
|
29
|
+
r: rating
|
|
30
|
+
});
|
|
31
|
+
const response = await $fetch.raw(gravatarUrl, {
|
|
32
|
+
headers: {
|
|
33
|
+
"User-Agent": "Nuxt Scripts Gravatar Proxy"
|
|
34
|
+
}
|
|
35
|
+
}).catch((error) => {
|
|
36
|
+
throw createError({
|
|
37
|
+
statusCode: error.statusCode || 500,
|
|
38
|
+
statusMessage: error.statusMessage || "Failed to fetch Gravatar avatar"
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
const cacheMaxAge = proxyConfig?.cacheMaxAge ?? 3600;
|
|
42
|
+
setHeader(event, "Content-Type", response.headers.get("content-type") || "image/jpeg");
|
|
43
|
+
setHeader(event, "Cache-Control", `public, max-age=${cacheMaxAge}, s-maxage=${cacheMaxAge}`);
|
|
44
|
+
setHeader(event, "Vary", "Accept-Encoding");
|
|
45
|
+
return response._data;
|
|
46
|
+
});
|
|
@@ -1,42 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
statusMessage: "Asset URL is required"
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
let parsedUrl;
|
|
13
|
-
try {
|
|
14
|
-
parsedUrl = new URL(url);
|
|
15
|
-
} catch {
|
|
16
|
-
throw createError({
|
|
17
|
-
statusCode: 400,
|
|
18
|
-
statusMessage: "Invalid asset URL"
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
if (parsedUrl.hostname !== "static.cdninstagram.com") {
|
|
22
|
-
throw createError({
|
|
23
|
-
statusCode: 403,
|
|
24
|
-
statusMessage: "Domain not allowed"
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
const response = await $fetch.raw(url, {
|
|
28
|
-
headers: {
|
|
29
|
-
"Accept": "*/*",
|
|
30
|
-
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"
|
|
31
|
-
}
|
|
32
|
-
}).catch((error) => {
|
|
33
|
-
throw createError({
|
|
34
|
-
statusCode: error.statusCode || 500,
|
|
35
|
-
statusMessage: error.statusMessage || "Failed to fetch asset"
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
const contentType = response.headers.get("content-type") || "application/octet-stream";
|
|
39
|
-
setHeader(event, "Content-Type", contentType);
|
|
40
|
-
setHeader(event, "Cache-Control", "public, max-age=86400, s-maxage=86400");
|
|
41
|
-
return response._data;
|
|
1
|
+
import { createImageProxyHandler } from "./utils/image-proxy.js";
|
|
2
|
+
export default createImageProxyHandler({
|
|
3
|
+
allowedDomains: ["static.cdninstagram.com"],
|
|
4
|
+
accept: "*/*",
|
|
5
|
+
userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36",
|
|
6
|
+
cacheMaxAge: 86400,
|
|
7
|
+
contentType: "application/octet-stream",
|
|
8
|
+
decodeAmpersands: true
|
|
42
9
|
});
|
|
@@ -1,54 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
throw createError({
|
|
8
|
-
statusCode: 400,
|
|
9
|
-
statusMessage: "Image URL is required"
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
let parsedUrl;
|
|
13
|
-
try {
|
|
14
|
-
parsedUrl = new URL(url);
|
|
15
|
-
} catch {
|
|
16
|
-
throw createError({
|
|
17
|
-
statusCode: 400,
|
|
18
|
-
statusMessage: "Invalid image URL"
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
if (parsedUrl.protocol !== "http:" && parsedUrl.protocol !== "https:") {
|
|
22
|
-
throw createError({
|
|
23
|
-
statusCode: 400,
|
|
24
|
-
statusMessage: "Invalid URL scheme"
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
if (!parsedUrl.hostname.endsWith(".cdninstagram.com") && parsedUrl.hostname !== "scontent.cdninstagram.com") {
|
|
28
|
-
throw createError({
|
|
29
|
-
statusCode: 403,
|
|
30
|
-
statusMessage: "Domain not allowed"
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
const response = await $fetch.raw(url, {
|
|
34
|
-
redirect: "manual",
|
|
35
|
-
headers: {
|
|
36
|
-
"Accept": "image/webp,image/jpeg,image/png,image/*,*/*;q=0.8",
|
|
37
|
-
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"
|
|
38
|
-
}
|
|
39
|
-
}).catch((error) => {
|
|
40
|
-
throw createError({
|
|
41
|
-
statusCode: error.statusCode || 500,
|
|
42
|
-
statusMessage: error.statusMessage || "Failed to fetch image"
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
if (response.status >= 300 && response.status < 400) {
|
|
46
|
-
throw createError({
|
|
47
|
-
statusCode: 403,
|
|
48
|
-
statusMessage: "Redirects not allowed"
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
setHeader(event, "Content-Type", response.headers.get("content-type") || "image/jpeg");
|
|
52
|
-
setHeader(event, "Cache-Control", "public, max-age=3600, s-maxage=3600");
|
|
53
|
-
return response._data;
|
|
1
|
+
import { createImageProxyHandler } from "./utils/image-proxy.js";
|
|
2
|
+
export default createImageProxyHandler({
|
|
3
|
+
allowedDomains: (hostname) => hostname.endsWith(".cdninstagram.com") || hostname === "scontent.cdninstagram.com",
|
|
4
|
+
userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36",
|
|
5
|
+
followRedirects: false,
|
|
6
|
+
decodeAmpersands: true
|
|
54
7
|
});
|
|
@@ -1,2 +1,18 @@
|
|
|
1
|
+
export declare const RSRC_RE: RegExp;
|
|
2
|
+
export declare const AMP_RE: RegExp;
|
|
3
|
+
export declare const SCONTENT_RE: RegExp;
|
|
4
|
+
export declare const STATIC_CDN_RE: RegExp;
|
|
5
|
+
export declare const LOOKASIDE_RE: RegExp;
|
|
6
|
+
export declare const INSTAGRAM_IMAGE_HOSTS: string[];
|
|
7
|
+
export declare const INSTAGRAM_ASSET_HOST = "static.cdninstagram.com";
|
|
8
|
+
export declare function proxyImageUrl(url: string, prefix?: string): string;
|
|
9
|
+
export declare function proxyAssetUrl(url: string, prefix?: string): string;
|
|
10
|
+
export declare function rewriteUrl(url: string, prefix?: string): string;
|
|
11
|
+
export declare function rewriteUrlsInText(text: string, prefix?: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* Scope CSS rules under a parent selector and strip global/page-level rules.
|
|
14
|
+
* Removes :root, html, body selectors and @charset/@import at-rules.
|
|
15
|
+
*/
|
|
16
|
+
export declare function scopeCss(css: string, scopeSelector: string): string;
|
|
1
17
|
declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<string>>;
|
|
2
18
|
export default _default;
|
|
@@ -1,6 +1,132 @@
|
|
|
1
1
|
import { createError, defineEventHandler, getQuery, setHeader } from "h3";
|
|
2
2
|
import { $fetch } from "ofetch";
|
|
3
|
+
import { ELEMENT_NODE, parse, renderSync, TEXT_NODE, walkSync } from "ultrahtml";
|
|
4
|
+
export const RSRC_RE = /url\(\/rsrc\.php([^)]+)\)/g;
|
|
5
|
+
export const AMP_RE = /&/g;
|
|
6
|
+
export const SCONTENT_RE = /https:\/\/scontent[^"'\s),]+\.cdninstagram\.com[^"'\s),]+/g;
|
|
7
|
+
export const STATIC_CDN_RE = /https:\/\/static\.cdninstagram\.com[^"'\s),]+/g;
|
|
8
|
+
export const LOOKASIDE_RE = /https:\/\/lookaside\.instagram\.com[^"'\s),]+/g;
|
|
9
|
+
export const INSTAGRAM_IMAGE_HOSTS = ["scontent.cdninstagram.com", "lookaside.instagram.com"];
|
|
10
|
+
export const INSTAGRAM_ASSET_HOST = "static.cdninstagram.com";
|
|
11
|
+
const CHARSET_RE = /@charset\s[^;]+;/gi;
|
|
12
|
+
const IMPORT_RE = /@import\s[^;]+;/gi;
|
|
13
|
+
const WHITESPACE_RE = /\s/;
|
|
14
|
+
const EMBED_INSTAGRAM_SUFFIX_RE = /\/embed\/instagram$/;
|
|
15
|
+
const AT_RULE_NAME_RE = /@([\w-]+)/;
|
|
16
|
+
const MULTI_SPACE_RE = /\s+/g;
|
|
17
|
+
const SRCSET_SPLIT_RE = /\s+/;
|
|
18
|
+
export function proxyImageUrl(url, prefix = "/_scripts") {
|
|
19
|
+
return `${prefix}/embed/instagram-image?url=${encodeURIComponent(url.replace(AMP_RE, "&"))}`;
|
|
20
|
+
}
|
|
21
|
+
export function proxyAssetUrl(url, prefix = "/_scripts") {
|
|
22
|
+
return `${prefix}/embed/instagram-asset?url=${encodeURIComponent(url.replace(AMP_RE, "&"))}`;
|
|
23
|
+
}
|
|
24
|
+
export function rewriteUrl(url, prefix = "/_scripts") {
|
|
25
|
+
try {
|
|
26
|
+
const parsed = new URL(url);
|
|
27
|
+
if (parsed.hostname === INSTAGRAM_ASSET_HOST)
|
|
28
|
+
return proxyAssetUrl(url, prefix);
|
|
29
|
+
if (INSTAGRAM_IMAGE_HOSTS.some((h) => parsed.hostname === h || parsed.hostname.endsWith(`.cdninstagram.com`)))
|
|
30
|
+
return proxyImageUrl(url, prefix);
|
|
31
|
+
} catch {
|
|
32
|
+
}
|
|
33
|
+
return url;
|
|
34
|
+
}
|
|
35
|
+
export function rewriteUrlsInText(text, prefix = "/_scripts") {
|
|
36
|
+
return text.replace(SCONTENT_RE, (m) => proxyImageUrl(m, prefix)).replace(STATIC_CDN_RE, (m) => proxyAssetUrl(m, prefix)).replace(LOOKASIDE_RE, (m) => proxyImageUrl(m, prefix));
|
|
37
|
+
}
|
|
38
|
+
function removeNode(node) {
|
|
39
|
+
node.type = TEXT_NODE;
|
|
40
|
+
node.value = "";
|
|
41
|
+
node.name = void 0;
|
|
42
|
+
node.attributes = {};
|
|
43
|
+
node.children = [];
|
|
44
|
+
}
|
|
45
|
+
export function scopeCss(css, scopeSelector) {
|
|
46
|
+
let result = css.replace(CHARSET_RE, "");
|
|
47
|
+
result = result.replace(IMPORT_RE, "");
|
|
48
|
+
return processRules(result, scopeSelector);
|
|
49
|
+
}
|
|
50
|
+
function processRules(css, scopeSelector) {
|
|
51
|
+
const output = [];
|
|
52
|
+
let i = 0;
|
|
53
|
+
while (i < css.length) {
|
|
54
|
+
while (i < css.length && WHITESPACE_RE.test(css[i])) i++;
|
|
55
|
+
if (i >= css.length)
|
|
56
|
+
break;
|
|
57
|
+
if (css[i] === "@") {
|
|
58
|
+
const atRule = extractAtRule(css, i);
|
|
59
|
+
if (atRule) {
|
|
60
|
+
const atName = atRule.content.match(AT_RULE_NAME_RE)?.[1]?.toLowerCase();
|
|
61
|
+
if (atName === "media" || atName === "supports" || atName === "layer") {
|
|
62
|
+
const braceStart = atRule.content.indexOf("{");
|
|
63
|
+
const innerCss = atRule.content.slice(braceStart + 1, -1);
|
|
64
|
+
const scopedInner = processRules(innerCss, scopeSelector);
|
|
65
|
+
output.push(`${atRule.content.slice(0, braceStart + 1) + scopedInner}}`);
|
|
66
|
+
} else if (atName === "keyframes" || atName === "-webkit-keyframes" || atName === "font-face") {
|
|
67
|
+
output.push(atRule.content);
|
|
68
|
+
}
|
|
69
|
+
i = atRule.end;
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const bracePos = css.indexOf("{", i);
|
|
74
|
+
if (bracePos === -1)
|
|
75
|
+
break;
|
|
76
|
+
const selector = css.slice(i, bracePos).trim();
|
|
77
|
+
const block = extractBlock(css, bracePos);
|
|
78
|
+
if (!block)
|
|
79
|
+
break;
|
|
80
|
+
i = block.end;
|
|
81
|
+
if (!selector)
|
|
82
|
+
continue;
|
|
83
|
+
const selectors = selector.split(",").map((s) => s.trim());
|
|
84
|
+
const filteredSelectors = selectors.filter((s) => {
|
|
85
|
+
const normalized = s.replace(MULTI_SPACE_RE, " ").trim().toLowerCase();
|
|
86
|
+
return normalized !== ":root" && normalized !== "html" && normalized !== "body" && !normalized.startsWith(":root ") && !normalized.startsWith("html ") && !normalized.startsWith("body ") && normalized !== "html, body";
|
|
87
|
+
});
|
|
88
|
+
if (filteredSelectors.length === 0)
|
|
89
|
+
continue;
|
|
90
|
+
const scopedSelectors = filteredSelectors.map((s) => {
|
|
91
|
+
return `${scopeSelector} ${s}`;
|
|
92
|
+
});
|
|
93
|
+
output.push(`${scopedSelectors.join(", ")} ${block.content}`);
|
|
94
|
+
}
|
|
95
|
+
return output.join("\n");
|
|
96
|
+
}
|
|
97
|
+
function extractAtRule(css, start) {
|
|
98
|
+
const bracePos = css.indexOf("{", start);
|
|
99
|
+
const semiPos = css.indexOf(";", start);
|
|
100
|
+
if (semiPos !== -1 && (bracePos === -1 || semiPos < bracePos)) {
|
|
101
|
+
return { content: css.slice(start, semiPos + 1), end: semiPos + 1 };
|
|
102
|
+
}
|
|
103
|
+
if (bracePos === -1)
|
|
104
|
+
return null;
|
|
105
|
+
const block = extractBlock(css, bracePos);
|
|
106
|
+
if (!block)
|
|
107
|
+
return null;
|
|
108
|
+
return {
|
|
109
|
+
content: css.slice(start, bracePos) + block.content,
|
|
110
|
+
end: block.end
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
function extractBlock(css, openBrace) {
|
|
114
|
+
let depth = 0;
|
|
115
|
+
for (let j = openBrace; j < css.length; j++) {
|
|
116
|
+
if (css[j] === "{") {
|
|
117
|
+
depth++;
|
|
118
|
+
} else if (css[j] === "}") {
|
|
119
|
+
depth--;
|
|
120
|
+
if (depth === 0) {
|
|
121
|
+
return { content: css.slice(openBrace, j + 1), end: j + 1 };
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
3
127
|
export default defineEventHandler(async (event) => {
|
|
128
|
+
const handlerPath = event.path?.split("?")[0] || "";
|
|
129
|
+
const prefix = handlerPath.replace(EMBED_INSTAGRAM_SUFFIX_RE, "") || "/_scripts";
|
|
4
130
|
const query = getQuery(event);
|
|
5
131
|
const postUrl = query.url;
|
|
6
132
|
const captions = query.captions === "true";
|
|
@@ -27,11 +153,10 @@ export default defineEventHandler(async (event) => {
|
|
|
27
153
|
}
|
|
28
154
|
const pathname = parsedUrl.pathname.endsWith("/") ? parsedUrl.pathname : `${parsedUrl.pathname}/`;
|
|
29
155
|
const cleanUrl = parsedUrl.origin + pathname;
|
|
30
|
-
const embedUrl = cleanUrl
|
|
156
|
+
const embedUrl = `${cleanUrl}embed/${captions ? "captioned/" : ""}`;
|
|
31
157
|
const html = await $fetch(embedUrl, {
|
|
32
158
|
headers: {
|
|
33
159
|
"Accept": "text/html",
|
|
34
|
-
// Use simple UA - full Chrome UA triggers JS-heavy version without static content
|
|
35
160
|
"User-Agent": "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"
|
|
36
161
|
}
|
|
37
162
|
}).catch((error) => {
|
|
@@ -40,18 +165,45 @@ export default defineEventHandler(async (event) => {
|
|
|
40
165
|
statusMessage: error.statusMessage || "Failed to fetch Instagram embed"
|
|
41
166
|
});
|
|
42
167
|
});
|
|
168
|
+
const ast = parse(html);
|
|
43
169
|
const cssUrls = [];
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (
|
|
48
|
-
cssUrls.push(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (
|
|
53
|
-
|
|
54
|
-
|
|
170
|
+
walkSync(ast, (node) => {
|
|
171
|
+
if (node.type !== ELEMENT_NODE)
|
|
172
|
+
return;
|
|
173
|
+
if (node.name === "link" && node.attributes.rel === "stylesheet" && node.attributes.href) {
|
|
174
|
+
cssUrls.push(node.attributes.href);
|
|
175
|
+
removeNode(node);
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
if (node.name === "script" || node.name === "noscript" || node.name === "style") {
|
|
179
|
+
removeNode(node);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
for (const attr of ["src", "poster"]) {
|
|
183
|
+
if (node.attributes[attr])
|
|
184
|
+
node.attributes[attr] = rewriteUrl(node.attributes[attr], prefix);
|
|
185
|
+
}
|
|
186
|
+
if (node.attributes.srcset) {
|
|
187
|
+
node.attributes.srcset = node.attributes.srcset.split(",").map((entry) => {
|
|
188
|
+
const parts = entry.trim().split(SRCSET_SPLIT_RE);
|
|
189
|
+
const url = parts[0];
|
|
190
|
+
const descriptor = parts.slice(1).join(" ");
|
|
191
|
+
return url ? `${rewriteUrl(url, prefix)}${descriptor ? ` ${descriptor}` : ""}` : entry;
|
|
192
|
+
}).join(", ");
|
|
193
|
+
}
|
|
194
|
+
if (node.attributes.style)
|
|
195
|
+
node.attributes.style = rewriteUrlsInText(node.attributes.style, prefix);
|
|
196
|
+
});
|
|
197
|
+
walkSync(ast, (node) => {
|
|
198
|
+
if (node.type === TEXT_NODE && node.value)
|
|
199
|
+
node.value = rewriteUrlsInText(node.value, prefix);
|
|
200
|
+
});
|
|
201
|
+
let bodyNode = null;
|
|
202
|
+
walkSync(ast, (node) => {
|
|
203
|
+
if (node.type === ELEMENT_NODE && node.name === "body")
|
|
204
|
+
bodyNode = node;
|
|
205
|
+
});
|
|
206
|
+
const bodyHtml = bodyNode ? bodyNode.children.map((child) => renderSync(child)).join("") : renderSync(ast);
|
|
55
207
|
const cssContents = await Promise.all(
|
|
56
208
|
cssUrls.map(
|
|
57
209
|
(url) => $fetch(url, {
|
|
@@ -61,31 +213,20 @@ export default defineEventHandler(async (event) => {
|
|
|
61
213
|
);
|
|
62
214
|
let combinedCss = cssContents.join("\n");
|
|
63
215
|
combinedCss = combinedCss.replace(
|
|
64
|
-
|
|
65
|
-
(_m, path) => `url(/
|
|
216
|
+
RSRC_RE,
|
|
217
|
+
(_m, path) => `url(${prefix}/embed/instagram-asset?url=${encodeURIComponent(`https://static.cdninstagram.com/rsrc.php${path}`)})`
|
|
66
218
|
);
|
|
219
|
+
combinedCss = rewriteUrlsInText(combinedCss, prefix);
|
|
220
|
+
combinedCss = scopeCss(combinedCss, ".instagram-embed-root");
|
|
67
221
|
const baseStyles = `
|
|
68
|
-
|
|
69
|
-
#splash-screen { display: none !important; }
|
|
70
|
-
.Embed { opacity: 1 !important; visibility: visible !important; }
|
|
71
|
-
.EmbeddedMedia, .EmbeddedMediaImage { display: block !important; visibility: visible !important; }
|
|
222
|
+
.instagram-embed-root { background: white; max-width: 540px; width: calc(100% - 2px); border-radius: 3px; border: 1px solid rgb(219, 219, 219); display: block; margin: 0px 0px 12px; min-width: 326px; padding: 0px; }
|
|
223
|
+
.instagram-embed-root #splash-screen { display: none !important; }
|
|
224
|
+
.instagram-embed-root .Embed { opacity: 1 !important; visibility: visible !important; }
|
|
225
|
+
.instagram-embed-root .EmbeddedMedia, .instagram-embed-root .EmbeddedMediaImage { display: block !important; visibility: visible !important; }
|
|
72
226
|
`;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
(m) => `/api/_scripts/instagram-embed-image?url=${encodeURIComponent(m.replace(/&/g, "&"))}`
|
|
76
|
-
).replace(
|
|
77
|
-
/https:\/\/static\.cdninstagram\.com[^"'\s),]+/g,
|
|
78
|
-
(m) => `/api/_scripts/instagram-embed-asset?url=${encodeURIComponent(m.replace(/&/g, "&"))}`
|
|
79
|
-
).replace(
|
|
80
|
-
/https:\/\/lookaside\.instagram\.com[^"'\s),]+/g,
|
|
81
|
-
(m) => `/api/_scripts/instagram-embed-image?url=${encodeURIComponent(m.replace(/&/g, "&"))}`
|
|
82
|
-
);
|
|
83
|
-
rewrittenHtml = rewrittenHtml.replace(
|
|
84
|
-
"</head>",
|
|
85
|
-
`<style>${baseStyles}
|
|
86
|
-
${combinedCss}</style></head>`
|
|
87
|
-
);
|
|
227
|
+
const result = `<div class="instagram-embed-root"><style>${baseStyles}
|
|
228
|
+
${combinedCss}</style>${bodyHtml}</div>`;
|
|
88
229
|
setHeader(event, "Content-Type", "text/html");
|
|
89
230
|
setHeader(event, "Cache-Control", "public, max-age=600, s-maxage=600");
|
|
90
|
-
return
|
|
231
|
+
return result;
|
|
91
232
|
});
|