@wix/astro 1.0.30 → 1.0.32

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 (36) hide show
  1. package/build/index.js +31 -0
  2. package/build/index.js.map +1 -1
  3. package/build-browser-runtime/setup.js +723 -3
  4. package/build-runtime/chunk-7EHL72JI.js +1079 -0
  5. package/build-runtime/{chunk-FR26HCAT.js → chunk-EK7YZVWJ.js} +17 -135
  6. package/build-runtime/chunk-NKY4T53W.js +709 -0
  7. package/build-runtime/chunk-PSHIUVP2.js +131 -0
  8. package/build-runtime/chunk-U67V476Y.js +35 -0
  9. package/build-runtime/{chunk-RKE6XT5Z.js → chunk-WE3ELMU5.js} +1 -1
  10. package/build-runtime/chunk-YX6EVX5Q.js +11 -0
  11. package/build-runtime/context/elevated.js +3 -2
  12. package/build-runtime/context/nonElevated.js +3 -2
  13. package/build-runtime/context/setupServicePlugin.js +1 -1
  14. package/build-runtime/context/setupWebhook.js +1 -1
  15. package/build-runtime/middleware/auth.js +1 -1
  16. package/build-runtime/middleware/html-embeds.js +3 -2
  17. package/build-runtime/routes/auth/callback.js +2 -2
  18. package/build-runtime/routes/auth/login.js +2 -2
  19. package/build-runtime/routes/auth/logout-callback.js +1 -1
  20. package/build-runtime/routes/auth/logout.js +2 -2
  21. package/build-runtime/routes/paylink/checkout.d.ts +5 -0
  22. package/build-runtime/routes/paylink/checkout.js +35 -0
  23. package/build-runtime/routes/paylink/paylink.js +5 -1072
  24. package/build-runtime/routes/robots/robots.d.ts +5 -0
  25. package/build-runtime/routes/robots/robots.js +44 -0
  26. package/build-runtime/routes/servicePluginsDevRoute.js +1 -1
  27. package/build-runtime/routes/webhooksDevRoute.js +1 -1
  28. package/package.json +4 -4
  29. package/src/index.ts +28 -0
  30. package/src/plugins/setupSsrContext.ts +6 -0
  31. package/src/routes/paylink/checkout.ts +28 -0
  32. package/src/routes/robots/robots.ts +40 -0
  33. package/src/utils/normalizeWixRedirectUrl.ts +11 -0
  34. package/tsup.config.mjs +6 -0
  35. package/build-runtime/chunk-B6RICTPP.js +0 -94
  36. package/build-runtime/chunk-MLKGABMK.js +0 -9
@@ -0,0 +1,131 @@
1
+ // ../../node_modules/@wix/sdk-types/build/index.mjs
2
+ function EventDefinition(type, isDomainEvent = false, transformations = (x) => x) {
3
+ return () => ({
4
+ __type: "event-definition",
5
+ type,
6
+ isDomainEvent,
7
+ transformations
8
+ });
9
+ }
10
+
11
+ // ../../node_modules/@wix/sdk-context/build/index.mjs
12
+ var wixContext = {};
13
+
14
+ // ../../node_modules/@wix/sdk-runtime/build/context.js
15
+ function resolveContext() {
16
+ const oldContext = typeof $wixContext !== "undefined" && $wixContext.initWixModules ? $wixContext.initWixModules : typeof globalThis.__wix_context__ !== "undefined" && globalThis.__wix_context__.initWixModules ? globalThis.__wix_context__.initWixModules : void 0;
17
+ if (oldContext) {
18
+ return {
19
+ // @ts-expect-error
20
+ initWixModules(modules, elevated) {
21
+ return runWithoutContext(() => oldContext(modules, elevated));
22
+ },
23
+ fetchWithAuth() {
24
+ throw new Error("fetchWithAuth is not available in this context");
25
+ },
26
+ graphql() {
27
+ throw new Error("graphql is not available in this context");
28
+ }
29
+ };
30
+ }
31
+ const contextualClient = typeof $wixContext !== "undefined" ? $wixContext.client : typeof wixContext.client !== "undefined" ? wixContext.client : typeof globalThis.__wix_context__ !== "undefined" ? globalThis.__wix_context__.client : void 0;
32
+ const elevatedClient = typeof $wixContext !== "undefined" ? $wixContext.elevatedClient : typeof wixContext.elevatedClient !== "undefined" ? wixContext.elevatedClient : typeof globalThis.__wix_context__ !== "undefined" ? globalThis.__wix_context__.elevatedClient : void 0;
33
+ if (!contextualClient && !elevatedClient) {
34
+ return;
35
+ }
36
+ return {
37
+ initWixModules(wixModules, elevated) {
38
+ if (elevated) {
39
+ if (!elevatedClient) {
40
+ throw new Error("An elevated client is required to use elevated modules. Make sure to initialize the Wix context with an elevated client before using elevated SDK modules");
41
+ }
42
+ return runWithoutContext(() => elevatedClient.use(wixModules));
43
+ }
44
+ if (!contextualClient) {
45
+ throw new Error("Wix context is not available. Make sure to initialize the Wix context before using SDK modules");
46
+ }
47
+ return runWithoutContext(() => contextualClient.use(wixModules));
48
+ },
49
+ fetchWithAuth: (urlOrRequest, requestInit) => {
50
+ if (!contextualClient) {
51
+ throw new Error("Wix context is not available. Make sure to initialize the Wix context before using SDK modules");
52
+ }
53
+ return contextualClient.fetchWithAuth(urlOrRequest, requestInit);
54
+ },
55
+ getAuth() {
56
+ if (!contextualClient) {
57
+ throw new Error("Wix context is not available. Make sure to initialize the Wix context before using SDK modules");
58
+ }
59
+ return contextualClient.auth;
60
+ },
61
+ async graphql(query, variables, opts) {
62
+ if (!contextualClient) {
63
+ throw new Error("Wix context is not available. Make sure to initialize the Wix context before using SDK modules");
64
+ }
65
+ return contextualClient.graphql(query, variables, opts);
66
+ }
67
+ };
68
+ }
69
+ function runWithoutContext(fn) {
70
+ const globalContext = globalThis.__wix_context__;
71
+ const moduleContext = {
72
+ client: wixContext.client,
73
+ elevatedClient: wixContext.elevatedClient
74
+ };
75
+ let closureContext;
76
+ globalThis.__wix_context__ = void 0;
77
+ wixContext.client = void 0;
78
+ wixContext.elevatedClient = void 0;
79
+ if (typeof $wixContext !== "undefined") {
80
+ closureContext = {
81
+ client: $wixContext?.client,
82
+ elevatedClient: $wixContext?.elevatedClient
83
+ };
84
+ delete $wixContext.client;
85
+ delete $wixContext.elevatedClient;
86
+ }
87
+ try {
88
+ return fn();
89
+ } finally {
90
+ globalThis.__wix_context__ = globalContext;
91
+ wixContext.client = moduleContext.client;
92
+ wixContext.elevatedClient = moduleContext.elevatedClient;
93
+ if (typeof $wixContext !== "undefined") {
94
+ $wixContext.client = closureContext.client;
95
+ $wixContext.elevatedClient = closureContext.elevatedClient;
96
+ }
97
+ }
98
+ }
99
+
100
+ // ../../node_modules/@wix/sdk-runtime/build/context-v2.js
101
+ function contextualizeRESTModuleV2(restModule, elevated) {
102
+ return (...args) => {
103
+ const context = resolveContext();
104
+ if (!context) {
105
+ return restModule.apply(void 0, args);
106
+ }
107
+ return context.initWixModules(restModule, elevated).apply(void 0, args);
108
+ };
109
+ }
110
+ function contextualizeEventDefinitionModuleV2(eventDefinition) {
111
+ const contextualMethod = (...args) => {
112
+ const context = resolveContext();
113
+ if (!context) {
114
+ return () => {
115
+ };
116
+ }
117
+ return context.initWixModules(eventDefinition).apply(void 0, args);
118
+ };
119
+ contextualMethod.__type = eventDefinition.__type;
120
+ contextualMethod.type = eventDefinition.type;
121
+ contextualMethod.isDomainEvent = eventDefinition.isDomainEvent;
122
+ contextualMethod.transformations = eventDefinition.transformations;
123
+ return contextualMethod;
124
+ }
125
+
126
+ export {
127
+ EventDefinition,
128
+ contextualizeRESTModuleV2,
129
+ contextualizeEventDefinitionModuleV2,
130
+ resolveContext
131
+ };
@@ -0,0 +1,35 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __commonJS = (cb, mod) => function __require() {
8
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
+ };
10
+ var __export = (target, all) => {
11
+ for (var name in all)
12
+ __defProp(target, name, { get: all[name], enumerable: true });
13
+ };
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from))
17
+ if (!__hasOwnProp.call(to, key) && key !== except)
18
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28
+ mod
29
+ ));
30
+
31
+ export {
32
+ __commonJS,
33
+ __export,
34
+ __toESM
35
+ };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  __export
3
- } from "./chunk-MLKGABMK.js";
3
+ } from "./chunk-U67V476Y.js";
4
4
 
5
5
  // ../../node_modules/zod/dist/esm/v4/core/core.js
6
6
  // @__NO_SIDE_EFFECTS__
@@ -0,0 +1,11 @@
1
+ // src/utils/normalizeWixRedirectUrl.ts
2
+ function normalizeWixRedirectUrl({
3
+ wixRedirectUrl
4
+ }) {
5
+ const normalizedWixRedirectUrl = wixRedirectUrl.endsWith("/") ? wixRedirectUrl : `${wixRedirectUrl}/`;
6
+ return normalizedWixRedirectUrl;
7
+ }
8
+
9
+ export {
10
+ normalizeWixRedirectUrl
11
+ };
@@ -1,8 +1,9 @@
1
1
  import {
2
2
  createHostProxy
3
- } from "../chunk-B6RICTPP.js";
3
+ } from "../chunk-NKY4T53W.js";
4
4
  import "../chunk-NVTQFGTR.js";
5
- import "../chunk-MLKGABMK.js";
5
+ import "../chunk-PSHIUVP2.js";
6
+ import "../chunk-U67V476Y.js";
6
7
 
7
8
  // src/context/elevated.ts
8
9
  import { AppStrategy, createClient } from "@wix/sdk";
@@ -1,10 +1,11 @@
1
1
  import {
2
2
  createHostProxy
3
- } from "../chunk-B6RICTPP.js";
3
+ } from "../chunk-NKY4T53W.js";
4
4
  import {
5
5
  authAsyncLocalStorage
6
6
  } from "../chunk-NVTQFGTR.js";
7
- import "../chunk-MLKGABMK.js";
7
+ import "../chunk-PSHIUVP2.js";
8
+ import "../chunk-U67V476Y.js";
8
9
 
9
10
  // src/context/nonElevated.ts
10
11
  import { createClient, OAuthStrategy } from "@wix/sdk";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  setupClient
3
3
  } from "../chunk-W73LN534.js";
4
- import "../chunk-MLKGABMK.js";
4
+ import "../chunk-U67V476Y.js";
5
5
 
6
6
  // src/context/setupServicePlugin.ts
7
7
  async function setupServicePlugin(fn) {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  setupClient
3
3
  } from "../chunk-W73LN534.js";
4
- import "../chunk-MLKGABMK.js";
4
+ import "../chunk-U67V476Y.js";
5
5
 
6
6
  // src/context/setupWebhook.ts
7
7
  async function setupWebhook(fn) {
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  authAsyncLocalStorage
6
6
  } from "../chunk-NVTQFGTR.js";
7
- import "../chunk-MLKGABMK.js";
7
+ import "../chunk-U67V476Y.js";
8
8
 
9
9
  // src/utils/generateVisitorTokens.ts
10
10
  import { OAuthStrategy } from "@wix/sdk";
@@ -5,10 +5,11 @@ import {
5
5
  resolveUrl,
6
6
  toURLSearchParams,
7
7
  transformError
8
- } from "../chunk-FR26HCAT.js";
8
+ } from "../chunk-EK7YZVWJ.js";
9
+ import "../chunk-PSHIUVP2.js";
9
10
  import {
10
11
  __export
11
- } from "../chunk-MLKGABMK.js";
12
+ } from "../chunk-U67V476Y.js";
12
13
 
13
14
  // ../../node_modules/@wix/auto_sdk_headless-site-assets_scripts/build/es/index.mjs
14
15
  var es_exports = {};
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  object,
3
3
  string
4
- } from "../../chunk-RKE6XT5Z.js";
4
+ } from "../../chunk-WE3ELMU5.js";
5
5
  import {
6
6
  auth,
7
7
  oAuthStateCookieName
@@ -9,7 +9,7 @@ import {
9
9
  import {
10
10
  saveSessionTokensToCookie
11
11
  } from "../../chunk-HPW4ZAEJ.js";
12
- import "../../chunk-MLKGABMK.js";
12
+ import "../../chunk-U67V476Y.js";
13
13
 
14
14
  // src/routes/auth/callback.ts
15
15
  var oauthCookieSchema = object({
@@ -2,12 +2,12 @@ import {
2
2
  _enum,
3
3
  object,
4
4
  string
5
- } from "../../chunk-RKE6XT5Z.js";
5
+ } from "../../chunk-WE3ELMU5.js";
6
6
  import {
7
7
  auth,
8
8
  oAuthStateCookieName
9
9
  } from "../../chunk-UZPSWWI5.js";
10
- import "../../chunk-MLKGABMK.js";
10
+ import "../../chunk-U67V476Y.js";
11
11
 
12
12
  // src/routes/auth/login.ts
13
13
  var loginSearchParams = object({
@@ -5,7 +5,7 @@ import {
5
5
  import {
6
6
  saveSessionTokensToCookie
7
7
  } from "../../chunk-HPW4ZAEJ.js";
8
- import "../../chunk-MLKGABMK.js";
8
+ import "../../chunk-U67V476Y.js";
9
9
 
10
10
  // src/routes/auth/logout-callback.ts
11
11
  var GET = async (context) => {
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  object,
3
3
  string
4
- } from "../../chunk-RKE6XT5Z.js";
4
+ } from "../../chunk-WE3ELMU5.js";
5
5
  import {
6
6
  auth,
7
7
  returnToQueryParamName
8
8
  } from "../../chunk-UZPSWWI5.js";
9
- import "../../chunk-MLKGABMK.js";
9
+ import "../../chunk-U67V476Y.js";
10
10
 
11
11
  // src/routes/auth/logout.ts
12
12
  var logoutSearchParams = object({
@@ -0,0 +1,5 @@
1
+ import { APIRoute } from 'astro';
2
+
3
+ declare const GET: APIRoute;
4
+
5
+ export { GET };
@@ -0,0 +1,35 @@
1
+ import {
2
+ normalizeWixRedirectUrl
3
+ } from "../../chunk-YX6EVX5Q.js";
4
+ import {
5
+ es_exports
6
+ } from "../../chunk-7EHL72JI.js";
7
+ import "../../chunk-EK7YZVWJ.js";
8
+ import "../../chunk-PSHIUVP2.js";
9
+ import "../../chunk-U67V476Y.js";
10
+
11
+ // src/routes/paylink/checkout.ts
12
+ import { auth } from "@wix/essentials";
13
+ import { WIX_CLIENT_ID } from "astro:env/client";
14
+ var GET = async ({ url }) => {
15
+ const { redirectUrlWixPages } = await auth.elevate(es_exports.getOAuthApp)(
16
+ WIX_CLIENT_ID
17
+ );
18
+ if (redirectUrlWixPages == null) {
19
+ throw new Error(`Invalid Redirect URL: '${redirectUrlWixPages}'`);
20
+ }
21
+ const baseUrl = normalizeWixRedirectUrl({
22
+ wixRedirectUrl: redirectUrlWixPages
23
+ });
24
+ const newCheckoutUrl = new URL(
25
+ url.pathname.replace("/", "") + url.search,
26
+ baseUrl
27
+ );
28
+ return new Response(null, {
29
+ headers: { Location: newCheckoutUrl.toString() },
30
+ status: 302
31
+ });
32
+ };
33
+ export {
34
+ GET
35
+ };