@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.
Files changed (177) hide show
  1. package/build/dependencies/astro-auth/backend-runtime/constants-Dbkf3D5f.mjs +6 -0
  2. package/build/dependencies/astro-auth/backend-runtime/elevatedContextualClient-tJx9dIn_.mjs +41 -0
  3. package/build/dependencies/astro-auth/backend-runtime/host-utils-B2Fs_Z4S.mjs +17 -0
  4. package/build/dependencies/astro-auth/backend-runtime/middleware/auth.d.mts +6 -0
  5. package/build/dependencies/astro-auth/backend-runtime/middleware/auth.mjs +3643 -0
  6. package/build/dependencies/astro-auth/backend-runtime/middleware/localization.d.mts +6 -0
  7. package/build/dependencies/astro-auth/backend-runtime/middleware/localization.mjs +193 -0
  8. package/build/dependencies/astro-auth/backend-runtime/routes/callback.d.mts +6 -0
  9. package/build/dependencies/astro-auth/backend-runtime/routes/callback.mjs +34 -0
  10. package/build/dependencies/astro-auth/backend-runtime/routes/login.d.mts +6 -0
  11. package/build/dependencies/astro-auth/backend-runtime/routes/login.mjs +32 -0
  12. package/build/dependencies/astro-auth/backend-runtime/routes/logout-callback.d.mts +6 -0
  13. package/build/dependencies/astro-auth/backend-runtime/routes/logout-callback.mjs +14 -0
  14. package/build/dependencies/astro-auth/backend-runtime/routes/logout.d.mts +6 -0
  15. package/build/dependencies/astro-auth/backend-runtime/routes/logout.mjs +19 -0
  16. package/build/dependencies/astro-auth/backend-runtime/runtime/backend/setupContextualClient.d.mts +1 -0
  17. package/build/dependencies/astro-auth/backend-runtime/runtime/backend/setupContextualClient.mjs +8 -0
  18. package/build/dependencies/astro-auth/backend-runtime/saveSessionTokensToCookie-DK3xvtzk.mjs +24 -0
  19. package/build/dependencies/astro-auth/backend-runtime/schemas-XrMhpOYn.mjs +2771 -0
  20. package/build/dependencies/astro-auth/browser-runtime/setup.d.ts +4 -3
  21. package/build/dependencies/astro-auth/browser-runtime/setup.js +55 -81
  22. package/build/dependencies/astro-backend-extensions/backend-runtime/routes/extensions.d.mts +6 -0
  23. package/build/dependencies/astro-backend-extensions/backend-runtime/routes/extensions.mjs +37 -0
  24. package/build/dependencies/astro-backend-extensions/backend-runtime/runtime/setupServicePlugin.d.mts +10 -0
  25. package/build/dependencies/astro-backend-extensions/backend-runtime/runtime/setupServicePlugin.mjs +22 -0
  26. package/build/dependencies/astro-backend-extensions/backend-runtime/runtime/setupWebhook.d.mts +9 -0
  27. package/build/dependencies/astro-backend-extensions/backend-runtime/runtime/setupWebhook.mjs +22 -0
  28. package/build/dependencies/astro-backend-extensions/backend-runtime/utils-DDHGZHjR.mjs +56 -0
  29. package/build/dependencies/astro-backend-extensions/backend-runtime/utils-mYlwmIjd.d.mts +6 -0
  30. package/build/dependencies/astro-backoffice-extensions/browser-runtime/wrapComponent.d.ts +4 -3
  31. package/build/dependencies/astro-backoffice-extensions/browser-runtime/wrapComponent.js +6 -5
  32. package/build/dependencies/astro-context-providers-extensions/browser-runtime/hmr.d.ts +10 -0
  33. package/build/dependencies/astro-context-providers-extensions/browser-runtime/hmr.js +20 -23
  34. package/build/dependencies/astro-context-providers-extensions/browser-runtime/sdk.d.ts +9 -0
  35. package/build/dependencies/astro-context-providers-extensions/browser-runtime/sdk.js +16 -15
  36. package/build/dependencies/astro-custom-elements-extensions/browser-runtime/customElementHmr.d.ts +9 -5
  37. package/build/dependencies/astro-custom-elements-extensions/browser-runtime/customElementHmr.js +23 -40
  38. package/build/dependencies/astro-custom-elements-extensions/browser-runtime/reactHmr.d.ts +10 -1
  39. package/build/dependencies/astro-custom-elements-extensions/browser-runtime/reactHmr.js +20 -23
  40. package/build/dependencies/astro-custom-elements-extensions/browser-runtime/renderSettingsPanel.d.ts +4 -3
  41. package/build/dependencies/astro-custom-elements-extensions/browser-runtime/renderSettingsPanel.js +14 -18
  42. package/build/dependencies/astro-custom-elements-extensions/browser-runtime/wrapCustomElement.d.ts +9 -5
  43. package/build/dependencies/astro-custom-elements-extensions/browser-runtime/wrapCustomElement.js +23 -25
  44. package/build/dependencies/astro-embedded-scripts-extensions/browser-runtime/setupContext.d.ts +8 -4
  45. package/build/dependencies/astro-embedded-scripts-extensions/browser-runtime/setupContext.js +18 -17
  46. package/build/dependencies/astro-function-libraries-extensions/browser-runtime/sdk.d.ts +9 -0
  47. package/build/dependencies/astro-function-libraries-extensions/browser-runtime/sdk.js +16 -15
  48. package/build/dependencies/astro-html-embeds/backend-runtime/html-embeds.d.mts +6 -0
  49. package/build/dependencies/astro-html-embeds/backend-runtime/html-embeds.mjs +53 -0
  50. package/build/dependencies/astro-monitor/backend-runtime/monitor.d.mts +6 -0
  51. package/build/dependencies/astro-monitor/backend-runtime/monitor.mjs +43 -0
  52. package/build/dependencies/astro-payment-links/backend-runtime/elevate-CDDLuCIf.mjs +9 -0
  53. package/build/dependencies/astro-payment-links/backend-runtime/payment-checkout.d.mts +6 -0
  54. package/build/dependencies/astro-payment-links/backend-runtime/payment-checkout.mjs +20 -0
  55. package/build/dependencies/astro-payment-links/backend-runtime/payment-link.d.mts +6 -0
  56. package/build/dependencies/astro-payment-links/backend-runtime/payment-link.mjs +15 -0
  57. package/build/dependencies/astro-payment-links/backend-runtime/proposal.d.mts +6 -0
  58. package/build/dependencies/astro-payment-links/backend-runtime/proposal.mjs +20 -0
  59. package/build/dependencies/astro-robots/backend-runtime/robots.d.mts +6 -0
  60. package/build/dependencies/astro-robots/backend-runtime/robots.mjs +26 -0
  61. package/build/dependencies/astro-site-component-panels-extensions/browser-runtime/hmr.d.ts +10 -0
  62. package/build/dependencies/astro-site-component-panels-extensions/browser-runtime/hmr.js +20 -23
  63. package/build/dependencies/astro-site-component-panels-extensions/browser-runtime/sdk.d.ts +12 -0
  64. package/build/dependencies/astro-site-component-panels-extensions/browser-runtime/sdk.js +10 -10
  65. package/build/dependencies/astro-site-components-extensions/browser-runtime/hmr.d.ts +10 -0
  66. package/build/dependencies/astro-site-components-extensions/browser-runtime/hmr.js +20 -23
  67. package/build/dependencies/astro-site-components-extensions/browser-runtime/sdk.d.ts +9 -0
  68. package/build/dependencies/astro-site-components-extensions/browser-runtime/sdk.js +16 -15
  69. package/build/dependencies/astro-translations/backend-runtime/middleware/static-translations.d.mts +6 -0
  70. package/build/dependencies/astro-translations/backend-runtime/middleware/static-translations.mjs +177 -0
  71. package/build/dependencies/astro-translations/backend-runtime/runtime/{i18n.d.ts → i18n.d.mts} +3 -2
  72. package/build/dependencies/astro-translations/backend-runtime/runtime/i18n.mjs +38 -0
  73. package/build/dependencies/astro-translations/integration/index.d.mts +105 -0
  74. package/build/dependencies/astro-translations/integration/index.mjs +264 -0
  75. package/build/dependencies/astro-trusted-backoffice-extensions/browser-runtime/hmr.d.ts +10 -1
  76. package/build/dependencies/astro-trusted-backoffice-extensions/browser-runtime/hmr.js +20 -23
  77. package/build/dependencies/astro-trusted-backoffice-extensions/browser-runtime/wrapComponent.d.ts +12 -8
  78. package/build/dependencies/astro-trusted-backoffice-extensions/browser-runtime/wrapComponent.js +25 -35
  79. package/build/dependencies/astro-viewer-api/backend-runtime/api.d.mts +6 -0
  80. package/build/dependencies/astro-viewer-api/backend-runtime/api.mjs +27 -0
  81. package/build/dependencies/astro-viewer-services-extensions/browser-runtime/sdk.d.ts +9 -0
  82. package/build/dependencies/astro-viewer-services-extensions/browser-runtime/sdk.js +16 -15
  83. package/build/integration/builders-B9yQdgSz.mjs +76 -0
  84. package/build/integration/builders-DP0350YQ.d.mts +121 -0
  85. package/build/integration/builders-DVfxT6EC.mjs +225 -0
  86. package/build/integration/builders-experimental.d.mts +56 -0
  87. package/build/integration/builders-experimental.mjs +26 -0
  88. package/build/integration/builders-trusted.d.mts +75 -0
  89. package/build/integration/builders-trusted.mjs +46 -0
  90. package/build/integration/builders.d.mts +4 -0
  91. package/build/integration/builders.mjs +4 -0
  92. package/build/integration/index-B3B_5bgh.d.mts +248 -0
  93. package/build/integration/index-D5k6Bmue.d.mts +32 -0
  94. package/build/integration/index.d.mts +35 -0
  95. package/build/integration/index.mjs +29236 -0
  96. package/package.json +12 -12
  97. package/build/dependencies/astro-auth/backend-runtime/chunk-24J7STEA.js +0 -8
  98. package/build/dependencies/astro-auth/backend-runtime/chunk-352W54SQ.js +0 -70
  99. package/build/dependencies/astro-auth/backend-runtime/chunk-BIARYLOZ.js +0 -3267
  100. package/build/dependencies/astro-auth/backend-runtime/chunk-DZHZMKUF.js +0 -26
  101. package/build/dependencies/astro-auth/backend-runtime/chunk-MLKGABMK.js +0 -9
  102. package/build/dependencies/astro-auth/backend-runtime/chunk-USQSPPTM.js +0 -14
  103. package/build/dependencies/astro-auth/backend-runtime/middleware/auth.d.ts +0 -5
  104. package/build/dependencies/astro-auth/backend-runtime/middleware/auth.js +0 -136
  105. package/build/dependencies/astro-auth/backend-runtime/middleware/localization.d.ts +0 -5
  106. package/build/dependencies/astro-auth/backend-runtime/middleware/localization.js +0 -219
  107. package/build/dependencies/astro-auth/backend-runtime/routes/callback.d.ts +0 -5
  108. package/build/dependencies/astro-auth/backend-runtime/routes/callback.js +0 -53
  109. package/build/dependencies/astro-auth/backend-runtime/routes/login.d.ts +0 -5
  110. package/build/dependencies/astro-auth/backend-runtime/routes/login.js +0 -46
  111. package/build/dependencies/astro-auth/backend-runtime/routes/logout-callback.d.ts +0 -5
  112. package/build/dependencies/astro-auth/backend-runtime/routes/logout-callback.js +0 -24
  113. package/build/dependencies/astro-auth/backend-runtime/routes/logout.d.ts +0 -5
  114. package/build/dependencies/astro-auth/backend-runtime/routes/logout.js +0 -33
  115. package/build/dependencies/astro-auth/backend-runtime/runtime/backend/setupContextualClient.d.ts +0 -2
  116. package/build/dependencies/astro-auth/backend-runtime/runtime/backend/setupContextualClient.js +0 -10
  117. package/build/dependencies/astro-backend-extensions/backend-runtime/chunk-CPGTXQVH.js +0 -75
  118. package/build/dependencies/astro-backend-extensions/backend-runtime/routes/extensions.d.ts +0 -5
  119. package/build/dependencies/astro-backend-extensions/backend-runtime/routes/extensions.js +0 -41
  120. package/build/dependencies/astro-backend-extensions/backend-runtime/runtime/setupServicePlugin.d.ts +0 -10
  121. package/build/dependencies/astro-backend-extensions/backend-runtime/runtime/setupServicePlugin.js +0 -35
  122. package/build/dependencies/astro-backend-extensions/backend-runtime/runtime/setupWebhook.d.ts +0 -9
  123. package/build/dependencies/astro-backend-extensions/backend-runtime/runtime/setupWebhook.js +0 -34
  124. package/build/dependencies/astro-backend-extensions/backend-runtime/utils-B7jr2PES.d.ts +0 -5
  125. package/build/dependencies/astro-backend-extensions/types/index.d.ts +0 -102
  126. package/build/dependencies/astro-backoffice-extensions/types/index.d.ts +0 -68
  127. package/build/dependencies/astro-context-providers-extensions/types/index.d.ts +0 -32
  128. package/build/dependencies/astro-core/types/index.d.ts +0 -109
  129. package/build/dependencies/astro-custom-elements-extensions/types/index.d.ts +0 -45
  130. package/build/dependencies/astro-embedded-scripts-extensions/types/index.d.ts +0 -18
  131. package/build/dependencies/astro-function-libraries-extensions/types/index.d.ts +0 -23
  132. package/build/dependencies/astro-html-embeds/backend-runtime/html-embeds.d.ts +0 -5
  133. package/build/dependencies/astro-html-embeds/backend-runtime/html-embeds.js +0 -66
  134. package/build/dependencies/astro-payment-links/backend-runtime/chunk-656BVIJ3.js +0 -9
  135. package/build/dependencies/astro-payment-links/backend-runtime/payment-checkout.d.ts +0 -5
  136. package/build/dependencies/astro-payment-links/backend-runtime/payment-checkout.js +0 -24
  137. package/build/dependencies/astro-payment-links/backend-runtime/payment-link.d.ts +0 -5
  138. package/build/dependencies/astro-payment-links/backend-runtime/payment-link.js +0 -20
  139. package/build/dependencies/astro-payment-links/backend-runtime/proposal.d.ts +0 -5
  140. package/build/dependencies/astro-payment-links/backend-runtime/proposal.js +0 -24
  141. package/build/dependencies/astro-robots/backend-runtime/robots.d.ts +0 -5
  142. package/build/dependencies/astro-robots/backend-runtime/robots.js +0 -38
  143. package/build/dependencies/astro-site-component-panels-extensions/types/index.d.ts +0 -21
  144. package/build/dependencies/astro-site-components-extensions/types/index.d.ts +0 -48
  145. package/build/dependencies/astro-translations/backend-runtime/middleware/static-translations.d.ts +0 -5
  146. package/build/dependencies/astro-translations/backend-runtime/middleware/static-translations.js +0 -189
  147. package/build/dependencies/astro-translations/backend-runtime/runtime/i18n.js +0 -42
  148. package/build/dependencies/astro-translations/integration/index.d.ts +0 -5
  149. package/build/dependencies/astro-translations/integration/index.js +0 -296
  150. package/build/dependencies/astro-trusted-backoffice-extensions/types/index.d.ts +0 -50
  151. package/build/dependencies/astro-viewer-api/backend-runtime/api.d.ts +0 -5
  152. package/build/dependencies/astro-viewer-api/backend-runtime/api.js +0 -34
  153. package/build/dependencies/astro-viewer-services-extensions/types/index.d.ts +0 -27
  154. package/build/integration/builders-experimental.d.ts +0 -53
  155. package/build/integration/builders-experimental.js +0 -20
  156. package/build/integration/builders-experimental.js.map +0 -1
  157. package/build/integration/builders-trusted.d.ts +0 -69
  158. package/build/integration/builders-trusted.js +0 -52
  159. package/build/integration/builders-trusted.js.map +0 -1
  160. package/build/integration/builders.d.ts +0 -112
  161. package/build/integration/builders.js +0 -14
  162. package/build/integration/builders.js.map +0 -1
  163. package/build/integration/chunk-23MOLCVI.js +0 -1087
  164. package/build/integration/chunk-23MOLCVI.js.map +0 -1
  165. package/build/integration/chunk-6UOFHB2M.js +0 -386
  166. package/build/integration/chunk-6UOFHB2M.js.map +0 -1
  167. package/build/integration/chunk-L6JEDTVM.js +0 -7458
  168. package/build/integration/chunk-L6JEDTVM.js.map +0 -1
  169. package/build/integration/chunk-MNQWQ2MC.js +0 -809
  170. package/build/integration/chunk-MNQWQ2MC.js.map +0 -1
  171. package/build/integration/chunk-XN6SBNMI.js +0 -23758
  172. package/build/integration/chunk-XN6SBNMI.js.map +0 -1
  173. package/build/integration/index.d-BUVlSCHa.d.ts +0 -211
  174. package/build/integration/index.d-D4c48TR0.d.ts +0 -58
  175. package/build/integration/index.d.ts +0 -34
  176. package/build/integration/index.js +0 -498
  177. package/build/integration/index.js.map +0 -1
@@ -1,5 +1,6 @@
1
+ //#region src/runtime/client/setup.d.ts
1
2
  declare function setup(options: {
2
- clientId: string;
3
+ clientId: string;
3
4
  }): void;
4
-
5
- export { setup };
5
+ //#endregion
6
+ export { setup };
@@ -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 { createClient, EMPTY_TOKENS, OAuthStrategy } from "@wix/sdk";
3
+ import { EMPTY_TOKENS, OAuthStrategy, createClient } from "@wix/sdk";
7
4
 
8
- // src/utils/sessionCookie.ts
9
- var SESSION_COOKIE_NAME = "wixSession";
10
- var SESSION_COOKIE_OPTIONS = {
11
- path: "/",
12
- secure: true,
13
- ...import.meta.env.DEV && {
14
- maxAge: 10800,
15
- sameSite: "none"
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
- // src/runtime/client/utils.ts
16
+ //#endregion
17
+ //#region src/runtime/client/utils.ts
20
18
  function getSessionClient(options) {
21
- const cookieStorage = {
22
- getTokens: () => getCookieAsJson(SESSION_COOKIE_NAME)?.tokens ?? EMPTY_TOKENS,
23
- setTokens: (tokens) => {
24
- document.cookie = buildSessionCookieString(options.clientId, tokens);
25
- }
26
- };
27
- return createClient({
28
- auth: OAuthStrategy({
29
- tokenStorage: cookieStorage,
30
- ...options
31
- }),
32
- host: headlessSite.host({})
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
- const cookieValue = encodeURIComponent(
37
- JSON.stringify({ clientId, tokens })
38
- );
39
- let cookie = `${SESSION_COOKIE_NAME}=${cookieValue}; path=${SESSION_COOKIE_OPTIONS.path}; ${SESSION_COOKIE_OPTIONS.secure ? "secure;" : ""}`;
40
- if (SESSION_COOKIE_OPTIONS.sameSite) {
41
- cookie += ` samesite=${SESSION_COOKIE_OPTIONS.sameSite};`;
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
- const cookies = document.cookie.split("; ");
50
- const cookie = cookies.find((row) => row.startsWith(`${name}=`));
51
- if (cookie == null) {
52
- return null;
53
- }
54
- try {
55
- const jsonString = decodeURIComponent(cookie.split("=")[1] ?? "");
56
- const cookieValue = JSON.parse(jsonString);
57
- if (isCookieValue(cookieValue)) {
58
- return cookieValue;
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
- if (value == null || typeof value !== "object") {
67
- return false;
68
- }
69
- if (!("clientId" in value) || typeof value.clientId !== "string") {
70
- return false;
71
- }
72
- if (!("tokens" in value)) {
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
- // src/runtime/client/setup.ts
63
+ //#endregion
64
+ //#region src/runtime/client/setup.ts
86
65
  function setup(options) {
87
- const context = resolveContext();
88
- if (context != null) {
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
- export {
96
- setup
97
- };
69
+
70
+ //#endregion
71
+ export { setup };
@@ -0,0 +1,6 @@
1
+ import { APIRoute } from "astro";
2
+
3
+ //#region src/routes/extensions.d.ts
4
+ declare const ALL: APIRoute;
5
+ //#endregion
6
+ export { ALL };
@@ -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 };
@@ -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 };
@@ -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 };
@@ -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 };
@@ -0,0 +1,6 @@
1
+ import { AppStrategy } from "@wix/sdk";
2
+
3
+ //#region src/runtime/utils.d.ts
4
+ type AppStrategyOptions = Partial<Parameters<typeof AppStrategy>[0]>;
5
+ //#endregion
6
+ export { AppStrategyOptions as t };
@@ -1,5 +1,6 @@
1
- import { ComponentType } from 'react';
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
- return withContextualWixClient(component);
5
+ return withContextualWixClient(component);
5
6
  }
6
- export {
7
- wrapComponent
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
- return (props) => {
5
- const [WrappedComponent, setComponent] = useState(
6
- () => hotData.Component ?? OriginalComponent
7
- );
8
- const isMountedRef = useRef(false);
9
- useEffect(() => {
10
- isMountedRef.current = true;
11
- hotData.setComponent = (NewComponent) => {
12
- hotData.Component = NewComponent;
13
- if (isMountedRef.current) {
14
- setComponent(() => NewComponent);
15
- }
16
- };
17
- return () => {
18
- isMountedRef.current = false;
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
- export {
25
- createComponentHmrWrapper
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
- var enableClient = (applicationId) => {
5
- const host = site.host({ applicationId });
6
- const auth = site.auth();
7
- const wixClient = createClient({
8
- auth,
9
- host
10
- });
11
- wixClient.enableContext("module");
12
- return auth.getAccessTokenInjector();
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
- // src/runtime/sdk.ts
15
+ //#endregion
16
+ //#region src/runtime/sdk.ts
16
17
  function createContext() {
17
- return enableClient(import.meta.env.WIX_CLIENT_ID);
18
+ return enableClient(import.meta.env.WIX_CLIENT_ID);
18
19
  }
19
- export {
20
- createContext
21
- };
20
+
21
+ //#endregion
22
+ export { createContext };
@@ -1,6 +1,10 @@
1
- declare function customElementHmr({ customElement, tagName, }: {
2
- customElement: CustomElementConstructor;
3
- tagName: string;
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 };
@@ -1,46 +1,29 @@
1
- // src/runtime/customElementHmr.ts
2
- function customElementHmr({
3
- customElement,
4
- tagName
5
- }) {
6
- for (const node of document.querySelectorAll(tagName)) {
7
- if ("disconnectedCallback" in node && typeof node.disconnectedCallback === "function") {
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
- var replaceMethodsOnElement = (elementNode, newClass) => {
17
- const prototypeDescriptors = Object.getOwnPropertyDescriptors(
18
- newClass.prototype
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
- visitPrototypeChain(NewElementClass, (classInheritance) => {
26
- replaceMethodsOnElement(elementNode, classInheritance);
27
- });
14
+ visitPrototypeChain(NewElementClass, (classInheritance) => {
15
+ replaceMethodsOnElement(elementNode, classInheritance);
16
+ });
28
17
  }
29
18
  function visitPrototypeChain(rootClass, visitFn) {
30
- const inheritanceArray = [rootClass];
31
- let currentClass = Object.getPrototypeOf(
32
- rootClass
33
- );
34
- while (currentClass !== HTMLElement) {
35
- inheritanceArray.unshift(currentClass);
36
- currentClass = Object.getPrototypeOf(
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
- export {
45
- customElementHmr
46
- };
27
+
28
+ //#endregion
29
+ export { customElementHmr };
@@ -1 +1,10 @@
1
- export * from '@wix/astro-browser-runtime/hmr/react-component';
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
- return (props) => {
5
- const [WrappedComponent, setComponent] = useState(
6
- () => hotData.Component ?? OriginalComponent
7
- );
8
- const isMountedRef = useRef(false);
9
- useEffect(() => {
10
- isMountedRef.current = true;
11
- hotData.setComponent = (NewComponent) => {
12
- hotData.Component = NewComponent;
13
- if (isMountedRef.current) {
14
- setComponent(() => NewComponent);
15
- }
16
- };
17
- return () => {
18
- isMountedRef.current = false;
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
- export {
25
- createComponentHmrWrapper
26
- };
21
+
22
+ //#endregion
23
+ export { createComponentHmrWrapper };
@@ -1,5 +1,6 @@
1
- import { ComponentType } from 'react';
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 };