@wix/astro 2.27.0 → 2.28.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/build/dependencies/astro-auth/backend-runtime/constants-Dbkf3D5f.mjs +6 -0
- package/build/dependencies/astro-auth/backend-runtime/elevatedContextualClient-tJx9dIn_.mjs +41 -0
- package/build/dependencies/astro-auth/backend-runtime/host-utils-B2Fs_Z4S.mjs +17 -0
- package/build/dependencies/astro-auth/backend-runtime/middleware/auth.d.mts +6 -0
- package/build/dependencies/astro-auth/backend-runtime/middleware/auth.mjs +3643 -0
- package/build/dependencies/astro-auth/backend-runtime/middleware/localization.d.mts +6 -0
- package/build/dependencies/astro-auth/backend-runtime/middleware/localization.mjs +193 -0
- package/build/dependencies/astro-auth/backend-runtime/routes/callback.d.mts +6 -0
- package/build/dependencies/astro-auth/backend-runtime/routes/callback.mjs +34 -0
- package/build/dependencies/astro-auth/backend-runtime/routes/login.d.mts +6 -0
- package/build/dependencies/astro-auth/backend-runtime/routes/login.mjs +32 -0
- package/build/dependencies/astro-auth/backend-runtime/routes/logout-callback.d.mts +6 -0
- package/build/dependencies/astro-auth/backend-runtime/routes/logout-callback.mjs +14 -0
- package/build/dependencies/astro-auth/backend-runtime/routes/logout.d.mts +6 -0
- package/build/dependencies/astro-auth/backend-runtime/routes/logout.mjs +19 -0
- package/build/dependencies/astro-auth/backend-runtime/runtime/backend/setupContextualClient.d.mts +1 -0
- package/build/dependencies/astro-auth/backend-runtime/runtime/backend/setupContextualClient.mjs +8 -0
- package/build/dependencies/astro-auth/backend-runtime/saveSessionTokensToCookie-DK3xvtzk.mjs +24 -0
- package/build/dependencies/astro-auth/backend-runtime/schemas-XrMhpOYn.mjs +2771 -0
- package/build/dependencies/astro-auth/browser-runtime/setup.d.ts +4 -3
- package/build/dependencies/astro-auth/browser-runtime/setup.js +55 -81
- package/build/dependencies/astro-backend-extensions/backend-runtime/routes/extensions.d.mts +6 -0
- package/build/dependencies/astro-backend-extensions/backend-runtime/routes/extensions.mjs +37 -0
- package/build/dependencies/astro-backend-extensions/backend-runtime/runtime/setupServicePlugin.d.mts +10 -0
- package/build/dependencies/astro-backend-extensions/backend-runtime/runtime/setupServicePlugin.mjs +22 -0
- package/build/dependencies/astro-backend-extensions/backend-runtime/runtime/setupWebhook.d.mts +9 -0
- package/build/dependencies/astro-backend-extensions/backend-runtime/runtime/setupWebhook.mjs +22 -0
- package/build/dependencies/astro-backend-extensions/backend-runtime/utils-DDHGZHjR.mjs +56 -0
- package/build/dependencies/astro-backend-extensions/backend-runtime/utils-mYlwmIjd.d.mts +6 -0
- package/build/dependencies/astro-backoffice-extensions/browser-runtime/wrapComponent.d.ts +4 -3
- package/build/dependencies/astro-backoffice-extensions/browser-runtime/wrapComponent.js +6 -5
- package/build/dependencies/astro-context-providers-extensions/browser-runtime/hmr.d.ts +10 -0
- package/build/dependencies/astro-context-providers-extensions/browser-runtime/hmr.js +20 -23
- package/build/dependencies/astro-context-providers-extensions/browser-runtime/sdk.d.ts +9 -0
- package/build/dependencies/astro-context-providers-extensions/browser-runtime/sdk.js +16 -15
- package/build/dependencies/astro-custom-elements-extensions/browser-runtime/customElementHmr.d.ts +9 -5
- package/build/dependencies/astro-custom-elements-extensions/browser-runtime/customElementHmr.js +23 -40
- package/build/dependencies/astro-custom-elements-extensions/browser-runtime/reactHmr.d.ts +10 -1
- package/build/dependencies/astro-custom-elements-extensions/browser-runtime/reactHmr.js +20 -23
- package/build/dependencies/astro-custom-elements-extensions/browser-runtime/renderSettingsPanel.d.ts +4 -3
- package/build/dependencies/astro-custom-elements-extensions/browser-runtime/renderSettingsPanel.js +14 -18
- package/build/dependencies/astro-custom-elements-extensions/browser-runtime/wrapCustomElement.d.ts +9 -5
- package/build/dependencies/astro-custom-elements-extensions/browser-runtime/wrapCustomElement.js +23 -25
- package/build/dependencies/astro-embedded-scripts-extensions/browser-runtime/setupContext.d.ts +8 -4
- package/build/dependencies/astro-embedded-scripts-extensions/browser-runtime/setupContext.js +18 -17
- package/build/dependencies/astro-function-libraries-extensions/browser-runtime/sdk.d.ts +9 -0
- package/build/dependencies/astro-function-libraries-extensions/browser-runtime/sdk.js +16 -15
- package/build/dependencies/astro-html-embeds/backend-runtime/html-embeds.d.mts +6 -0
- package/build/dependencies/astro-html-embeds/backend-runtime/html-embeds.mjs +53 -0
- package/build/dependencies/astro-monitor/backend-runtime/monitor.d.mts +6 -0
- package/build/dependencies/astro-monitor/backend-runtime/monitor.mjs +43 -0
- package/build/dependencies/astro-payment-links/backend-runtime/elevate-CDDLuCIf.mjs +9 -0
- package/build/dependencies/astro-payment-links/backend-runtime/payment-checkout.d.mts +6 -0
- package/build/dependencies/astro-payment-links/backend-runtime/payment-checkout.mjs +20 -0
- package/build/dependencies/astro-payment-links/backend-runtime/payment-link.d.mts +6 -0
- package/build/dependencies/astro-payment-links/backend-runtime/payment-link.mjs +15 -0
- package/build/dependencies/astro-payment-links/backend-runtime/proposal.d.mts +6 -0
- package/build/dependencies/astro-payment-links/backend-runtime/proposal.mjs +20 -0
- package/build/dependencies/astro-robots/backend-runtime/robots.d.mts +6 -0
- package/build/dependencies/astro-robots/backend-runtime/robots.mjs +26 -0
- package/build/dependencies/astro-site-component-panels-extensions/browser-runtime/hmr.d.ts +10 -0
- package/build/dependencies/astro-site-component-panels-extensions/browser-runtime/hmr.js +20 -23
- package/build/dependencies/astro-site-component-panels-extensions/browser-runtime/sdk.d.ts +12 -0
- package/build/dependencies/astro-site-component-panels-extensions/browser-runtime/sdk.js +10 -10
- package/build/dependencies/astro-site-components-extensions/browser-runtime/hmr.d.ts +10 -0
- package/build/dependencies/astro-site-components-extensions/browser-runtime/hmr.js +20 -23
- package/build/dependencies/astro-site-components-extensions/browser-runtime/sdk.d.ts +9 -0
- package/build/dependencies/astro-site-components-extensions/browser-runtime/sdk.js +16 -15
- package/build/dependencies/astro-translations/backend-runtime/middleware/static-translations.d.mts +6 -0
- package/build/dependencies/astro-translations/backend-runtime/middleware/static-translations.mjs +177 -0
- package/build/dependencies/astro-translations/backend-runtime/runtime/{i18n.d.ts → i18n.d.mts} +3 -2
- package/build/dependencies/astro-translations/backend-runtime/runtime/i18n.mjs +38 -0
- package/build/dependencies/astro-translations/integration/index.d.mts +105 -0
- package/build/dependencies/astro-translations/integration/index.mjs +264 -0
- package/build/dependencies/astro-trusted-backoffice-extensions/browser-runtime/hmr.d.ts +10 -1
- package/build/dependencies/astro-trusted-backoffice-extensions/browser-runtime/hmr.js +20 -23
- package/build/dependencies/astro-trusted-backoffice-extensions/browser-runtime/wrapComponent.d.ts +12 -8
- package/build/dependencies/astro-trusted-backoffice-extensions/browser-runtime/wrapComponent.js +25 -35
- package/build/dependencies/astro-viewer-api/backend-runtime/api.d.mts +6 -0
- package/build/dependencies/astro-viewer-api/backend-runtime/api.mjs +27 -0
- package/build/dependencies/astro-viewer-services-extensions/browser-runtime/sdk.d.ts +9 -0
- package/build/dependencies/astro-viewer-services-extensions/browser-runtime/sdk.js +16 -15
- package/build/integration/builders-B9yQdgSz.mjs +76 -0
- package/build/integration/builders-DP0350YQ.d.mts +121 -0
- package/build/integration/builders-DVfxT6EC.mjs +225 -0
- package/build/integration/builders-experimental.d.mts +56 -0
- package/build/integration/builders-experimental.mjs +26 -0
- package/build/integration/builders-trusted.d.mts +75 -0
- package/build/integration/builders-trusted.mjs +46 -0
- package/build/integration/builders.d.mts +4 -0
- package/build/integration/builders.mjs +4 -0
- package/build/integration/index-B3B_5bgh.d.mts +248 -0
- package/build/integration/index-D5k6Bmue.d.mts +32 -0
- package/build/integration/index.d.mts +35 -0
- package/build/integration/index.mjs +29236 -0
- package/package.json +12 -12
- package/build/dependencies/astro-auth/backend-runtime/chunk-24J7STEA.js +0 -8
- package/build/dependencies/astro-auth/backend-runtime/chunk-352W54SQ.js +0 -70
- package/build/dependencies/astro-auth/backend-runtime/chunk-BIARYLOZ.js +0 -3267
- package/build/dependencies/astro-auth/backend-runtime/chunk-DZHZMKUF.js +0 -26
- package/build/dependencies/astro-auth/backend-runtime/chunk-MLKGABMK.js +0 -9
- package/build/dependencies/astro-auth/backend-runtime/chunk-USQSPPTM.js +0 -14
- package/build/dependencies/astro-auth/backend-runtime/middleware/auth.d.ts +0 -5
- package/build/dependencies/astro-auth/backend-runtime/middleware/auth.js +0 -136
- package/build/dependencies/astro-auth/backend-runtime/middleware/localization.d.ts +0 -5
- package/build/dependencies/astro-auth/backend-runtime/middleware/localization.js +0 -219
- package/build/dependencies/astro-auth/backend-runtime/routes/callback.d.ts +0 -5
- package/build/dependencies/astro-auth/backend-runtime/routes/callback.js +0 -53
- package/build/dependencies/astro-auth/backend-runtime/routes/login.d.ts +0 -5
- package/build/dependencies/astro-auth/backend-runtime/routes/login.js +0 -46
- package/build/dependencies/astro-auth/backend-runtime/routes/logout-callback.d.ts +0 -5
- package/build/dependencies/astro-auth/backend-runtime/routes/logout-callback.js +0 -24
- package/build/dependencies/astro-auth/backend-runtime/routes/logout.d.ts +0 -5
- package/build/dependencies/astro-auth/backend-runtime/routes/logout.js +0 -33
- package/build/dependencies/astro-auth/backend-runtime/runtime/backend/setupContextualClient.d.ts +0 -2
- package/build/dependencies/astro-auth/backend-runtime/runtime/backend/setupContextualClient.js +0 -10
- package/build/dependencies/astro-backend-extensions/backend-runtime/chunk-CPGTXQVH.js +0 -75
- package/build/dependencies/astro-backend-extensions/backend-runtime/routes/extensions.d.ts +0 -5
- package/build/dependencies/astro-backend-extensions/backend-runtime/routes/extensions.js +0 -41
- package/build/dependencies/astro-backend-extensions/backend-runtime/runtime/setupServicePlugin.d.ts +0 -10
- package/build/dependencies/astro-backend-extensions/backend-runtime/runtime/setupServicePlugin.js +0 -35
- package/build/dependencies/astro-backend-extensions/backend-runtime/runtime/setupWebhook.d.ts +0 -9
- package/build/dependencies/astro-backend-extensions/backend-runtime/runtime/setupWebhook.js +0 -34
- package/build/dependencies/astro-backend-extensions/backend-runtime/utils-B7jr2PES.d.ts +0 -5
- package/build/dependencies/astro-backend-extensions/types/index.d.ts +0 -102
- package/build/dependencies/astro-backoffice-extensions/types/index.d.ts +0 -68
- package/build/dependencies/astro-context-providers-extensions/types/index.d.ts +0 -32
- package/build/dependencies/astro-core/types/index.d.ts +0 -109
- package/build/dependencies/astro-custom-elements-extensions/types/index.d.ts +0 -45
- package/build/dependencies/astro-embedded-scripts-extensions/types/index.d.ts +0 -18
- package/build/dependencies/astro-function-libraries-extensions/types/index.d.ts +0 -23
- package/build/dependencies/astro-html-embeds/backend-runtime/html-embeds.d.ts +0 -5
- package/build/dependencies/astro-html-embeds/backend-runtime/html-embeds.js +0 -66
- package/build/dependencies/astro-payment-links/backend-runtime/chunk-656BVIJ3.js +0 -9
- package/build/dependencies/astro-payment-links/backend-runtime/payment-checkout.d.ts +0 -5
- package/build/dependencies/astro-payment-links/backend-runtime/payment-checkout.js +0 -24
- package/build/dependencies/astro-payment-links/backend-runtime/payment-link.d.ts +0 -5
- package/build/dependencies/astro-payment-links/backend-runtime/payment-link.js +0 -20
- package/build/dependencies/astro-payment-links/backend-runtime/proposal.d.ts +0 -5
- package/build/dependencies/astro-payment-links/backend-runtime/proposal.js +0 -24
- package/build/dependencies/astro-robots/backend-runtime/robots.d.ts +0 -5
- package/build/dependencies/astro-robots/backend-runtime/robots.js +0 -38
- package/build/dependencies/astro-site-component-panels-extensions/types/index.d.ts +0 -21
- package/build/dependencies/astro-site-components-extensions/types/index.d.ts +0 -48
- package/build/dependencies/astro-translations/backend-runtime/middleware/static-translations.d.ts +0 -5
- package/build/dependencies/astro-translations/backend-runtime/middleware/static-translations.js +0 -189
- package/build/dependencies/astro-translations/backend-runtime/runtime/i18n.js +0 -42
- package/build/dependencies/astro-translations/integration/index.d.ts +0 -5
- package/build/dependencies/astro-translations/integration/index.js +0 -296
- package/build/dependencies/astro-trusted-backoffice-extensions/types/index.d.ts +0 -50
- package/build/dependencies/astro-viewer-api/backend-runtime/api.d.ts +0 -5
- package/build/dependencies/astro-viewer-api/backend-runtime/api.js +0 -34
- package/build/dependencies/astro-viewer-services-extensions/types/index.d.ts +0 -27
- package/build/integration/builders-experimental.d.ts +0 -53
- package/build/integration/builders-experimental.js +0 -20
- package/build/integration/builders-experimental.js.map +0 -1
- package/build/integration/builders-trusted.d.ts +0 -69
- package/build/integration/builders-trusted.js +0 -52
- package/build/integration/builders-trusted.js.map +0 -1
- package/build/integration/builders.d.ts +0 -112
- package/build/integration/builders.js +0 -14
- package/build/integration/builders.js.map +0 -1
- package/build/integration/chunk-23MOLCVI.js +0 -1087
- package/build/integration/chunk-23MOLCVI.js.map +0 -1
- package/build/integration/chunk-6UOFHB2M.js +0 -386
- package/build/integration/chunk-6UOFHB2M.js.map +0 -1
- package/build/integration/chunk-L6JEDTVM.js +0 -7458
- package/build/integration/chunk-L6JEDTVM.js.map +0 -1
- package/build/integration/chunk-MNQWQ2MC.js +0 -809
- package/build/integration/chunk-MNQWQ2MC.js.map +0 -1
- package/build/integration/chunk-XN6SBNMI.js +0 -23758
- package/build/integration/chunk-XN6SBNMI.js.map +0 -1
- package/build/integration/index.d-BUVlSCHa.d.ts +0 -211
- package/build/integration/index.d-D4c48TR0.d.ts +0 -58
- package/build/integration/index.d.ts +0 -34
- package/build/integration/index.js +0 -498
- package/build/integration/index.js.map +0 -1
|
@@ -1,97 +1,71 @@
|
|
|
1
|
-
// src/runtime/client/setup.ts
|
|
2
1
|
import { resolveContext } from "@wix/sdk-runtime/context";
|
|
3
|
-
|
|
4
|
-
// src/runtime/client/utils.ts
|
|
5
2
|
import { headlessSite } from "@wix/headless-site";
|
|
6
|
-
import {
|
|
3
|
+
import { EMPTY_TOKENS, OAuthStrategy, createClient } from "@wix/sdk";
|
|
7
4
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
5
|
+
//#region src/utils/sessionCookie.ts
|
|
6
|
+
const SESSION_COOKIE_NAME = "wixSession";
|
|
7
|
+
const SESSION_COOKIE_OPTIONS = {
|
|
8
|
+
path: "/",
|
|
9
|
+
secure: true,
|
|
10
|
+
...import.meta.env.DEV && {
|
|
11
|
+
maxAge: 10800,
|
|
12
|
+
sameSite: "none"
|
|
13
|
+
}
|
|
17
14
|
};
|
|
18
15
|
|
|
19
|
-
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/runtime/client/utils.ts
|
|
20
18
|
function getSessionClient(options) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
});
|
|
19
|
+
return createClient({
|
|
20
|
+
auth: OAuthStrategy({
|
|
21
|
+
tokenStorage: {
|
|
22
|
+
getTokens: () => getCookieAsJson(SESSION_COOKIE_NAME)?.tokens ?? EMPTY_TOKENS,
|
|
23
|
+
setTokens: (tokens) => {
|
|
24
|
+
document.cookie = buildSessionCookieString(options.clientId, tokens);
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
...options
|
|
28
|
+
}),
|
|
29
|
+
host: headlessSite.host({})
|
|
30
|
+
});
|
|
34
31
|
}
|
|
35
32
|
function buildSessionCookieString(clientId, tokens) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
if (SESSION_COOKIE_OPTIONS.maxAge != null) {
|
|
44
|
-
cookie += ` max-age=${SESSION_COOKIE_OPTIONS.maxAge}`;
|
|
45
|
-
}
|
|
46
|
-
return cookie;
|
|
33
|
+
let cookie = `${SESSION_COOKIE_NAME}=${encodeURIComponent(JSON.stringify({
|
|
34
|
+
clientId,
|
|
35
|
+
tokens
|
|
36
|
+
}))}; path=${SESSION_COOKIE_OPTIONS.path}; ${SESSION_COOKIE_OPTIONS.secure ? "secure;" : ""}`;
|
|
37
|
+
if (SESSION_COOKIE_OPTIONS.sameSite != null) cookie += ` samesite=${SESSION_COOKIE_OPTIONS.sameSite};`;
|
|
38
|
+
if (SESSION_COOKIE_OPTIONS.maxAge != null) cookie += ` max-age=${SESSION_COOKIE_OPTIONS.maxAge}`;
|
|
39
|
+
return cookie;
|
|
47
40
|
}
|
|
48
41
|
function getCookieAsJson(name) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
throw new Error("Invalid cookie value");
|
|
61
|
-
} catch {
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
42
|
+
const cookie = document.cookie.split("; ").find((row) => row.startsWith(`${name}=`));
|
|
43
|
+
if (cookie == null) return null;
|
|
44
|
+
try {
|
|
45
|
+
const jsonString = decodeURIComponent(cookie.split("=")[1] ?? "");
|
|
46
|
+
const cookieValue = JSON.parse(jsonString);
|
|
47
|
+
if (isCookieValue(cookieValue)) return cookieValue;
|
|
48
|
+
throw new Error("Invalid cookie value");
|
|
49
|
+
} catch {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
64
52
|
}
|
|
65
53
|
function isCookieValue(value) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
return false;
|
|
74
|
-
}
|
|
75
|
-
const tokens = value.tokens;
|
|
76
|
-
if (tokens == null || typeof tokens !== "object") {
|
|
77
|
-
return false;
|
|
78
|
-
}
|
|
79
|
-
if (!("accessToken" in tokens) || !("refreshToken" in tokens)) {
|
|
80
|
-
return false;
|
|
81
|
-
}
|
|
82
|
-
return true;
|
|
54
|
+
if (value == null || typeof value !== "object") return false;
|
|
55
|
+
if (!("clientId" in value) || typeof value.clientId !== "string") return false;
|
|
56
|
+
if (!("tokens" in value)) return false;
|
|
57
|
+
const tokens = value.tokens;
|
|
58
|
+
if (tokens == null || typeof tokens !== "object") return false;
|
|
59
|
+
if (!("accessToken" in tokens) || !("refreshToken" in tokens)) return false;
|
|
60
|
+
return true;
|
|
83
61
|
}
|
|
84
62
|
|
|
85
|
-
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region src/runtime/client/setup.ts
|
|
86
65
|
function setup(options) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
if (!location.pathname.startsWith("/_wix/extensions/backoffice")) {
|
|
92
|
-
getSessionClient(options).enableContext("global");
|
|
93
|
-
}
|
|
66
|
+
if (resolveContext() != null) return;
|
|
67
|
+
if (!location.pathname.startsWith("/_wix/extensions/backoffice")) getSessionClient(options).enableContext("global");
|
|
94
68
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
};
|
|
69
|
+
|
|
70
|
+
//#endregion
|
|
71
|
+
export { setup };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { WIX_CLIENT_PUBLIC_KEY, WIX_CLIENT_SECRET } from "astro:env/server";
|
|
2
|
+
|
|
3
|
+
//#region src/routes/extensions.ts
|
|
4
|
+
const authOptions = {
|
|
5
|
+
appSecret: WIX_CLIENT_SECRET,
|
|
6
|
+
publicKey: WIX_CLIENT_PUBLIC_KEY
|
|
7
|
+
};
|
|
8
|
+
const runExtension = await createServeExtensionRunner();
|
|
9
|
+
const ALL = async (context) => {
|
|
10
|
+
const componentId = context.params.id;
|
|
11
|
+
if (componentId == null) return new Response(null, { status: 404 });
|
|
12
|
+
try {
|
|
13
|
+
return await runExtension({
|
|
14
|
+
componentId,
|
|
15
|
+
payload: await context.request.text(),
|
|
16
|
+
url: context.request.url
|
|
17
|
+
});
|
|
18
|
+
} catch (error) {
|
|
19
|
+
return Response.json(error, { status: 500 });
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
async function createServeExtensionRunner() {
|
|
23
|
+
const { entries } = await import("@virtual/wix-backend-entries");
|
|
24
|
+
return async ({ componentId, payload, url }) => {
|
|
25
|
+
const loadModule = entries[componentId];
|
|
26
|
+
if (loadModule == null) return new Response(null, { status: 404 });
|
|
27
|
+
const result = await (await loadModule()).default({
|
|
28
|
+
authOptions,
|
|
29
|
+
payload,
|
|
30
|
+
url
|
|
31
|
+
});
|
|
32
|
+
return Response.json(result ?? null);
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
export { ALL };
|
package/build/dependencies/astro-backend-extensions/backend-runtime/runtime/setupServicePlugin.d.mts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { t as AppStrategyOptions } from "../utils-mYlwmIjd.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/runtime/setupServicePlugin.d.ts
|
|
4
|
+
declare function setupServicePlugin(fn: () => Promise<unknown>): Promise<(options: {
|
|
5
|
+
authOptions: AppStrategyOptions;
|
|
6
|
+
payload: string;
|
|
7
|
+
url: string;
|
|
8
|
+
}) => Promise<unknown>>;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { setupServicePlugin };
|
package/build/dependencies/astro-backend-extensions/backend-runtime/runtime/setupServicePlugin.mjs
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { a as contextualClient, i as authAsyncLocalStorage, n as setupClient, r as elevatedContextualClient, t as createAppStrategy } from "../utils-DDHGZHjR.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/runtime/setupServicePlugin.ts
|
|
4
|
+
contextualClient.enableContext("module");
|
|
5
|
+
elevatedContextualClient.enableContext("module", { elevated: true });
|
|
6
|
+
async function setupServicePlugin(fn) {
|
|
7
|
+
const { client, setAuthOptions } = await setupClient(fn);
|
|
8
|
+
return async function({ authOptions, payload, url }) {
|
|
9
|
+
setAuthOptions(authOptions);
|
|
10
|
+
const processedRequest = await client.servicePlugins.parseJWT(payload);
|
|
11
|
+
return authAsyncLocalStorage.run({
|
|
12
|
+
auth: null,
|
|
13
|
+
elevatedAuth: createAppStrategy({
|
|
14
|
+
instanceId: processedRequest.metadata.instanceId,
|
|
15
|
+
...authOptions
|
|
16
|
+
})
|
|
17
|
+
}, async () => client.servicePlugins.executeHandler(processedRequest, url));
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
export { setupServicePlugin };
|
package/build/dependencies/astro-backend-extensions/backend-runtime/runtime/setupWebhook.d.mts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { t as AppStrategyOptions } from "../utils-mYlwmIjd.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/runtime/setupWebhook.d.ts
|
|
4
|
+
declare function setupWebhook(fn: () => Promise<unknown>): Promise<(options: {
|
|
5
|
+
authOptions: AppStrategyOptions;
|
|
6
|
+
payload: string;
|
|
7
|
+
}) => Promise<unknown>>;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { setupWebhook };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { a as contextualClient, i as authAsyncLocalStorage, n as setupClient, r as elevatedContextualClient, t as createAppStrategy } from "../utils-DDHGZHjR.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/runtime/setupWebhook.ts
|
|
4
|
+
contextualClient.enableContext("module");
|
|
5
|
+
elevatedContextualClient.enableContext("module", { elevated: true });
|
|
6
|
+
async function setupWebhook(fn) {
|
|
7
|
+
const { client, setAuthOptions } = await setupClient(fn);
|
|
8
|
+
return async function({ authOptions, payload }) {
|
|
9
|
+
setAuthOptions(authOptions);
|
|
10
|
+
const processedRequest = await client.webhooks.parseJWT(payload);
|
|
11
|
+
return authAsyncLocalStorage.run({
|
|
12
|
+
auth: null,
|
|
13
|
+
elevatedAuth: createAppStrategy({
|
|
14
|
+
instanceId: processedRequest.instanceId,
|
|
15
|
+
...authOptions
|
|
16
|
+
})
|
|
17
|
+
}, async () => client.webhooks.executeHandlers(processedRequest));
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
export { setupWebhook };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { AppStrategy, createClient } from "@wix/sdk";
|
|
2
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
3
|
+
import { wixContext } from "@wix/sdk-context";
|
|
4
|
+
|
|
5
|
+
//#region src/runtime/contextualClient.ts
|
|
6
|
+
const elevateNeededError = /* @__PURE__ */ new Error("Contextual client is not available for events and service plugins, please use elevate() instead.");
|
|
7
|
+
const contextualClient = createClient({ auth: {
|
|
8
|
+
getActiveToken: () => {
|
|
9
|
+
throw elevateNeededError;
|
|
10
|
+
},
|
|
11
|
+
getAuthHeaders: async () => {
|
|
12
|
+
throw elevateNeededError;
|
|
13
|
+
}
|
|
14
|
+
} });
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/runtime/authAsyncLocalStorage.ts
|
|
18
|
+
const authAsyncLocalStorage = new AsyncLocalStorage();
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/runtime/elevatedContextualClient.ts
|
|
22
|
+
const elevatedContextualClient = createClient({ auth: { getAuthHeaders: async (host) => {
|
|
23
|
+
const store = authAsyncLocalStorage.getStore();
|
|
24
|
+
if (!store) throw new Error("Cannot find an authentication strategy");
|
|
25
|
+
if (store.elevatedAuth) return store.elevatedAuth.getAuthHeaders(host);
|
|
26
|
+
throw new Error("Cannot find an elevated authentication strategy");
|
|
27
|
+
} } });
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/runtime/utils.ts
|
|
31
|
+
function createAppStrategy(opts = {}) {
|
|
32
|
+
return AppStrategy({
|
|
33
|
+
...opts,
|
|
34
|
+
appId: import.meta.env.WIX_CLIENT_ID
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
async function setupClient(fn) {
|
|
38
|
+
let authOptions = {};
|
|
39
|
+
const client = createClient({ auth: () => AppStrategy({
|
|
40
|
+
appId: import.meta.env.WIX_CLIENT_ID,
|
|
41
|
+
...authOptions
|
|
42
|
+
}) });
|
|
43
|
+
const olderClient = wixContext.client;
|
|
44
|
+
client.enableContext("module");
|
|
45
|
+
await fn();
|
|
46
|
+
if (olderClient) olderClient.enableContext("module");
|
|
47
|
+
return {
|
|
48
|
+
client,
|
|
49
|
+
setAuthOptions: (options) => {
|
|
50
|
+
authOptions = options;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
//#endregion
|
|
56
|
+
export { contextualClient as a, authAsyncLocalStorage as i, setupClient as n, elevatedContextualClient as r, createAppStrategy as t };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { ComponentType } from
|
|
1
|
+
import { ComponentType } from "react";
|
|
2
2
|
|
|
3
|
+
//#region src/runtime/wrapComponent.d.ts
|
|
3
4
|
declare function wrapComponent(component: ComponentType): ComponentType;
|
|
4
|
-
|
|
5
|
-
export { wrapComponent };
|
|
5
|
+
//#endregion
|
|
6
|
+
export { wrapComponent };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
// src/runtime/wrapComponent.ts
|
|
2
1
|
import { withContextualWixClient } from "@wix/dashboard/internal";
|
|
2
|
+
|
|
3
|
+
//#region src/runtime/wrapComponent.ts
|
|
3
4
|
function wrapComponent(component) {
|
|
4
|
-
|
|
5
|
+
return withContextualWixClient(component);
|
|
5
6
|
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
export { wrapComponent };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ComponentType } from "react";
|
|
2
|
+
|
|
3
|
+
//#region ../astro-browser-runtime/src/hmr/react-component.d.ts
|
|
4
|
+
interface HotData {
|
|
5
|
+
Component?: ComponentType;
|
|
6
|
+
setComponent?: (NewComponent: ComponentType) => void;
|
|
7
|
+
}
|
|
8
|
+
declare function createComponentHmrWrapper(OriginalComponent: ComponentType, hotData: HotData): ComponentType;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { createComponentHmrWrapper };
|
|
@@ -1,26 +1,23 @@
|
|
|
1
|
-
// ../astro-browser-runtime/src/hmr/react-component.tsx
|
|
2
1
|
import React, { useEffect, useRef, useState } from "react";
|
|
2
|
+
|
|
3
|
+
//#region ../astro-browser-runtime/src/hmr/react-component.tsx
|
|
3
4
|
function createComponentHmrWrapper(OriginalComponent, hotData) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
};
|
|
20
|
-
}, []);
|
|
21
|
-
return /* @__PURE__ */ React.createElement(WrappedComponent, { ...props });
|
|
22
|
-
};
|
|
5
|
+
return (props) => {
|
|
6
|
+
const [WrappedComponent, setComponent] = useState(() => hotData.Component ?? OriginalComponent);
|
|
7
|
+
const isMountedRef = useRef(false);
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
isMountedRef.current = true;
|
|
10
|
+
hotData.setComponent = (NewComponent) => {
|
|
11
|
+
hotData.Component = NewComponent;
|
|
12
|
+
if (isMountedRef.current) setComponent(() => NewComponent);
|
|
13
|
+
};
|
|
14
|
+
return () => {
|
|
15
|
+
isMountedRef.current = false;
|
|
16
|
+
};
|
|
17
|
+
}, []);
|
|
18
|
+
return /* @__PURE__ */ React.createElement(WrappedComponent, props);
|
|
19
|
+
};
|
|
23
20
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
};
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
export { createComponentHmrWrapper };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AccessTokenFn } from "@wix/site";
|
|
2
|
+
|
|
3
|
+
//#region ../astro-browser-runtime/src/sdk/site.d.ts
|
|
4
|
+
type AccessTokenInjector = (getAccessTokenFn: AccessTokenFn) => void;
|
|
5
|
+
//#endregion
|
|
6
|
+
//#region src/runtime/sdk.d.ts
|
|
7
|
+
declare function createContext(): AccessTokenInjector;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { createContext };
|
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
// ../astro-browser-runtime/src/sdk/site.ts
|
|
2
1
|
import { createClient } from "@wix/sdk";
|
|
3
2
|
import { site } from "@wix/site";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
3
|
+
|
|
4
|
+
//#region ../astro-browser-runtime/src/sdk/site.ts
|
|
5
|
+
const enableClient = (applicationId) => {
|
|
6
|
+
const host = site.host({ applicationId });
|
|
7
|
+
const auth = site.auth();
|
|
8
|
+
createClient({
|
|
9
|
+
auth,
|
|
10
|
+
host
|
|
11
|
+
}).enableContext("module");
|
|
12
|
+
return auth.getAccessTokenInjector();
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/runtime/sdk.ts
|
|
16
17
|
function createContext() {
|
|
17
|
-
|
|
18
|
+
return enableClient(import.meta.env.WIX_CLIENT_ID);
|
|
18
19
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
};
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
export { createContext };
|
package/build/dependencies/astro-custom-elements-extensions/browser-runtime/customElementHmr.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
//#region src/runtime/customElementHmr.d.ts
|
|
2
|
+
declare function customElementHmr({
|
|
3
|
+
customElement,
|
|
4
|
+
tagName
|
|
5
|
+
}: {
|
|
6
|
+
customElement: CustomElementConstructor;
|
|
7
|
+
tagName: string;
|
|
4
8
|
}): void;
|
|
5
|
-
|
|
6
|
-
export { customElementHmr };
|
|
9
|
+
//#endregion
|
|
10
|
+
export { customElementHmr };
|
package/build/dependencies/astro-custom-elements-extensions/browser-runtime/customElementHmr.js
CHANGED
|
@@ -1,46 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
function customElementHmr({
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
node.disconnectedCallback.apply(node);
|
|
9
|
-
}
|
|
10
|
-
applyCustomElementHmr(node, customElement);
|
|
11
|
-
if ("connectedCallback" in node && typeof node.connectedCallback === "function") {
|
|
12
|
-
node.connectedCallback.apply(node);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
1
|
+
//#region src/runtime/customElementHmr.ts
|
|
2
|
+
function customElementHmr({ customElement, tagName }) {
|
|
3
|
+
for (const node of document.querySelectorAll(tagName)) {
|
|
4
|
+
if ("disconnectedCallback" in node && typeof node.disconnectedCallback === "function") node.disconnectedCallback.apply(node);
|
|
5
|
+
applyCustomElementHmr(node, customElement);
|
|
6
|
+
if ("connectedCallback" in node && typeof node.connectedCallback === "function") node.connectedCallback.apply(node);
|
|
7
|
+
}
|
|
15
8
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
);
|
|
20
|
-
for (const [name, descriptor] of Object.entries(prototypeDescriptors)) {
|
|
21
|
-
Object.defineProperty(elementNode, name, descriptor);
|
|
22
|
-
}
|
|
9
|
+
const replaceMethodsOnElement = (elementNode, newClass) => {
|
|
10
|
+
const prototypeDescriptors = Object.getOwnPropertyDescriptors(newClass.prototype);
|
|
11
|
+
for (const [name, descriptor] of Object.entries(prototypeDescriptors)) Object.defineProperty(elementNode, name, descriptor);
|
|
23
12
|
};
|
|
24
13
|
function applyCustomElementHmr(elementNode, NewElementClass) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
14
|
+
visitPrototypeChain(NewElementClass, (classInheritance) => {
|
|
15
|
+
replaceMethodsOnElement(elementNode, classInheritance);
|
|
16
|
+
});
|
|
28
17
|
}
|
|
29
18
|
function visitPrototypeChain(rootClass, visitFn) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
currentClass
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
for (const classForVisiting of inheritanceArray) {
|
|
41
|
-
visitFn(classForVisiting);
|
|
42
|
-
}
|
|
19
|
+
const inheritanceArray = [rootClass];
|
|
20
|
+
let currentClass = Object.getPrototypeOf(rootClass);
|
|
21
|
+
while (currentClass !== HTMLElement) {
|
|
22
|
+
inheritanceArray.unshift(currentClass);
|
|
23
|
+
currentClass = Object.getPrototypeOf(currentClass);
|
|
24
|
+
}
|
|
25
|
+
for (const classForVisiting of inheritanceArray) visitFn(classForVisiting);
|
|
43
26
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
};
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
export { customElementHmr };
|
|
@@ -1 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import { ComponentType } from "react";
|
|
2
|
+
|
|
3
|
+
//#region ../astro-browser-runtime/src/hmr/react-component.d.ts
|
|
4
|
+
interface HotData {
|
|
5
|
+
Component?: ComponentType;
|
|
6
|
+
setComponent?: (NewComponent: ComponentType) => void;
|
|
7
|
+
}
|
|
8
|
+
declare function createComponentHmrWrapper(OriginalComponent: ComponentType, hotData: HotData): ComponentType;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { createComponentHmrWrapper };
|
|
@@ -1,26 +1,23 @@
|
|
|
1
|
-
// ../astro-browser-runtime/src/hmr/react-component.tsx
|
|
2
1
|
import React, { useEffect, useRef, useState } from "react";
|
|
2
|
+
|
|
3
|
+
//#region ../astro-browser-runtime/src/hmr/react-component.tsx
|
|
3
4
|
function createComponentHmrWrapper(OriginalComponent, hotData) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
};
|
|
20
|
-
}, []);
|
|
21
|
-
return /* @__PURE__ */ React.createElement(WrappedComponent, { ...props });
|
|
22
|
-
};
|
|
5
|
+
return (props) => {
|
|
6
|
+
const [WrappedComponent, setComponent] = useState(() => hotData.Component ?? OriginalComponent);
|
|
7
|
+
const isMountedRef = useRef(false);
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
isMountedRef.current = true;
|
|
10
|
+
hotData.setComponent = (NewComponent) => {
|
|
11
|
+
hotData.Component = NewComponent;
|
|
12
|
+
if (isMountedRef.current) setComponent(() => NewComponent);
|
|
13
|
+
};
|
|
14
|
+
return () => {
|
|
15
|
+
isMountedRef.current = false;
|
|
16
|
+
};
|
|
17
|
+
}, []);
|
|
18
|
+
return /* @__PURE__ */ React.createElement(WrappedComponent, props);
|
|
19
|
+
};
|
|
23
20
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
};
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
export { createComponentHmrWrapper };
|
package/build/dependencies/astro-custom-elements-extensions/browser-runtime/renderSettingsPanel.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { ComponentType } from
|
|
1
|
+
import { ComponentType } from "react";
|
|
2
2
|
|
|
3
|
+
//#region src/runtime/renderSettingsPanel.d.ts
|
|
3
4
|
declare function renderSettingsPanel(SettingsPanel: ComponentType): void;
|
|
4
|
-
|
|
5
|
-
export { renderSettingsPanel };
|
|
5
|
+
//#endregion
|
|
6
|
+
export { renderSettingsPanel };
|