@wix/astro 1.0.17 → 1.0.18

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/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import { AstroIntegration } from 'astro';
2
2
 
3
- declare const createIntegration: () => AstroIntegration;
3
+ declare const createIntegration: (options?: {
4
+ enableAuthRoutes?: boolean;
5
+ }) => AstroIntegration;
4
6
 
5
7
  export { createIntegration as default };
package/build/index.js CHANGED
@@ -12471,8 +12471,7 @@ function patchGlobal() {
12471
12471
  // src/plugins/setupSsrContext.ts
12472
12472
  init_esm_shims();
12473
12473
  import { extname, join as join2 } from "node:path";
12474
- function setupSsrContext(rootDir) {
12475
- const srcDir = join2(rootDir, SRC_DIR);
12474
+ function setupSsrContext() {
12476
12475
  const nonElevatedSetupUrl = new URL(
12477
12476
  "../build-runtime/context/non-elevated.js",
12478
12477
  import.meta.url
@@ -12487,10 +12486,14 @@ function setupSsrContext(rootDir) {
12487
12486
  },
12488
12487
  name: "setup-ssr-context",
12489
12488
  transform(code, id) {
12490
- if (!id.startsWith(srcDir)) {
12489
+ const extension = extname(id);
12490
+ if (
12491
+ // ignore node_modules
12492
+ id.includes("node_modules") && // but allow injected runtime
12493
+ !id.includes(join2("node_modules", "@wix", "astro"))
12494
+ ) {
12491
12495
  return null;
12492
12496
  }
12493
- const extension = extname(id);
12494
12497
  if (extension !== ".js" && extension !== ".astro" && extension !== ".ts" && extension !== ".tsx") {
12495
12498
  return null;
12496
12499
  }
@@ -18159,7 +18162,7 @@ async function writeVirtualBackofficeExtensionFiles(model, codegenDir) {
18159
18162
  await writeFile2(
18160
18163
  virtualHocEntrypoint,
18161
18164
  defaultOutdent`
18162
- import Component from '${toRelativePath2(originalEntrypoint, virtualHocEntrypoint)}';
18165
+ import Component from '${toRelativePath2(virtualHocEntrypoint, originalEntrypoint)}';
18163
18166
  import { withContextualWixClient } from '@wix/dashboard/internal';
18164
18167
 
18165
18168
  export const WrappedComponent = withContextualWixClient(Component);
@@ -18173,7 +18176,7 @@ async function writeVirtualBackofficeExtensionFiles(model, codegenDir) {
18173
18176
  virtualEntrypoint,
18174
18177
  defaultOutdent`
18175
18178
  ---
18176
- import { WrappedComponent } from '${toRelativePath2(virtualHocEntrypoint, virtualEntrypoint)}';
18179
+ import { WrappedComponent } from '${toRelativePath2(virtualEntrypoint, virtualHocEntrypoint)}';
18177
18180
  ---
18178
18181
 
18179
18182
  <div>
@@ -18314,7 +18317,9 @@ async function writeVirtualWebhookExtensionFiles(model, codegenDir) {
18314
18317
  }
18315
18318
 
18316
18319
  // src/index.ts
18317
- var createIntegration = () => {
18320
+ var createIntegration = (options = {
18321
+ enableAuthRoutes: true
18322
+ }) => {
18318
18323
  let _config;
18319
18324
  let model = null;
18320
18325
  return {
@@ -18403,10 +18408,44 @@ var createIntegration = () => {
18403
18408
  plugins: [
18404
18409
  patchGlobal(),
18405
18410
  patchAstroInlineScripts(),
18406
- setupSsrContext(rootDir)
18411
+ setupSsrContext()
18407
18412
  ]
18408
18413
  }
18409
18414
  });
18415
+ if (options.enableAuthRoutes) {
18416
+ injectRoute({
18417
+ entrypoint: new URL(
18418
+ "../build-runtime/routes/auth/login.js",
18419
+ import.meta.url
18420
+ ),
18421
+ pattern: "/api/auth/login",
18422
+ prerender: false
18423
+ });
18424
+ injectRoute({
18425
+ entrypoint: new URL(
18426
+ "../build-runtime/routes/auth/logout.js",
18427
+ import.meta.url
18428
+ ),
18429
+ pattern: "/api/auth/logout",
18430
+ prerender: false
18431
+ });
18432
+ injectRoute({
18433
+ entrypoint: new URL(
18434
+ "../build-runtime/routes/auth/callback.js",
18435
+ import.meta.url
18436
+ ),
18437
+ pattern: "/api/auth/callback",
18438
+ prerender: false
18439
+ });
18440
+ injectRoute({
18441
+ entrypoint: new URL(
18442
+ "../build-runtime/routes/auth/logout-callback.js",
18443
+ import.meta.url
18444
+ ),
18445
+ pattern: "/api/auth/logout-callback",
18446
+ prerender: false
18447
+ });
18448
+ }
18410
18449
  const webhookCodegenDir = join7(codegenDir, "extensions/webhooks");
18411
18450
  await outputDir(webhookCodegenDir);
18412
18451
  if (command === "dev") {