@wix/astro 1.0.12 → 1.0.15

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.
@@ -1,3 +1,5 @@
1
- declare function setup(): void;
1
+ declare function setup(options: {
2
+ clientId: string;
3
+ }): void;
2
4
 
3
5
  export { setup };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  getSessionClient,
3
3
  isBackofficeExtension
4
- } from "./chunk-4AS3AXFB.js";
4
+ } from "./chunk-HJBVRKIZ.js";
5
5
 
6
6
  // src/context/before-hydration.ts
7
7
  import { dashboard } from "@wix/dashboard";
@@ -15,8 +15,8 @@ function getBackofficeClient() {
15
15
  }
16
16
  });
17
17
  }
18
- function setup() {
19
- const client = isBackofficeExtension ? getBackofficeClient() : getSessionClient();
18
+ function setup(options) {
19
+ const client = isBackofficeExtension ? getBackofficeClient() : getSessionClient(options);
20
20
  client.enableContext("global");
21
21
  }
22
22
  export {
@@ -1,7 +1,6 @@
1
1
  // src/context/utils.ts
2
2
  import { createClient } from "@wix/sdk";
3
3
  import { SiteSessionAuth } from "@wix/sdk/auth/site-session";
4
- import { WIX_CLIENT_ID } from "astro:env/client";
5
4
  var isBackofficeExtension = location.pathname.startsWith(
6
5
  "/_wix/extensions/backoffice"
7
6
  );
@@ -19,11 +18,11 @@ function getCookieAsJson(name) {
19
18
  return null;
20
19
  }
21
20
  }
22
- function getSessionClient() {
21
+ function getSessionClient(options) {
23
22
  return createClient({
24
23
  auth: SiteSessionAuth({
25
- clientId: WIX_CLIENT_ID,
26
- tokens: getCookieAsJson("wixSession")?.tokens
24
+ tokens: getCookieAsJson("wixSession")?.tokens,
25
+ ...options
27
26
  })
28
27
  });
29
28
  }
@@ -1,3 +1,5 @@
1
- declare function setup(): void;
1
+ declare function setup(options: {
2
+ clientId: string;
3
+ }): void;
2
4
 
3
5
  export { setup };
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  getSessionClient,
3
3
  isBackofficeExtension
4
- } from "./chunk-4AS3AXFB.js";
4
+ } from "./chunk-HJBVRKIZ.js";
5
5
 
6
6
  // src/context/page.ts
7
- function setup() {
7
+ function setup(options) {
8
8
  if (!isBackofficeExtension) {
9
- getSessionClient().enableContext("global");
9
+ getSessionClient(options).enableContext("global");
10
10
  }
11
11
  }
12
12
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/astro",
3
- "version": "1.0.12",
3
+ "version": "1.0.15",
4
4
  "devDependencies": {
5
5
  "@wix/dashboard": "^1.3.35",
6
6
  "@wix/sdk": "^1.15.17",
@@ -46,5 +46,5 @@
46
46
  ]
47
47
  }
48
48
  },
49
- "falconPackageHash": "0776b36e71f1d12df1678b22b44d546fd83c6e48e37c8f48200e9e1f"
49
+ "falconPackageHash": "03baaa6edb871e335e34c1c6f47130585ee742e48350a4b908c708b5"
50
50
  }
@@ -12,10 +12,10 @@ function getBackofficeClient() {
12
12
  });
13
13
  }
14
14
 
15
- export function setup() {
15
+ export function setup(options: { clientId: string }) {
16
16
  const client = isBackofficeExtension
17
17
  ? getBackofficeClient()
18
- : getSessionClient();
18
+ : getSessionClient(options);
19
19
 
20
20
  client.enableContext('global');
21
21
  }
@@ -1,7 +1,7 @@
1
1
  import { getSessionClient, isBackofficeExtension } from './utils.js';
2
2
 
3
- export function setup() {
3
+ export function setup(options: { clientId: string }) {
4
4
  if (!isBackofficeExtension) {
5
- getSessionClient().enableContext('global');
5
+ getSessionClient(options).enableContext('global');
6
6
  }
7
7
  }
@@ -1,6 +1,5 @@
1
1
  import { createClient } from '@wix/sdk';
2
2
  import { SiteSessionAuth } from '@wix/sdk/auth/site-session';
3
- import { WIX_CLIENT_ID } from 'astro:env/client';
4
3
 
5
4
  export const isBackofficeExtension = location.pathname.startsWith(
6
5
  '/_wix/extensions/backoffice'
@@ -24,11 +23,11 @@ function getCookieAsJson(name: string) {
24
23
  }
25
24
  }
26
25
 
27
- export function getSessionClient() {
26
+ export function getSessionClient(options: { clientId: string }) {
28
27
  return createClient({
29
28
  auth: SiteSessionAuth({
30
- clientId: WIX_CLIENT_ID,
31
29
  tokens: getCookieAsJson('wixSession')?.tokens,
30
+ ...options,
32
31
  }),
33
32
  });
34
33
  }
package/src/index.ts CHANGED
@@ -57,7 +57,7 @@ const createIntegration = (): AstroIntegration => {
57
57
  }) {
58
58
  const codegenDirURL = createCodegenDir();
59
59
  const codegenDir = fileURLToPath(codegenDirURL);
60
- const rootDir = fileURLToPath(config.outDir);
60
+ const rootDir = fileURLToPath(config.root);
61
61
 
62
62
  model ??= await createProjectModel(logger);
63
63
 
@@ -65,16 +65,20 @@ const createIntegration = (): AstroIntegration => {
65
65
  injectScript(
66
66
  'before-hydration',
67
67
  outdent`
68
+ import { WIX_CLIENT_ID } from 'astro:env/client';
68
69
  import { setup } from '@wix/astro/context/before-hydration';
69
- setup();
70
+
71
+ setup({ clientId: WIX_CLIENT_ID });
70
72
  `
71
73
  );
72
74
 
73
75
  injectScript(
74
76
  'page',
75
77
  outdent`
78
+ import { WIX_CLIENT_ID } from 'astro:env/client';
76
79
  import { setup } from '@wix/astro/context/page';
77
- setup();
80
+
81
+ setup({ clientId: WIX_CLIENT_ID });
78
82
  `
79
83
  );
80
84