@wix/astro 1.0.17 → 1.0.19

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
@@ -12286,7 +12286,7 @@ var require_lib = __commonJS({
12286
12286
  init_esm_shims();
12287
12287
  var import_chokidar = __toESM(require_chokidar(), 1);
12288
12288
  import { join as join7 } from "node:path";
12289
- import { fileURLToPath as fileURLToPath3 } from "node:url";
12289
+ import { fileURLToPath as fileURLToPath4 } from "node:url";
12290
12290
  import { envField, passthroughImageService } from "astro/config";
12291
12291
 
12292
12292
  // ../../node_modules/outdent/lib-module/index.js
@@ -12471,23 +12471,38 @@ function patchGlobal() {
12471
12471
  // src/plugins/setupSsrContext.ts
12472
12472
  init_esm_shims();
12473
12473
  import { extname, join as join2 } from "node:path";
12474
+ import { fileURLToPath } from "node:url";
12475
+ var nonElevatedSetupUrl = new URL(
12476
+ "../build-runtime/context/non-elevated.js",
12477
+ import.meta.url
12478
+ );
12479
+ var elevatedSetupUrl = new URL(
12480
+ "../build-runtime/context/elevated.js",
12481
+ import.meta.url
12482
+ );
12483
+ var whitelistedFilePaths = [
12484
+ fileURLToPath(
12485
+ new URL("../build-runtime/routes/auth/login.js", import.meta.url)
12486
+ ),
12487
+ fileURLToPath(
12488
+ new URL("../build-runtime/routes/auth/callback.js", import.meta.url)
12489
+ ),
12490
+ fileURLToPath(
12491
+ new URL("../build-runtime/routes/auth/logout.js", import.meta.url)
12492
+ ),
12493
+ fileURLToPath(
12494
+ new URL("../build-runtime/routes/auth/logout-callback.js", import.meta.url)
12495
+ )
12496
+ ];
12474
12497
  function setupSsrContext(rootDir) {
12475
12498
  const srcDir = join2(rootDir, SRC_DIR);
12476
- const nonElevatedSetupUrl = new URL(
12477
- "../build-runtime/context/non-elevated.js",
12478
- import.meta.url
12479
- );
12480
- const elevatedSetupUrl = new URL(
12481
- "../build-runtime/context/elevated.js",
12482
- import.meta.url
12483
- );
12484
12499
  return {
12485
12500
  applyToEnvironment(environment) {
12486
12501
  return environment.name === "ssr";
12487
12502
  },
12488
12503
  name: "setup-ssr-context",
12489
12504
  transform(code, id) {
12490
- if (!id.startsWith(srcDir)) {
12505
+ if (!id.startsWith(srcDir) && !whitelistedFilePaths.includes(id)) {
12491
12506
  return null;
12492
12507
  }
12493
12508
  const extension = extname(id);
@@ -12738,10 +12753,10 @@ var isSymlinkSync = isTypeSync.bind(void 0, "lstatSync", "isSymbolicLink");
12738
12753
  init_esm_shims();
12739
12754
  import { promisify } from "node:util";
12740
12755
  import { execFile as execFileCallback, execFileSync as execFileSyncOriginal } from "node:child_process";
12741
- import { fileURLToPath } from "node:url";
12756
+ import { fileURLToPath as fileURLToPath2 } from "node:url";
12742
12757
  var execFileOriginal = promisify(execFileCallback);
12743
12758
  function toPath(urlOrPath) {
12744
- return urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;
12759
+ return urlOrPath instanceof URL ? fileURLToPath2(urlOrPath) : urlOrPath;
12745
12760
  }
12746
12761
  var TEN_MEGABYTES_IN_BYTES = 10 * 1024 * 1024;
12747
12762
 
@@ -18112,11 +18127,11 @@ function isValidWebhookComponent(component) {
18112
18127
 
18113
18128
  // src/utils/resolveBuildMetadata.ts
18114
18129
  init_esm_shims();
18115
- import { fileURLToPath as fileURLToPath2 } from "node:url";
18130
+ import { fileURLToPath as fileURLToPath3 } from "node:url";
18116
18131
  async function resolveBuildMetadata(appManifestPath, config) {
18117
- const outDir = fileURLToPath2(config.outDir);
18118
- const buildClientDir = fileURLToPath2(config.build.client);
18119
- const buildServerDir = fileURLToPath2(config.build.server);
18132
+ const outDir = fileURLToPath3(config.outDir);
18133
+ const buildClientDir = fileURLToPath3(config.build.client);
18134
+ const buildServerDir = fileURLToPath3(config.build.server);
18120
18135
  const clientDir = await pathExists(buildClientDir) ? buildClientDir : outDir;
18121
18136
  const serverDir = await pathExists(buildServerDir) ? buildServerDir : void 0;
18122
18137
  return {
@@ -18159,7 +18174,7 @@ async function writeVirtualBackofficeExtensionFiles(model, codegenDir) {
18159
18174
  await writeFile2(
18160
18175
  virtualHocEntrypoint,
18161
18176
  defaultOutdent`
18162
- import Component from '${toRelativePath2(originalEntrypoint, virtualHocEntrypoint)}';
18177
+ import Component from '${toRelativePath2(virtualHocEntrypoint, originalEntrypoint)}';
18163
18178
  import { withContextualWixClient } from '@wix/dashboard/internal';
18164
18179
 
18165
18180
  export const WrappedComponent = withContextualWixClient(Component);
@@ -18173,7 +18188,7 @@ async function writeVirtualBackofficeExtensionFiles(model, codegenDir) {
18173
18188
  virtualEntrypoint,
18174
18189
  defaultOutdent`
18175
18190
  ---
18176
- import { WrappedComponent } from '${toRelativePath2(virtualHocEntrypoint, virtualEntrypoint)}';
18191
+ import { WrappedComponent } from '${toRelativePath2(virtualEntrypoint, virtualHocEntrypoint)}';
18177
18192
  ---
18178
18193
 
18179
18194
  <div>
@@ -18314,7 +18329,9 @@ async function writeVirtualWebhookExtensionFiles(model, codegenDir) {
18314
18329
  }
18315
18330
 
18316
18331
  // src/index.ts
18317
- var createIntegration = () => {
18332
+ var createIntegration = (options = {
18333
+ enableAuthRoutes: true
18334
+ }) => {
18318
18335
  let _config;
18319
18336
  let model = null;
18320
18337
  return {
@@ -18322,8 +18339,8 @@ var createIntegration = () => {
18322
18339
  async "astro:build:done"({ logger }) {
18323
18340
  model ??= await createProjectModel(logger);
18324
18341
  const appManifest = generateAppManifest(model);
18325
- const outDir = fileURLToPath3(_config.outDir);
18326
- const rootDir = fileURLToPath3(_config.root);
18342
+ const outDir = fileURLToPath4(_config.outDir);
18343
+ const rootDir = fileURLToPath4(_config.root);
18327
18344
  const appManifestPath = join7(outDir, "_wix/app-manifest.json");
18328
18345
  await writeJson(appManifestPath, appManifest, { spaces: 2 });
18329
18346
  await writeJson(
@@ -18346,8 +18363,8 @@ var createIntegration = () => {
18346
18363
  updateConfig
18347
18364
  }) {
18348
18365
  const codegenDirURL = createCodegenDir();
18349
- const codegenDir = fileURLToPath3(codegenDirURL);
18350
- const rootDir = fileURLToPath3(config.root);
18366
+ const codegenDir = fileURLToPath4(codegenDirURL);
18367
+ const rootDir = fileURLToPath4(config.root);
18351
18368
  model ??= await createProjectModel(logger);
18352
18369
  injectScript(
18353
18370
  "before-hydration",
@@ -18407,6 +18424,40 @@ var createIntegration = () => {
18407
18424
  ]
18408
18425
  }
18409
18426
  });
18427
+ if (options.enableAuthRoutes) {
18428
+ injectRoute({
18429
+ entrypoint: new URL(
18430
+ "../build-runtime/routes/auth/login.js",
18431
+ import.meta.url
18432
+ ),
18433
+ pattern: "/api/auth/login",
18434
+ prerender: false
18435
+ });
18436
+ injectRoute({
18437
+ entrypoint: new URL(
18438
+ "../build-runtime/routes/auth/logout.js",
18439
+ import.meta.url
18440
+ ),
18441
+ pattern: "/api/auth/logout",
18442
+ prerender: false
18443
+ });
18444
+ injectRoute({
18445
+ entrypoint: new URL(
18446
+ "../build-runtime/routes/auth/callback.js",
18447
+ import.meta.url
18448
+ ),
18449
+ pattern: "/api/auth/callback",
18450
+ prerender: false
18451
+ });
18452
+ injectRoute({
18453
+ entrypoint: new URL(
18454
+ "../build-runtime/routes/auth/logout-callback.js",
18455
+ import.meta.url
18456
+ ),
18457
+ pattern: "/api/auth/logout-callback",
18458
+ prerender: false
18459
+ });
18460
+ }
18410
18461
  const webhookCodegenDir = join7(codegenDir, "extensions/webhooks");
18411
18462
  await outputDir(webhookCodegenDir);
18412
18463
  if (command === "dev") {