@wix/astro 2.12.0 → 2.13.1

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.
@@ -11199,6 +11199,7 @@ import { fileURLToPath as fileURLToPath4 } from "url";
11199
11199
 
11200
11200
  // ../fs-utils/src/index.ts
11201
11201
  init_esm_shims();
11202
+ import { randomBytes } from "crypto";
11202
11203
  import {
11203
11204
  access,
11204
11205
  readFile as fsReadFile,
@@ -11206,8 +11207,8 @@ import {
11206
11207
  mkdir,
11207
11208
  rm
11208
11209
  } from "fs/promises";
11209
- import { EOL } from "os";
11210
- import { dirname } from "path";
11210
+ import { EOL, tmpdir } from "os";
11211
+ import { dirname, join } from "path";
11211
11212
  async function clearDir(dir) {
11212
11213
  await rm(dir, { recursive: true });
11213
11214
  await mkdir(dir);
@@ -11229,21 +11230,17 @@ async function writeJson(filePath, object, opts = { spaces: 2 }) {
11229
11230
  await writeFile(filePath, toJsonString(object, opts));
11230
11231
  }
11231
11232
 
11232
- // ../astro-backend-extensions/src/build-components/buildComponents.ts
11233
- init_esm_shims();
11234
- import { join as join4 } from "path";
11235
-
11236
- // ../astro-backend-extensions/src/build-components/buildServicePluginComponent.ts
11237
- init_esm_shims();
11238
- import { writeFile as writeFile2 } from "fs/promises";
11239
- import { join as join2 } from "path";
11240
-
11241
11233
  // ../vite-utils/src/index.ts
11242
11234
  init_esm_shims();
11243
11235
  import { ok } from "assert";
11244
- import { join } from "path";
11236
+ import { join as join2 } from "path";
11245
11237
  import { fileURLToPath as fileURLToPath2 } from "url";
11246
- import { build as viteBuild, normalizePath as viteNormalizePath } from "vite";
11238
+ import {
11239
+ createServer,
11240
+ mergeConfig,
11241
+ build as viteBuild,
11242
+ normalizePath as viteNormalizePath
11243
+ } from "vite";
11247
11244
  function appendToDevServerUrl(devServerUrl, relativePath) {
11248
11245
  const url = new URL(
11249
11246
  relativePath.replace(/^[\\/]/, "./"),
@@ -11267,6 +11264,19 @@ async function buildAll(configs) {
11267
11264
  }
11268
11265
  return viteBuildOutputToRollupOutputs(buildOutput);
11269
11266
  }
11267
+ async function createTemporaryViteServer(viteConfig) {
11268
+ const server = await createServer(
11269
+ mergeConfig(viteConfig, {
11270
+ logLevel: "silent",
11271
+ optimizeDeps: { noDiscovery: true },
11272
+ server: {
11273
+ middlewareMode: true,
11274
+ ws: false
11275
+ }
11276
+ })
11277
+ );
11278
+ return server;
11279
+ }
11270
11280
  function getAssetForModuleId({
11271
11281
  buildOutput,
11272
11282
  moduleId
@@ -11288,7 +11298,7 @@ function getAssetUrlForModuleId({
11288
11298
  devServer,
11289
11299
  moduleId
11290
11300
  }) {
11291
- const pathWithBase = join(devServer.config.base, "@id", `${moduleId}?import`);
11301
+ const pathWithBase = join2(devServer.config.base, "@id", `${moduleId}?import`);
11292
11302
  return appendToDevServerUrl(baseUrl, pathWithBase);
11293
11303
  }
11294
11304
  function getChunkForEntryName({
@@ -11315,6 +11325,15 @@ function getLocalDevServerUrl(server) {
11315
11325
  ok(devServerUrl != null);
11316
11326
  return devServerUrl;
11317
11327
  }
11328
+ async function loadFileWithVite(filename, server) {
11329
+ const module2 = await server.ssrLoadModule(filename).catch((error) => {
11330
+ if (error != null && typeof error === "object" && "code" in error && error.code === "ERR_LOAD_URL") {
11331
+ return null;
11332
+ }
11333
+ throw error;
11334
+ });
11335
+ return module2;
11336
+ }
11318
11337
  function viteBuildOutputToRollupOutputs(viteBuildOutput) {
11319
11338
  const isValidRollupOutput = "output" in viteBuildOutput || Array.isArray(viteBuildOutput);
11320
11339
  ok(isValidRollupOutput);
@@ -11325,6 +11344,15 @@ function normalizePath(id) {
11325
11344
  return viteNormalizePath(filePath);
11326
11345
  }
11327
11346
 
11347
+ // ../astro-backend-extensions/src/build-components/buildComponents.ts
11348
+ init_esm_shims();
11349
+ import { join as join5 } from "path";
11350
+
11351
+ // ../astro-backend-extensions/src/build-components/buildServicePluginComponent.ts
11352
+ init_esm_shims();
11353
+ import { writeFile as writeFile2 } from "fs/promises";
11354
+ import { join as join3 } from "path";
11355
+
11328
11356
  // ../../node_modules/outdent/lib-module/index.js
11329
11357
  init_esm_shims();
11330
11358
  function noop() {
@@ -11470,10 +11498,10 @@ async function buildServicePluginComponent({
11470
11498
  entryFileName,
11471
11499
  srcDir
11472
11500
  }) {
11473
- const directory = join2(codegenDir, compId);
11501
+ const directory = join3(codegenDir, compId);
11474
11502
  await outputDir(directory);
11475
- const entrypoint = join2(directory, `entry.ts`);
11476
- const entryFilePath = join2(srcDir, entryFileName);
11503
+ const entrypoint = join3(directory, `entry.ts`);
11504
+ const entryFilePath = join3(srcDir, entryFileName);
11477
11505
  await writeFile2(
11478
11506
  entrypoint,
11479
11507
  defaultOutdent`
@@ -11489,7 +11517,7 @@ async function buildServicePluginComponent({
11489
11517
  // ../astro-backend-extensions/src/build-components/buildWebhookComponent.ts
11490
11518
  init_esm_shims();
11491
11519
  import { writeFile as writeFile3 } from "fs/promises";
11492
- import { join as join3 } from "path";
11520
+ import { join as join4 } from "path";
11493
11521
  var setupWebhookUrl = new URL(
11494
11522
  "../dependencies/astro-backend-extensions/backend-runtime/runtime/setupWebhook.js",
11495
11523
  import.meta.url
@@ -11500,10 +11528,10 @@ async function buildWebhookComponent({
11500
11528
  entryFileName,
11501
11529
  srcDir
11502
11530
  }) {
11503
- const directory = join3(codegenDir, compId);
11531
+ const directory = join4(codegenDir, compId);
11504
11532
  await outputDir(directory);
11505
- const entrypoint = join3(directory, `entry.ts`);
11506
- const entryFilePath = join3(srcDir, entryFileName);
11533
+ const entrypoint = join4(directory, `entry.ts`);
11534
+ const entryFilePath = join4(srcDir, entryFileName);
11507
11535
  await writeFile3(
11508
11536
  entrypoint,
11509
11537
  defaultOutdent`
@@ -11522,8 +11550,8 @@ async function buildComponents({
11522
11550
  extensions,
11523
11551
  srcDir
11524
11552
  }) {
11525
- const webhooksCodegenDir = join4(codegenDir, "webhooks");
11526
- const servicePluginsCodegenDir = join4(codegenDir, "service-plugins");
11553
+ const webhooksCodegenDir = join5(codegenDir, "webhooks");
11554
+ const servicePluginsCodegenDir = join5(codegenDir, "service-plugins");
11527
11555
  for (const extension of extensions) {
11528
11556
  switch (extension.type) {
11529
11557
  case "EcomAdditionalFees": {
@@ -11595,7 +11623,86 @@ async function buildComponents({
11595
11623
 
11596
11624
  // ../astro-backend-extensions/src/utils/createExtensionManifest.ts
11597
11625
  init_esm_shims();
11598
- function createExtensionManifest(extension, baseUrl) {
11626
+
11627
+ // ../astro-backend-extensions/src/utils/legacyWebhookMap.ts
11628
+ init_esm_shims();
11629
+ var mapping = {
11630
+ AppInstalled: "APP_PROVISIONED_WEBHOOK",
11631
+ AppRemoved: "APP_REMOVED_WEBHOOK",
11632
+ "com.wix.bookings.api.v1.BookingNotification": "BOOKINGS.BOOKING.EVENTS",
11633
+ "com.wix.bookings.schedules.api.v1.ScheduleNotification": "BOOKINGS.SCHEDULES.EVENTS",
11634
+ "com.wix.ecommerce.cart.abandonment.api.v1.CartAbandonedEvent": "STORES_CART_ABANDONED_CART_WEBHOOK",
11635
+ "com.wix.ecommerce.cart.abandonment.api.v1.CartRecoveredEvent": "STORES_CART_RECOVERED_WEBHOOK",
11636
+ "com.wix.ecommerce.cart.api.v1.CartCompletedEvent": "STORES_CART_COMPLETED_WEBHOOK",
11637
+ "com.wix.ecommerce.cart.api.v1.CartCreatedEvent": "STORES_CART_CREATED_WEBHOOK",
11638
+ "com.wix.ecommerce.catalog.api.v1.CollectionChanged": "STORES_COLLECTION_CHANGED",
11639
+ "com.wix.ecommerce.catalog.api.v1.CollectionCreated": "STORES_COLLECTION_CREATED",
11640
+ "com.wix.ecommerce.catalog.api.v1.CollectionDeleted": "STORES_COLLECTION_DELETED",
11641
+ "com.wix.ecommerce.catalog.api.v1.ProductChanged": "STORES_PRODUCT_CHANGED",
11642
+ "com.wix.ecommerce.catalog.api.v1.ProductCreated": "STORES_PRODUCT_CREATED",
11643
+ "com.wix.ecommerce.catalog.api.v1.ProductDeleted": "STORES_PRODUCT_DELETED",
11644
+ "com.wix.ecommerce.catalog.api.v1.VariantsChanged": "STORES_VARIANTS_CHANGED",
11645
+ "com.wix.ecommerce.inventory.api.v1.InventoryItemChanged": "STORES_INVENTORY_ITEM_CHANGED",
11646
+ "com.wix.ecommerce.inventory.api.v1.InventoryVariantsChanged": "STORES_INVENTORY_VARIANTS_CHANGED",
11647
+ "com.wix.ecommerce.orders.api.v2.OrderEvent": "STORES_NEW_ORDER_WEBHOOK",
11648
+ "com.wix.payment.api.pay.v3.PaymentEvent": "CASHIER_PAYMENT_EVENT_WEBHOOK",
11649
+ "com.wixpress.bookings.resources.core.api.v1.resource.ResourceNotification": "BOOKINGS.RESOURCES.EVENTS",
11650
+ "com.wixpress.bookings.services.api.v1.CategoryNotification": "BOOKINGS.CATEGORIES.EVENTS",
11651
+ "com.wixpress.bookings.services.api.v1.FormNotification": "BOOKINGS.FORMS.EVENTS",
11652
+ "com.wixpress.bookings.services.api.v1.ServiceNotification": "BOOKINGS.SERVICES.EVENTS",
11653
+ "com.wixpress.emailsubscriptions.v1.EmailSubscriptionChanged": "EMAIL_SUBSCRIPTION_CHANGED",
11654
+ "com.wixpress.formbuilder.api.v1.FormSubmittedEvent": "CRM_FORM_SUBMITTED",
11655
+ FulfillmentCreated: "STORES_FULFILLMENT_CREATED",
11656
+ FulfillmentDeleted: "STORES_FULFILLMENT_DELETED",
11657
+ FulfillmentUpdated: "STORES_FULFILLMENT_UPDATED",
11658
+ NewMessageReceived: "WIX_CHAT_NEW_MESSAGE",
11659
+ OneTimePurchasesChanged: "wix.stores.v1.subscription_option_one_time_purcahse_changed",
11660
+ OrderCanceled: "STORES_ORDER_CANCEL_WEBHOOK",
11661
+ OrderPaid: "STORES_ORDER_PAID_WEBHOOK",
11662
+ OrderRefunded: "STORES_ORDER_REFUND_WEBHOOK",
11663
+ PaidPlanAutoRenewalCancelled: "APP_SUBSCRIPTION_CANCELLED_WEBHOOK",
11664
+ PaidPlanChanged: "APP_SUBSCRIPTION_CHANGED_WEBHOOK",
11665
+ PaidPlanPurchased: "APP_SUBSCRIPTION_CREATED_WEBHOOK",
11666
+ PlanConvertedToPaid: "APP-SUBSCRIPTION-CONVERTED-TO-PAID-WEBHOOK",
11667
+ PlanReactivated: "APP_SUBSCRIPTION_REACTIVATED_WEBHOOK",
11668
+ PlanTransferred: "APP_SUBSCRIPTION_TRANSFERRED_WEBHOOK",
11669
+ SitePropertiesUpdated: "SITE_PROPERTIES_UPDATED",
11670
+ SubscriptionOptionsAssignmentChangedForProduct: "wix.stores.v1.subscription_option_assigned",
11671
+ "wix.blog.v3.category_created": "wix.blog.category_created",
11672
+ "wix.blog.v3.category_deleted": "wix.blog.category_deleted",
11673
+ "wix.blog.v3.category_updated": "wix.blog.category_updated",
11674
+ "wix.blog.v3.post_created": "wix.blog.post_created",
11675
+ "wix.blog.v3.post_deleted": "wix.blog.post_deleted",
11676
+ "wix.blog.v3.post_liked": "wix.blog.post_liked",
11677
+ "wix.blog.v3.post_unliked": "wix.blog.post_unliked",
11678
+ "wix.events.events.EventCanceled": "EVENTS_EVENT_CANCELED_WEBHOOK",
11679
+ "wix.events.events.EventCreated": "EVENTS_EVENT_CREATED_WEBHOOK",
11680
+ "wix.events.events.EventDeleted": "EVENTS_EVENT_DELETED_WEBHOOK",
11681
+ "wix.events.events.EventEnded": "EVENTS_EVENT_ENDED_WEBHOOK",
11682
+ "wix.events.events.EventReminder": "EVENTS_EVENT_REMINDER",
11683
+ "wix.events.events.EventStarted": "EVENTS_EVENT_STARTED_WEBHOOK",
11684
+ "wix.events.events.EventUpdated": "EVENTS_EVENT_UPDATED_WEBHOOK",
11685
+ "wix.events.rsvp.events.RsvpCreated": "EVENTS_RSVP_CREATED_WEBHOOK",
11686
+ "wix.events.rsvp.events.RsvpDeleted": "EVENTS_RSVP_DELETED_WEBHOOK",
11687
+ "wix.events.rsvp.events.RsvpUpdated": "EVENTS_RSVP_UPDATED_WEBHOOK",
11688
+ "wix.events.ticketing.events.OrderConfirmed": "EVENTS_TICKETING_ORDER_CONFIRMED_WEBHOOK",
11689
+ "wix.events.ticketing.events.OrderDeleted": "EVENTS_TICKETING_ORDER_DELETED_WEBHOOK",
11690
+ "wix.events.ticketing.events.OrderInitiated": "EVENTS_TICKETING_ORDER_INITIATED_WEBHOOK",
11691
+ "wix.events.ticketing.events.OrderUpdated": "EVENTS_TICKETING_ORDER_UPDATED_WEBHOOK",
11692
+ "wix.events.ticketing.events.ReservationCreated": "EVENTS_TICKETING_RESERVATION_CREATED_WEBHOOK",
11693
+ "wix.events.ticketing.events.ReservationUpdated": "EVENTS_TICKETING_RESERVATION_UPDATED_WEBHOOK",
11694
+ "wix.events.ticketing.events.TicketDefinitionCreated": "EVENTS_TICKETING_TICKET_DEFINITION_CREATED_WEBHOOK",
11695
+ "wix.events.ticketing.events.TicketDefinitionDeleted": "EVENTS_TICKETING_TICKET_DEFINITION_DELETED_WEBHOOK",
11696
+ "wix.events.ticketing.events.TicketDefinitionUpdated": "EVENTS_TICKETING_TICKET_DEFINITION_UPDATED_WEBHOOK"
11697
+ };
11698
+ var legacyWebhookMap = new Map(Object.entries(mapping));
11699
+
11700
+ // ../astro-backend-extensions/src/utils/createExtensionManifest.ts
11701
+ async function createExtensionManifest({
11702
+ baseUrl,
11703
+ extension,
11704
+ temporaryViteServer
11705
+ }) {
11599
11706
  switch (extension.type) {
11600
11707
  case "EcomAdditionalFees": {
11601
11708
  return {
@@ -11696,8 +11803,23 @@ function createExtensionManifest(extension, baseUrl) {
11696
11803
  };
11697
11804
  }
11698
11805
  case "Webhook": {
11806
+ const module2 = await loadFileWithVite(
11807
+ extension.options.source,
11808
+ temporaryViteServer
11809
+ );
11810
+ if (!isValidEventFileExport(module2)) {
11811
+ throw new Error(
11812
+ [
11813
+ `Invalid export for event source at \`${extension.options.source}\`.`,
11814
+ `Expected event listener call to be the default export.`
11815
+ ].join("\n")
11816
+ );
11817
+ }
11818
+ const { slug } = module2.default();
11819
+ const webhookSlug = legacyWebhookMap.get(slug) ?? slug;
11699
11820
  return {
11700
11821
  compId: extension.options.id,
11822
+ compName: webhookSlug,
11701
11823
  compType: "WEBHOOK",
11702
11824
  compData: {
11703
11825
  webhook: {
@@ -11705,13 +11827,25 @@ function createExtensionManifest(extension, baseUrl) {
11705
11827
  baseUrl,
11706
11828
  `/_wix/extensions/webhooks/${extension.options.id}`
11707
11829
  ),
11708
- webhookSlug: extension.options.slug
11830
+ webhookSlug
11709
11831
  }
11710
11832
  }
11711
11833
  };
11712
11834
  }
11713
11835
  }
11714
11836
  }
11837
+ function isValidEventFileExport(module2) {
11838
+ if (typeof module2 !== "object" || module2 == null) {
11839
+ return false;
11840
+ }
11841
+ if (!("default" in module2)) {
11842
+ return false;
11843
+ }
11844
+ if (typeof module2.default !== "function") {
11845
+ return false;
11846
+ }
11847
+ return true;
11848
+ }
11715
11849
 
11716
11850
  // ../astro-backend-extensions/src/utils/filterSupportedExtensions.ts
11717
11851
  init_esm_shims();
@@ -12353,6 +12487,7 @@ async function removeUnusedCodegenFiles({
12353
12487
  var createIntegration = () => {
12354
12488
  let srcDir = null;
12355
12489
  let codegenDir = null;
12490
+ let temporaryViteServer = null;
12356
12491
  return {
12357
12492
  name: "@wix/astro/backend-extensions",
12358
12493
  hooks: {
@@ -12390,15 +12525,33 @@ var createIntegration = () => {
12390
12525
  await removeUnusedCodegenFiles({ codegenDir, extensions });
12391
12526
  await buildComponents({ codegenDir, extensions, srcDir });
12392
12527
  },
12393
- "wix:app-manifest:setup"({
12528
+ async "astro:server:done"() {
12529
+ await temporaryViteServer?.close();
12530
+ },
12531
+ async "wix:app-manifest:setup"({
12394
12532
  model,
12395
12533
  serverUrlPlaceholder: serverUrlPlaceholder2,
12396
12534
  updateAppManifest
12397
12535
  }) {
12536
+ ok2(srcDir != null);
12537
+ temporaryViteServer ??= await createTemporaryViteServer({
12538
+ root: srcDir,
12539
+ // this makes the temporary vite server have its own, separate, copy
12540
+ // of `@wix/sdk-context`, which means it runs in an isolated context
12541
+ // than that of the dev server.
12542
+ ssr: { noExternal: true }
12543
+ });
12398
12544
  const extensions = model.extensions.filter(filterSupportedExtensions);
12399
12545
  updateAppManifest({
12400
- components: extensions.map(
12401
- (extension) => createExtensionManifest(extension, serverUrlPlaceholder2)
12546
+ components: await Promise.all(
12547
+ extensions.map(async (extension) => {
12548
+ ok2(temporaryViteServer);
12549
+ return createExtensionManifest({
12550
+ baseUrl: serverUrlPlaceholder2,
12551
+ extension,
12552
+ temporaryViteServer
12553
+ });
12554
+ })
12402
12555
  )
12403
12556
  });
12404
12557
  }
@@ -12479,12 +12632,12 @@ import { fileURLToPath as fileURLToPath5 } from "url";
12479
12632
 
12480
12633
  // ../astro-backoffice-extensions/src/build-components/buildComponents.ts
12481
12634
  init_esm_shims();
12482
- import { join as join6 } from "path";
12635
+ import { join as join7 } from "path";
12483
12636
 
12484
12637
  // ../astro-backoffice-extensions/src/build-components/buildBackofficeComponent.ts
12485
12638
  init_esm_shims();
12486
12639
  import { writeFile as writeFile4 } from "fs/promises";
12487
- import { join as join5 } from "path";
12640
+ import { join as join6 } from "path";
12488
12641
  var wrapComponentUrl = new URL(
12489
12642
  "../dependencies/astro-backoffice-extensions/browser-runtime/wrapComponent.js",
12490
12643
  import.meta.url
@@ -12495,10 +12648,10 @@ async function buildBackofficeComponent({
12495
12648
  entryFileName,
12496
12649
  srcDir
12497
12650
  }) {
12498
- const directory = join5(codegenDir, compId);
12651
+ const directory = join6(codegenDir, compId);
12499
12652
  await outputDir(directory);
12500
- const entryFilePath = join5(srcDir, entryFileName);
12501
- const HocEntrypoint = join5(directory, `wrapper.tsx`);
12653
+ const entryFilePath = join6(srcDir, entryFileName);
12654
+ const HocEntrypoint = join6(directory, `wrapper.tsx`);
12502
12655
  await writeFile4(
12503
12656
  HocEntrypoint,
12504
12657
  defaultOutdent`
@@ -12508,7 +12661,7 @@ async function buildBackofficeComponent({
12508
12661
  export const WrappedComponent = wrapComponent(Component);
12509
12662
  `
12510
12663
  );
12511
- const entrypoint = join5(directory, `entry.astro`);
12664
+ const entrypoint = join6(directory, `entry.astro`);
12512
12665
  await writeFile4(
12513
12666
  entrypoint,
12514
12667
  defaultOutdent`
@@ -12534,7 +12687,7 @@ async function buildComponents2({
12534
12687
  extensions,
12535
12688
  srcDir
12536
12689
  }) {
12537
- const backofficeCodegenDir = join6(codegenDir, "backoffice");
12690
+ const backofficeCodegenDir = join7(codegenDir, "backoffice");
12538
12691
  for (const extension of extensions) {
12539
12692
  switch (extension.type) {
12540
12693
  case "BackofficeExtensionMenuPlugin": {
@@ -12767,7 +12920,7 @@ init_esm_shims();
12767
12920
  // ../astro-core/src/integration.ts
12768
12921
  init_esm_shims();
12769
12922
  import { ok as ok5 } from "assert";
12770
- import { join as join8 } from "path";
12923
+ import { join as join9 } from "path";
12771
12924
  import { fileURLToPath as fileURLToPath7 } from "url";
12772
12925
  import { envField, passthroughImageService } from "astro/config";
12773
12926
 
@@ -12941,8 +13094,8 @@ function getLocalDevServerRootUrl(server) {
12941
13094
  init_esm_shims();
12942
13095
  import { ok as ok4 } from "assert";
12943
13096
  import { createHash } from "crypto";
12944
- import { join as join7 } from "path";
12945
- import { mergeConfig } from "vite";
13097
+ import { join as join8 } from "path";
13098
+ import { mergeConfig as mergeConfig2 } from "vite";
12946
13099
  function createExtensionViteConfigFactory({
12947
13100
  command,
12948
13101
  config: astroConfig,
@@ -12959,7 +13112,7 @@ function createExtensionViteConfigFactory({
12959
13112
  if (command === "serve") {
12960
13113
  commandConfig.base = `${EXTENSION_PROXY_BASE}/${extensionId}/`;
12961
13114
  }
12962
- return mergeConfig(
13115
+ return mergeConfig2(
12963
13116
  {
12964
13117
  build: {
12965
13118
  assetsDir: outputDir2,
@@ -12968,20 +13121,20 @@ function createExtensionViteConfigFactory({
12968
13121
  rollupOptions: {
12969
13122
  output: {
12970
13123
  assetFileNames: normalizePath(
12971
- join7(outputDir2, `[name]-[hash][extname]`)
13124
+ join8(outputDir2, `[name]-[hash][extname]`)
12972
13125
  ),
12973
13126
  chunkFileNames: normalizePath(
12974
- join7(outputDir2, `[name]-[hash].js`)
13127
+ join8(outputDir2, `[name]-[hash].js`)
12975
13128
  ),
12976
13129
  entryFileNames: normalizePath(
12977
- join7(outputDir2, `[name]-[hash].js`)
13130
+ join8(outputDir2, `[name]-[hash].js`)
12978
13131
  ),
12979
13132
  format: "esm"
12980
13133
  }
12981
13134
  },
12982
13135
  target: astroConfig.build.target
12983
13136
  },
12984
- cacheDir: join7("node_modules", ".vite-wix", extensionId),
13137
+ cacheDir: join8("node_modules", ".vite-wix", extensionId),
12985
13138
  clearScreen: false,
12986
13139
  configFile: false,
12987
13140
  customLogger: astroConfig.customLogger,
@@ -13007,7 +13160,6 @@ function createShortHash(str) {
13007
13160
  // ../astro-core/src/utils/createModel.ts
13008
13161
  init_esm_shims();
13009
13162
  import EventEmitter from "events";
13010
- import { createServer, mergeConfig as mergeConfig2 } from "vite";
13011
13163
 
13012
13164
  // ../astro-core/src/utils/loadEnvVars.ts
13013
13165
  init_esm_shims();
@@ -13580,10 +13732,9 @@ async function createModel({
13580
13732
  srcDir
13581
13733
  }) {
13582
13734
  const { appId, env: env2 } = loadEnvVars({ logger, rootDir });
13583
- const server = await getTempViteServer({
13584
- viteConfig: {
13585
- root: srcDir
13586
- }
13735
+ const server = await createTemporaryViteServer({
13736
+ root: srcDir,
13737
+ ssr: { external: [] }
13587
13738
  });
13588
13739
  const extensions = await loadExtensions(server);
13589
13740
  const model = new Model({
@@ -13595,33 +13746,9 @@ async function createModel({
13595
13746
  });
13596
13747
  return model;
13597
13748
  }
13598
- async function getTempViteServer({
13599
- viteConfig
13600
- }) {
13601
- const tempViteServer = await createServer(
13602
- mergeConfig2(viteConfig, {
13603
- logLevel: "silent",
13604
- optimizeDeps: { noDiscovery: true },
13605
- server: {
13606
- middlewareMode: true,
13607
- ws: false
13608
- },
13609
- ssr: { external: [] }
13610
- })
13611
- );
13612
- return tempViteServer;
13613
- }
13614
13749
  async function loadExtensions(server) {
13615
- const mod = await server.ssrLoadModule("/extensions.ts").catch((error) => {
13616
- if (error != null && typeof error === "object" && "code" in error && error.code === "ERR_LOAD_URL") {
13617
- return null;
13618
- }
13619
- throw error;
13620
- });
13621
- if (mod) {
13622
- return mod.default.extensions;
13623
- }
13624
- return [];
13750
+ const module2 = await loadFileWithVite("/extensions.ts", server);
13751
+ return module2 ? module2.default.extensions : [];
13625
13752
  }
13626
13753
 
13627
13754
  // ../astro-core/src/utils/generateBuildMetadata.ts
@@ -13783,8 +13910,8 @@ var createIntegration3 = ({
13783
13910
  ok5(model);
13784
13911
  const rootDir = fileURLToPath7(config.root);
13785
13912
  const outDir = fileURLToPath7(config.outDir);
13786
- const buildMetadataPath = join8(rootDir, ".wix/build-metadata.json");
13787
- const appManifestPath = join8(outDir, "_wix/app-manifest.json");
13913
+ const buildMetadataPath = join9(rootDir, ".wix/build-metadata.json");
13914
+ const appManifestPath = join9(outDir, "_wix/app-manifest.json");
13788
13915
  const buildMetadata = await generateBuildMetadata(
13789
13916
  appManifestPath,
13790
13917
  config
@@ -13826,6 +13953,25 @@ init_esm_shims();
13826
13953
  init_esm_shims();
13827
13954
  import { ok as ok7 } from "assert";
13828
13955
  import { fileURLToPath as fileURLToPath8 } from "url";
13956
+
13957
+ // ../frontend-dependencies-utils/src/index.ts
13958
+ init_esm_shims();
13959
+ var allFrontendDependencies = [
13960
+ { packageName: "@wix/site-crm", version: 1 },
13961
+ { packageName: "@wix/site-ecom", version: 1 },
13962
+ { packageName: "@wix/site-location", version: 1 },
13963
+ { packageName: "@wix/site-members", version: 1 },
13964
+ { packageName: "@wix/site-pay", version: 1 },
13965
+ { packageName: "@wix/site-pricing-plans", version: 1 },
13966
+ { packageName: "@wix/site-seo", version: 1 },
13967
+ { packageName: "@wix/site-site", version: 1 },
13968
+ { packageName: "@wix/site-storage", version: 1 },
13969
+ { packageName: "@wix/site-stores", version: 1 },
13970
+ { packageName: "@wix/site-window", version: 1 },
13971
+ { packageName: "@wix/site-realtime", version: 1 }
13972
+ ];
13973
+
13974
+ // ../astro-custom-elements-extensions/src/integration.ts
13829
13975
  import { createServer as createServer2 } from "vite";
13830
13976
 
13831
13977
  // ../astro-custom-elements-extensions/src/utils/filterSupportedExtensions.ts
@@ -13836,7 +13982,7 @@ function filterSupportedExtensions3(extension) {
13836
13982
 
13837
13983
  // ../astro-custom-elements-extensions/src/utils/getAssetUrl.ts
13838
13984
  init_esm_shims();
13839
- import { join as join9 } from "path";
13985
+ import { join as join10 } from "path";
13840
13986
  function getAssetUrl({
13841
13987
  buildOutput,
13842
13988
  fileName,
@@ -13854,12 +14000,12 @@ function getAssetUrlForDevServer({
13854
14000
  fileName,
13855
14001
  viteDevServer
13856
14002
  }) {
13857
- return join9(viteDevServer.config.base, fileName);
14003
+ return join10(viteDevServer.config.base, fileName);
13858
14004
  }
13859
14005
 
13860
14006
  // ../astro-custom-elements-extensions/src/utils/getChunkUrl.ts
13861
14007
  init_esm_shims();
13862
- import { join as join10 } from "path";
14008
+ import { join as join11 } from "path";
13863
14009
  function getChunkUrl({
13864
14010
  buildOutput,
13865
14011
  fileName,
@@ -13883,12 +14029,12 @@ function getChunkUrlForDevServer({
13883
14029
  fileName,
13884
14030
  viteDevServer
13885
14031
  }) {
13886
- return join10(viteDevServer.config.base, "@id", `${fileName}?import`);
14032
+ return join11(viteDevServer.config.base, "@id", `${fileName}?import`);
13887
14033
  }
13888
14034
 
13889
14035
  // ../astro-custom-elements-extensions/src/vite/getViteConfig.ts
13890
14036
  init_esm_shims();
13891
- import { join as join12 } from "path";
14037
+ import { join as join13 } from "path";
13892
14038
 
13893
14039
  // ../../node_modules/vite-plugin-externals/dist/es/src/index.js
13894
14040
  init_esm_shims();
@@ -20988,7 +21134,7 @@ init_esm_shims();
20988
21134
  import React from "react";
20989
21135
  import ReactDOM from "react-dom";
20990
21136
  import { ok as ok6 } from "assert";
20991
- import { join as join11, parse as parse4 } from "path";
21137
+ import { join as join12, parse as parse4 } from "path";
20992
21138
  import { send } from "vite";
20993
21139
  var wrapCustomElementPath = normalizePath(
20994
21140
  new URL(
@@ -21016,7 +21162,6 @@ var customElementHmrPath = normalizePath(
21016
21162
  );
21017
21163
  function viteWrapCustomElementPlugin({
21018
21164
  getExtensions,
21019
- mode,
21020
21165
  srcDir
21021
21166
  }) {
21022
21167
  const getExtensionForModuleId = (baseId) => {
@@ -21025,12 +21170,15 @@ function viteWrapCustomElementPlugin({
21025
21170
  );
21026
21171
  return result;
21027
21172
  };
21028
- const reactFileSuffix = mode === "build" ? "production.min.js" : "development.js";
21029
- const reactTemplate = defaultOutdent`
21173
+ const htmlTemplate = ({
21174
+ dev,
21175
+ setupCode
21176
+ }) => {
21177
+ const reactFileSuffix = dev ? "development.js" : "production.min.js";
21178
+ const reactTemplate = defaultOutdent`
21030
21179
  <script crossorigin src="https://static.parastorage.com/unpkg/react@${React.version}/umd/react.${reactFileSuffix}"></script>
21031
21180
  <script crossorigin src="https://static.parastorage.com/unpkg/react-dom@${ReactDOM.version}/umd/react-dom.${reactFileSuffix}"></script>
21032
21181
  `;
21033
- const htmlTemplate = (setupCode) => {
21034
21182
  return defaultOutdent`
21035
21183
  <!DOCTYPE html>
21036
21184
  <html>
@@ -21061,28 +21209,31 @@ function viteWrapCustomElementPlugin({
21061
21209
  if (extension === ".html") {
21062
21210
  const customElement2 = getExtensionForModuleId(baseId);
21063
21211
  if (customElement2?.options.settings != null) {
21064
- const filePath = join11(srcDir, customElement2.options.settings);
21212
+ const filePath = join12(srcDir, customElement2.options.settings);
21065
21213
  const transformedHtml = await server.transformIndexHtml(
21066
21214
  baseId,
21067
- htmlTemplate(defaultOutdent`
21068
- import { createComponentHmrWrapper } from '${reactHmrPath}';
21069
- import { renderSettingsPanel } from '${renderSettingsPanelPath}';
21070
- import SettingsPanel from '${normalizePath(filePath)}';
21071
-
21072
- let WrappedComponent = SettingsPanel;
21073
-
21074
- if (import.meta.hot) {
21075
- import.meta.hot.accept('${normalizePath(filePath)}', (newModule) => {
21076
- if (newModule?.default) {
21077
- import.meta.hot.data.setComponent?.(newModule?.default);
21078
- }
21079
- });
21080
-
21081
- WrappedComponent = createComponentHmrWrapper(SettingsPanel, import.meta.hot.data);
21082
- }
21215
+ htmlTemplate({
21216
+ dev: true,
21217
+ setupCode: defaultOutdent`
21218
+ import { createComponentHmrWrapper } from '${reactHmrPath}';
21219
+ import { renderSettingsPanel } from '${renderSettingsPanelPath}';
21220
+ import SettingsPanel from '${normalizePath(filePath)}';
21221
+
21222
+ let WrappedComponent = SettingsPanel;
21223
+
21224
+ if (import.meta.hot) {
21225
+ import.meta.hot.accept('${normalizePath(filePath)}', (newModule) => {
21226
+ if (newModule?.default) {
21227
+ import.meta.hot.data.setComponent?.(newModule?.default);
21228
+ }
21229
+ });
21230
+
21231
+ WrappedComponent = createComponentHmrWrapper(SettingsPanel, import.meta.hot.data);
21232
+ }
21083
21233
 
21084
- renderSettingsPanel(WrappedComponent);
21085
- `)
21234
+ renderSettingsPanel(WrappedComponent);
21235
+ `
21236
+ })
21086
21237
  );
21087
21238
  return send(req, res, transformedHtml, "html", {
21088
21239
  headers: server.config.server.headers
@@ -21103,19 +21254,22 @@ function viteWrapCustomElementPlugin({
21103
21254
  if (extension === ".html") {
21104
21255
  const customElement3 = getExtensionForModuleId(baseId);
21105
21256
  if (customElement3?.options.settings != null) {
21106
- const filePath = join11(srcDir, customElement3.options.settings);
21107
- return htmlTemplate(defaultOutdent`
21108
- import { renderSettingsPanel } from '${renderSettingsPanelPath}';
21109
- import SettingsPanel from '${normalizePath(filePath)}';
21257
+ const filePath = join12(srcDir, customElement3.options.settings);
21258
+ return htmlTemplate({
21259
+ dev: false,
21260
+ setupCode: defaultOutdent`
21261
+ import { renderSettingsPanel } from '${renderSettingsPanelPath}';
21262
+ import SettingsPanel from '${normalizePath(filePath)}';
21110
21263
 
21111
- renderSettingsPanel(SettingsPanel);
21112
- `);
21264
+ renderSettingsPanel(SettingsPanel);
21265
+ `
21266
+ });
21113
21267
  }
21114
21268
  throw new Error("Unexpected configuration");
21115
21269
  }
21116
21270
  const customElement2 = getExtensionForModuleId(baseId);
21117
21271
  if (customElement2) {
21118
- const filePath = join11(srcDir, customElement2.options.element);
21272
+ const filePath = join12(srcDir, customElement2.options.element);
21119
21273
  return defaultOutdent`
21120
21274
  import CustomElement from '${normalizePath(filePath)}';
21121
21275
  import { wrapCustomElement } from '${wrapCustomElementPath}';
@@ -21172,7 +21326,6 @@ function parseId(id) {
21172
21326
  function getViteConfig({
21173
21327
  createExtensionViteConfig,
21174
21328
  getExtensions,
21175
- mode,
21176
21329
  rootDir,
21177
21330
  srcDir
21178
21331
  }) {
@@ -21180,13 +21333,13 @@ function getViteConfig({
21180
21333
  const entries = [`${extension.options.id}.js`];
21181
21334
  if (extension.options.settings != null) {
21182
21335
  entries.push(
21183
- join12(rootDir, `custom-element-panels/${extension.options.id}.html`)
21336
+ join13(rootDir, `custom-element-panels/${extension.options.id}.html`)
21184
21337
  );
21185
21338
  }
21186
21339
  return entries;
21187
21340
  });
21188
21341
  const extensionsPaths = getExtensions().map((extension) => {
21189
- return join12(srcDir, extension.options.element);
21342
+ return join13(srcDir, extension.options.element);
21190
21343
  });
21191
21344
  return createExtensionViteConfig({
21192
21345
  name: "custom-elements",
@@ -21206,7 +21359,7 @@ function getViteConfig({
21206
21359
  ]
21207
21360
  },
21208
21361
  plugins: [
21209
- viteWrapCustomElementPlugin({ getExtensions, mode, srcDir }),
21362
+ viteWrapCustomElementPlugin({ getExtensions, srcDir }),
21210
21363
  viteExternalsPlugin({
21211
21364
  react: "React",
21212
21365
  "react-dom": "ReactDOM"
@@ -21251,7 +21404,6 @@ var createIntegration4 = () => {
21251
21404
  getViteConfig({
21252
21405
  createExtensionViteConfig,
21253
21406
  getExtensions,
21254
- mode: "dev",
21255
21407
  rootDir,
21256
21408
  srcDir
21257
21409
  })
@@ -21274,7 +21426,6 @@ var createIntegration4 = () => {
21274
21426
  getViteConfig({
21275
21427
  createExtensionViteConfig,
21276
21428
  getExtensions,
21277
- mode: "build",
21278
21429
  rootDir,
21279
21430
  srcDir
21280
21431
  })
@@ -21321,8 +21472,7 @@ var createIntegration4 = () => {
21321
21472
  }
21322
21473
  } : {}
21323
21474
  },
21324
- dependencies: [],
21325
- // TODO: frontend dependencies
21475
+ dependencies: allFrontendDependencies,
21326
21476
  installation: {
21327
21477
  base: {
21328
21478
  autoAdd: extension.options.installation.autoAdd,
@@ -21369,7 +21519,7 @@ import { ok as ok10 } from "assert";
21369
21519
  import {
21370
21520
  dirname as dirname2,
21371
21521
  isAbsolute as isAbsolutePath,
21372
- join as join15,
21522
+ join as join16,
21373
21523
  relative
21374
21524
  } from "path";
21375
21525
  import { fileURLToPath as fileURLToPath11 } from "url";
@@ -29428,13 +29578,13 @@ function getAssetContentFromBuildOutput({
29428
29578
 
29429
29579
  // ../astro-embedded-scripts-extensions/src/utils/getViteConfig.ts
29430
29580
  init_esm_shims();
29431
- import { join as join14 } from "path";
29581
+ import { join as join15 } from "path";
29432
29582
  import { fileURLToPath as fileURLToPath10 } from "url";
29433
29583
 
29434
29584
  // ../astro-embedded-scripts-extensions/src/utils/viteSdkSupportPlugin.ts
29435
29585
  init_esm_shims();
29436
29586
  import { ok as ok9 } from "assert";
29437
- import { join as join13 } from "path";
29587
+ import { join as join14 } from "path";
29438
29588
  import { fileURLToPath as fileURLToPath9 } from "url";
29439
29589
 
29440
29590
  // ../astro-embedded-scripts-extensions/src/utils/htmlUtils.ts
@@ -29544,7 +29694,7 @@ function resolveRuntimeScriptPath({
29544
29694
  server
29545
29695
  }) {
29546
29696
  if (server) {
29547
- return join13(server.config.base, "/@fs", fileURLToPath9(setupContextUrl));
29697
+ return join14(server.config.base, "/@fs", fileURLToPath9(setupContextUrl));
29548
29698
  }
29549
29699
  if (bundle) {
29550
29700
  const runtimeChunk = Object.values(bundle).find(
@@ -29573,7 +29723,7 @@ function getViteConfig2({
29573
29723
  const input = [
29574
29724
  setupContextUrl2,
29575
29725
  ...extensions.map(
29576
- (embeddedScript2) => join14(srcDir, embeddedScript2.options.source)
29726
+ (embeddedScript2) => join15(srcDir, embeddedScript2.options.source)
29577
29727
  )
29578
29728
  ];
29579
29729
  return createExtensionViteConfig({
@@ -29668,7 +29818,7 @@ var createIntegration5 = () => {
29668
29818
  for (const extension of extensions) {
29669
29819
  const fileName = relative(
29670
29820
  rootDir,
29671
- join15(srcDir, extension.options.source)
29821
+ join16(srcDir, extension.options.source)
29672
29822
  );
29673
29823
  const html = await getAssetContent({
29674
29824
  buildOutput: customBuildOutput,
@@ -29684,7 +29834,7 @@ var createIntegration5 = () => {
29684
29834
  if (srcAttr.value.startsWith("//") || isAbsoluteUrl(srcAttr.value)) {
29685
29835
  return;
29686
29836
  }
29687
- const normalizedValue = isAbsolutePath(srcAttr.value) ? srcAttr.value : join15(
29837
+ const normalizedValue = isAbsolutePath(srcAttr.value) ? srcAttr.value : join16(
29688
29838
  customDevServer?.config.base ?? "",
29689
29839
  dirname2(fileName),
29690
29840
  srcAttr.value
@@ -29701,8 +29851,7 @@ var createIntegration5 = () => {
29701
29851
  name: extension.options.name,
29702
29852
  allowedForFreeSite: true,
29703
29853
  connectArticleUrl: "",
29704
- dependencies: [],
29705
- // TODO: frontend dependencies
29854
+ dependencies: allFrontendDependencies,
29706
29855
  embedCategory: extension.options.scriptType,
29707
29856
  loadOnce: true,
29708
29857
  pages: "NONE_PAGES",
@@ -29746,7 +29895,7 @@ import { ok as ok11 } from "assert";
29746
29895
 
29747
29896
  // ../astro-site-component-panels-extensions/src/utils/getSupportedExtensions.ts
29748
29897
  init_esm_shims();
29749
- import { join as join16 } from "path";
29898
+ import { join as join17 } from "path";
29750
29899
  function getSupportedExtensions({
29751
29900
  extensions,
29752
29901
  srcDir
@@ -29756,7 +29905,7 @@ function getSupportedExtensions({
29756
29905
  );
29757
29906
  return siteComponentPanelExtensions.map((extension) => ({
29758
29907
  ...extension,
29759
- componentPath: join16(srcDir, extension.options.component)
29908
+ componentPath: join17(srcDir, extension.options.component)
29760
29909
  }));
29761
29910
  }
29762
29911
 
@@ -30086,11 +30235,11 @@ import { createServer as createServer5 } from "vite";
30086
30235
 
30087
30236
  // ../astro-site-components-extensions/src/utils/getPresets.ts
30088
30237
  init_esm_shims();
30089
- import { join as join19 } from "path";
30238
+ import { join as join20 } from "path";
30090
30239
 
30091
30240
  // ../astro-site-components-extensions/src/vite/client/build-config.ts
30092
30241
  init_esm_shims();
30093
- import { join as join18 } from "path";
30242
+ import { join as join19 } from "path";
30094
30243
 
30095
30244
  // ../astro-site-components-extensions/src/vite/shared.ts
30096
30245
  init_esm_shims();
@@ -30184,7 +30333,7 @@ init_esm_shims();
30184
30333
 
30185
30334
  // ../astro-site-components-extensions/src/utils/getSupportedExtensions.ts
30186
30335
  init_esm_shims();
30187
- import { join as join17 } from "path";
30336
+ import { join as join18 } from "path";
30188
30337
  function getSupportedExtensions2({
30189
30338
  extensions,
30190
30339
  srcDir
@@ -30196,15 +30345,15 @@ function getSupportedExtensions2({
30196
30345
  ).map(([name, { source, ...config }]) => ({
30197
30346
  name,
30198
30347
  config,
30199
- path: join17(srcDir, source),
30348
+ path: join18(srcDir, source),
30200
30349
  source
30201
30350
  }));
30202
30351
  return {
30203
30352
  ...extension,
30204
- componentPath: join17(srcDir, extension.options.resources.client.component),
30353
+ componentPath: join18(srcDir, extension.options.resources.client.component),
30205
30354
  componentPresets,
30206
- editorPreviewPath: extension.options.resources.editor?.component != null ? join17(srcDir, extension.options.resources.editor.component) : null,
30207
- sdkPath: extension.options.resources.sdk != null ? join17(srcDir, extension.options.resources.sdk) : null
30355
+ editorPreviewPath: extension.options.resources.editor?.component != null ? join18(srcDir, extension.options.resources.editor.component) : null,
30356
+ sdkPath: extension.options.resources.sdk != null ? join18(srcDir, extension.options.resources.sdk) : null
30208
30357
  };
30209
30358
  });
30210
30359
  }
@@ -30220,7 +30369,7 @@ function getSiteComponent(model, id) {
30220
30369
  }
30221
30370
 
30222
30371
  // ../astro-site-components-extensions/src/vite/client/virtual-module.ts
30223
- function getComponentBuildTemplate(componentPath) {
30372
+ function getClientComponentBuildTemplate(componentPath) {
30224
30373
  return defaultOutdent`
30225
30374
  import { createContext } from '${sdkRuntimePath2}';
30226
30375
 
@@ -30229,7 +30378,7 @@ function getComponentBuildTemplate(componentPath) {
30229
30378
  export { default } from '${componentPath}';
30230
30379
  `;
30231
30380
  }
30232
- function getComponentServeTemplate(componentPath) {
30381
+ function getClientComponentServeTemplate(componentPath) {
30233
30382
  return defaultOutdent`
30234
30383
  import { createContext } from '${sdkRuntimePath2}';
30235
30384
  import { createComponentHmrWrapper } from '${hmrRuntimePath2}';
@@ -30252,23 +30401,23 @@ function getComponentServeTemplate(componentPath) {
30252
30401
  export default WrappedComponent;
30253
30402
  `;
30254
30403
  }
30255
- function getVirtualModuleIdForComponent2(componentId) {
30404
+ function getVirtualModuleIdForClientComponent(componentId) {
30256
30405
  return `wix/component/${componentId}`;
30257
30406
  }
30258
- function registerComponentVirtualRoute({
30407
+ function registerClientVirtualRoute({
30259
30408
  model,
30260
30409
  router
30261
30410
  }) {
30262
30411
  router.route(
30263
- getVirtualModuleIdForComponent2(":id"),
30412
+ getVirtualModuleIdForClientComponent(":id"),
30264
30413
  ({ id }, { command }) => {
30265
30414
  const extension = getSiteComponent(model, id);
30266
30415
  if (extension) {
30267
30416
  const componentPath = normalizePath(extension.componentPath);
30268
30417
  if (command === "build") {
30269
- return getComponentBuildTemplate(componentPath);
30418
+ return getClientComponentBuildTemplate(componentPath);
30270
30419
  }
30271
- return getComponentServeTemplate(componentPath);
30420
+ return getClientComponentServeTemplate(componentPath);
30272
30421
  }
30273
30422
  return null;
30274
30423
  }
@@ -30277,23 +30426,23 @@ function registerComponentVirtualRoute({
30277
30426
 
30278
30427
  // ../astro-site-components-extensions/src/vite/editor/virtual-module.ts
30279
30428
  init_esm_shims();
30280
- function getVirtualModuleIdForPreview(componentId) {
30281
- return `wix/component-preview/${componentId}`;
30429
+ function getVirtualModuleIdForEditorComponent(componentId) {
30430
+ return `wix/component-editor/${componentId}`;
30282
30431
  }
30283
- function registerPreviewVirtualRoute({
30432
+ function registerEditorVirtualRoute({
30284
30433
  model,
30285
30434
  router
30286
30435
  }) {
30287
30436
  router.route(
30288
- getVirtualModuleIdForPreview(":id"),
30437
+ getVirtualModuleIdForEditorComponent(":id"),
30289
30438
  ({ id }, { command }) => {
30290
30439
  const extension = getSiteComponent(model, id);
30291
30440
  if (extension?.editorPreviewPath != null) {
30292
30441
  const componentPath = normalizePath(extension.editorPreviewPath);
30293
30442
  if (command === "build") {
30294
- return getComponentBuildTemplate(componentPath);
30443
+ return getClientComponentBuildTemplate(componentPath);
30295
30444
  }
30296
- return getComponentServeTemplate(componentPath);
30445
+ return getClientComponentServeTemplate(componentPath);
30297
30446
  }
30298
30447
  return null;
30299
30448
  }
@@ -30309,27 +30458,41 @@ function registerSdkVirtualRoute({
30309
30458
  model,
30310
30459
  router
30311
30460
  }) {
30312
- router.route(getVirtualModuleIdForSdk(":id"), ({ id }) => {
30313
- const extension = getSiteComponent(model, id);
30314
- if (extension?.sdkPath != null) {
30315
- const sdkPath = normalizePath(extension.sdkPath);
30316
- return defaultOutdent`
30317
- if (import.meta.hot) {
30318
- import.meta.hot.accept((_) => {});
30461
+ router.route(
30462
+ getVirtualModuleIdForSdk(":id"),
30463
+ ({ id }, { command }) => {
30464
+ const extension = getSiteComponent(model, id);
30465
+ if (extension?.sdkPath != null) {
30466
+ const sdkPath = normalizePath(extension.sdkPath);
30467
+ if (command === "build") {
30468
+ return getBuildTemplate2(sdkPath);
30319
30469
  }
30320
-
30321
- export { default } from '${sdkPath}';
30322
- `;
30470
+ return getServeTemplate2(sdkPath);
30471
+ }
30472
+ return null;
30323
30473
  }
30324
- return null;
30325
- });
30474
+ );
30475
+ }
30476
+ function getBuildTemplate2(sdkPath) {
30477
+ return defaultOutdent`
30478
+ export { default } from '${sdkPath}';
30479
+ `;
30480
+ }
30481
+ function getServeTemplate2(sdkPath) {
30482
+ return defaultOutdent`
30483
+ if (import.meta.hot) {
30484
+ import.meta.hot.accept((_) => {});
30485
+ }
30486
+
30487
+ export { default } from '${sdkPath}';
30488
+ `;
30326
30489
  }
30327
30490
 
30328
30491
  // ../astro-site-components-extensions/src/vite/virtual-modules-plugin.ts
30329
30492
  function virtualModulesPlugin({ model }) {
30330
30493
  const router = createVirtualRouter();
30331
- registerComponentVirtualRoute({ model, router });
30332
- registerPreviewVirtualRoute({ model, router });
30494
+ registerClientVirtualRoute({ model, router });
30495
+ registerEditorVirtualRoute({ model, router });
30333
30496
  registerSdkVirtualRoute({ model, router });
30334
30497
  return viteVirtualRouterPlugin({
30335
30498
  name: "wix:site-component-virtual-modules-plugin",
@@ -30338,13 +30501,13 @@ function virtualModulesPlugin({ model }) {
30338
30501
  }
30339
30502
 
30340
30503
  // ../astro-site-components-extensions/src/vite/client/build-config.ts
30341
- function getEntryNameForComponent(componentId) {
30504
+ function getEntryNameForClientComponent(componentId) {
30342
30505
  return `component-${componentId}`;
30343
30506
  }
30344
30507
  function getEntryNameForPreset(componentId, presetName) {
30345
30508
  return `component-${componentId}-preset-${presetName}.css`;
30346
30509
  }
30347
- var getComponentBuildConfig = ({
30510
+ var getClientBuildConfig = ({
30348
30511
  createExtensionViteConfig,
30349
30512
  extension: {
30350
30513
  componentPresets,
@@ -30353,13 +30516,13 @@ var getComponentBuildConfig = ({
30353
30516
  model
30354
30517
  }) => {
30355
30518
  const input = {
30356
- [getEntryNameForComponent(id)]: getVirtualModuleIdForComponent2(id)
30519
+ [getEntryNameForClientComponent(id)]: getVirtualModuleIdForClientComponent(id)
30357
30520
  };
30358
30521
  for (const { name, path: path5 } of componentPresets) {
30359
30522
  input[getEntryNameForPreset(id, name)] = path5;
30360
30523
  }
30361
30524
  return createExtensionViteConfig({
30362
- name: join18(extensionName, "client"),
30525
+ name: join19(extensionName, "client"),
30363
30526
  config: {
30364
30527
  build: {
30365
30528
  rollupOptions: {
@@ -30415,7 +30578,7 @@ function getPresetsDev({
30415
30578
  return extension.componentPresets.reduce((acc, { name, config, path: path5 }) => {
30416
30579
  const cssUrl = appendToDevServerUrl(
30417
30580
  baseUrl,
30418
- join19(devServer.config.base, "@fs", path5)
30581
+ join20(devServer.config.base, "@fs", path5)
30419
30582
  );
30420
30583
  acc[name] = {
30421
30584
  ...config,
@@ -30450,7 +30613,7 @@ function getClientResourceBuild({
30450
30613
  buildOutput,
30451
30614
  extension
30452
30615
  }) {
30453
- const entryName = getEntryNameForComponent(extension.options.id);
30616
+ const entryName = getEntryNameForClientComponent(extension.options.id);
30454
30617
  const chunk = getChunkForEntryName({ buildOutput, entryName });
30455
30618
  const componentFileName = chunk.fileName;
30456
30619
  const cssFileName = getCssFileNameFromChunk(chunk);
@@ -30464,7 +30627,7 @@ function getClientResourceDev({
30464
30627
  devServer,
30465
30628
  extension
30466
30629
  }) {
30467
- const moduleId = getVirtualModuleIdForComponent2(extension.options.id);
30630
+ const moduleId = getVirtualModuleIdForClientComponent(extension.options.id);
30468
30631
  return {
30469
30632
  componentUrl: getAssetUrlForModuleId({ baseUrl, devServer, moduleId })
30470
30633
  };
@@ -30475,23 +30638,23 @@ init_esm_shims();
30475
30638
 
30476
30639
  // ../astro-site-components-extensions/src/vite/editor/build-config.ts
30477
30640
  init_esm_shims();
30478
- import { join as join20 } from "path";
30479
- function getEntryNameForPreview(componentId) {
30480
- return `component-${componentId}-preview`;
30641
+ import { join as join21 } from "path";
30642
+ function getEntryNameForEditorComponent(componentId) {
30643
+ return `component-${componentId}-editor`;
30481
30644
  }
30482
- var getPreviewBuildConfig = ({
30645
+ var getEditorBuildConfig = ({
30483
30646
  createExtensionViteConfig,
30484
30647
  extensionId,
30485
30648
  model
30486
30649
  }) => {
30487
30650
  return createExtensionViteConfig({
30488
- name: join20(extensionName, "editor"),
30651
+ name: join21(extensionName, "editor"),
30489
30652
  config: {
30490
30653
  build: {
30491
30654
  rollupOptions: {
30492
30655
  external: externalDeps2,
30493
30656
  input: {
30494
- [getEntryNameForPreview(extensionId)]: getVirtualModuleIdForPreview(extensionId)
30657
+ [getEntryNameForEditorComponent(extensionId)]: getVirtualModuleIdForEditorComponent(extensionId)
30495
30658
  },
30496
30659
  preserveEntrySignatures: "strict"
30497
30660
  }
@@ -30524,7 +30687,7 @@ function getEditorResourceBuild({
30524
30687
  buildOutput,
30525
30688
  extension
30526
30689
  }) {
30527
- const entryName = getEntryNameForPreview(extension.options.id);
30690
+ const entryName = getEntryNameForEditorComponent(extension.options.id);
30528
30691
  const chunk = getChunkForEntryName({ buildOutput, entryName });
30529
30692
  const componentFileName = chunk.fileName;
30530
30693
  const cssFileName = getCssFileNameFromChunk(chunk);
@@ -30538,7 +30701,7 @@ function getEditorResourceDev({
30538
30701
  devServer,
30539
30702
  extension
30540
30703
  }) {
30541
- const moduleId = getVirtualModuleIdForPreview(extension.options.id);
30704
+ const moduleId = getVirtualModuleIdForEditorComponent(extension.options.id);
30542
30705
  return {
30543
30706
  componentUrl: getAssetUrlForModuleId({ baseUrl, devServer, moduleId })
30544
30707
  };
@@ -30549,7 +30712,7 @@ init_esm_shims();
30549
30712
 
30550
30713
  // ../astro-site-components-extensions/src/vite/sdk/build-config.ts
30551
30714
  init_esm_shims();
30552
- import { join as join21 } from "path";
30715
+ import { join as join22 } from "path";
30553
30716
  function getEntryNameForSdk(componentId) {
30554
30717
  return `component-${componentId}-sdk`;
30555
30718
  }
@@ -30559,7 +30722,7 @@ var getSdkBuildConfig = ({
30559
30722
  model
30560
30723
  }) => {
30561
30724
  return createExtensionViteConfig({
30562
- name: join21(extensionName, "sdk"),
30725
+ name: join22(extensionName, "sdk"),
30563
30726
  config: {
30564
30727
  build: {
30565
30728
  rollupOptions: {
@@ -30622,32 +30785,81 @@ function getSdkResourceDev({
30622
30785
  };
30623
30786
  }
30624
30787
 
30625
- // ../astro-site-components-extensions/src/utils/getResources.ts
30626
- function getResources2({
30788
+ // ../astro-site-components-extensions/src/utils/getServerResource.ts
30789
+ init_esm_shims();
30790
+
30791
+ // ../astro-site-components-extensions/src/vite/server/build-config.ts
30792
+ init_esm_shims();
30793
+ import { join as join23 } from "path";
30794
+ function getEntryNameForServerComponent(componentId) {
30795
+ return `component-${componentId}-server`;
30796
+ }
30797
+ var getServerBuildConfig = ({
30798
+ createExtensionViteConfig,
30799
+ extensionId,
30800
+ model
30801
+ }) => {
30802
+ return createExtensionViteConfig({
30803
+ name: join23(extensionName, "server"),
30804
+ config: {
30805
+ build: {
30806
+ rollupOptions: {
30807
+ external: externalDeps2,
30808
+ input: {
30809
+ [getEntryNameForServerComponent(extensionId)]: getVirtualModuleIdForClientComponent(extensionId)
30810
+ },
30811
+ output: {
30812
+ inlineDynamicImports: true
30813
+ }
30814
+ },
30815
+ ssr: true
30816
+ },
30817
+ plugins: [virtualModulesPlugin({ model })],
30818
+ ssr: {
30819
+ noExternal: true,
30820
+ target: "node"
30821
+ }
30822
+ }
30823
+ });
30824
+ };
30825
+
30826
+ // ../astro-site-components-extensions/src/utils/getServerResource.ts
30827
+ function getServerResource({
30828
+ baseUrl,
30627
30829
  buildOutput,
30628
- extension,
30629
- ...options
30830
+ devServer,
30831
+ extension
30630
30832
  }) {
30631
- const clientResource = getClientResource({
30632
- buildOutput,
30633
- extension,
30634
- ...options
30635
- });
30636
- const sdkResource = getSdkResource({
30637
- buildOutput,
30638
- extension,
30639
- ...options
30640
- });
30641
- const editorResource = getEditorResource({
30642
- buildOutput,
30643
- extension,
30644
- ...options
30645
- });
30833
+ if (buildOutput) {
30834
+ return getServerResourceBuild({ baseUrl, buildOutput, extension });
30835
+ }
30836
+ if (devServer) {
30837
+ return;
30838
+ }
30839
+ throw new Error("Unknown error: no build output or vite dev server");
30840
+ }
30841
+ function getServerResourceBuild({
30842
+ baseUrl,
30843
+ buildOutput,
30844
+ extension
30845
+ }) {
30846
+ const entryName = getEntryNameForServerComponent(extension.options.id);
30847
+ const chunk = getChunkForEntryName({ buildOutput, entryName });
30848
+ const componentFileName = chunk.fileName;
30849
+ return {
30850
+ url: appendToDevServerUrl(baseUrl, componentFileName)
30851
+ };
30852
+ }
30853
+
30854
+ // ../astro-site-components-extensions/src/utils/getResources.ts
30855
+ function getResources2(buildContext) {
30856
+ const { extension } = buildContext;
30646
30857
  return {
30647
30858
  ...extension.options.resources,
30648
- client: clientResource,
30649
- editor: editorResource,
30650
- sdk: sdkResource
30859
+ client: getClientResource(buildContext),
30860
+ editor: getEditorResource(buildContext),
30861
+ sdk: getSdkResource(buildContext),
30862
+ server: getServerResource(buildContext)
30651
30863
  };
30652
30864
  }
30653
30865
 
@@ -30665,15 +30877,20 @@ function getBuildViteConfigs({
30665
30877
  sdkPath
30666
30878
  } = extension;
30667
30879
  acc.push(
30668
- getComponentBuildConfig({
30880
+ getClientBuildConfig({
30669
30881
  createExtensionViteConfig,
30670
30882
  extension,
30671
30883
  model
30884
+ }),
30885
+ getServerBuildConfig({
30886
+ createExtensionViteConfig,
30887
+ extensionId,
30888
+ model
30672
30889
  })
30673
30890
  );
30674
30891
  if (editorPreviewPath != null) {
30675
30892
  acc.push(
30676
- getPreviewBuildConfig({
30893
+ getEditorBuildConfig({
30677
30894
  createExtensionViteConfig,
30678
30895
  extensionId,
30679
30896
  model
@@ -30766,18 +30983,12 @@ var createIntegration7 = () => {
30766
30983
  const extensions = getSupportedExtensions2(model);
30767
30984
  const components = [];
30768
30985
  for (const extension of extensions) {
30769
- const resources = getResources2({
30986
+ const buildContext = {
30770
30987
  baseUrl: staticsUrlPlaceholder2,
30771
30988
  buildOutput: customBuildOutput,
30772
30989
  devServer: customDevServer,
30773
30990
  extension
30774
- });
30775
- const presets = getPresets({
30776
- baseUrl: staticsUrlPlaceholder2,
30777
- buildOutput: customBuildOutput,
30778
- devServer: customDevServer,
30779
- extension
30780
- });
30991
+ };
30781
30992
  components.push({
30782
30993
  compId: extension.options.id,
30783
30994
  compType: "EDITOR_REACT_COMPONENT",
@@ -30787,9 +30998,9 @@ var createIntegration7 = () => {
30787
30998
  description: extension.options.description,
30788
30999
  editorElement: {
30789
31000
  ...extension.options.editorElement,
30790
- presets
31001
+ presets: getPresets(buildContext)
30791
31002
  },
30792
- resources
31003
+ resources: getResources2(buildContext)
30793
31004
  }
30794
31005
  }
30795
31006
  });
@@ -30945,4 +31156,4 @@ queue-microtask/index.js:
30945
31156
  run-parallel/index.js:
30946
31157
  (*! run-parallel. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
30947
31158
  */
30948
- //# sourceMappingURL=chunk-UBCQK5ZU.js.map
31159
+ //# sourceMappingURL=chunk-XH4FRXRS.js.map