@wix/astro 2.10.0 → 2.11.0

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 (55) hide show
  1. package/build/builders.d.ts +6 -0
  2. package/build/builders.js +42 -0
  3. package/build/builders.js.map +1 -0
  4. package/build/dependencies/astro-auth/backend-runtime/middleware/auth.js +3 -0
  5. package/build/dependencies/astro-auth/browser-runtime/setup.js +1 -1
  6. package/build/dependencies/astro-auth/index.d.ts +7 -0
  7. package/build/dependencies/astro-auth/index.js +301 -0
  8. package/build/dependencies/astro-auth/index.js.map +1 -0
  9. package/build/dependencies/astro-backend-extensions/index.d.ts +77 -0
  10. package/build/dependencies/astro-backend-extensions/index.js +7279 -0
  11. package/build/dependencies/astro-backend-extensions/index.js.map +1 -0
  12. package/build/dependencies/astro-backoffice-extensions/index.d.ts +47 -0
  13. package/build/dependencies/astro-backoffice-extensions/index.js +7159 -0
  14. package/build/dependencies/astro-backoffice-extensions/index.js.map +1 -0
  15. package/build/dependencies/astro-core/index.d.ts +95 -0
  16. package/build/dependencies/astro-core/index.js +1055 -0
  17. package/build/dependencies/astro-core/index.js.map +1 -0
  18. package/build/dependencies/astro-custom-elements-extensions/browser-runtime/index.js +14 -16
  19. package/build/dependencies/astro-custom-elements-extensions/index.d.ts +24 -0
  20. package/build/dependencies/astro-custom-elements-extensions/index.js +10082 -0
  21. package/build/dependencies/astro-custom-elements-extensions/index.js.map +1 -0
  22. package/build/dependencies/astro-embedded-scripts-extensions/browser-runtime/setupContext.js +6 -10
  23. package/build/dependencies/astro-embedded-scripts-extensions/index.d.ts +18 -0
  24. package/build/dependencies/astro-embedded-scripts-extensions/index.js +8453 -0
  25. package/build/dependencies/astro-embedded-scripts-extensions/index.js.map +1 -0
  26. package/build/dependencies/astro-html-embeds/index.d.ts +5 -0
  27. package/build/dependencies/astro-html-embeds/index.js +25 -0
  28. package/build/dependencies/astro-html-embeds/index.js.map +1 -0
  29. package/build/dependencies/astro-payment-links/index.d.ts +5 -0
  30. package/build/dependencies/astro-payment-links/index.js +42 -0
  31. package/build/dependencies/astro-payment-links/index.js.map +1 -0
  32. package/build/dependencies/astro-robots/index.d.ts +5 -0
  33. package/build/dependencies/astro-robots/index.js +23 -0
  34. package/build/dependencies/astro-robots/index.js.map +1 -0
  35. package/build/dependencies/astro-site-component-panels-extensions/browser-runtime/hmr.js +26 -0
  36. package/build/dependencies/astro-site-component-panels-extensions/browser-runtime/sdk.js +12 -0
  37. package/build/dependencies/astro-site-components-extensions/browser-runtime/sdk.js +21 -0
  38. package/build/dependencies/astro-site-plugins-extensions/index.d.ts +20 -0
  39. package/build/dependencies/astro-site-plugins-extensions/index.js +49 -0
  40. package/build/dependencies/astro-site-plugins-extensions/index.js.map +1 -0
  41. package/build/dependencies/astro-viewer-api/index.d.ts +5 -0
  42. package/build/dependencies/astro-viewer-api/index.js +22 -0
  43. package/build/dependencies/astro-viewer-api/index.js.map +1 -0
  44. package/build/index.d.ts +16 -0
  45. package/build/index.js +56 -0
  46. package/build/index.js.map +1 -0
  47. package/build/integration/builders.d.ts +3 -2
  48. package/build/integration/builders.js +11 -9
  49. package/build/integration/builders.js.map +1 -1
  50. package/build/integration/{chunk-JFJIM45R.js → chunk-OJIGUJIG.js} +522 -207
  51. package/build/integration/chunk-OJIGUJIG.js.map +1 -0
  52. package/build/integration/index.js +16 -14
  53. package/build/integration/index.js.map +1 -1
  54. package/package.json +5 -4
  55. package/build/integration/chunk-JFJIM45R.js.map +0 -1
@@ -0,0 +1,1055 @@
1
+ import { createRequire as _createRequire } from 'node:module';
2
+ const require = _createRequire(import.meta.url);
3
+
4
+ // src/integration.ts
5
+ import { join as join2 } from "path";
6
+ import { fileURLToPath as fileURLToPath3 } from "url";
7
+
8
+ // ../fs-utils/src/index.ts
9
+ import {
10
+ access,
11
+ readFile as fsReadFile,
12
+ mkdir,
13
+ rm,
14
+ writeFile
15
+ } from "fs/promises";
16
+ import { EOL } from "os";
17
+ import { dirname } from "path";
18
+ import process2 from "process";
19
+ import { fileURLToPath } from "url";
20
+ var isWindows = process2.platform === "win32";
21
+ async function outputDir(dir) {
22
+ await mkdir(dir, { recursive: true });
23
+ }
24
+ async function pathExists(path) {
25
+ return access(path).then(() => true).catch(() => false);
26
+ }
27
+ async function writeJson(filePath, object, opts = { spaces: 2 }) {
28
+ const str = toJsonString(object, opts);
29
+ await outputDir(dirname(filePath));
30
+ await writeFile(filePath, str, "utf-8");
31
+ }
32
+ function toJsonString(object, opts) {
33
+ return `${JSON.stringify(object, null, opts?.spaces)}${EOL}`;
34
+ }
35
+
36
+ // src/integration.ts
37
+ import { envField, passthroughImageService } from "astro/config";
38
+
39
+ // src/plugins/patchGlobal.ts
40
+ var define = { global: "window" };
41
+ function patchGlobal() {
42
+ return [
43
+ {
44
+ name: "fix-draft-js",
45
+ apply: "serve",
46
+ config: () => ({ optimizeDeps: { esbuildOptions: { define } } })
47
+ },
48
+ {
49
+ name: "fix-draft-js",
50
+ apply: "build",
51
+ config: () => ({ esbuild: { define } })
52
+ }
53
+ ];
54
+ }
55
+
56
+ // src/utils/createExtensionViteConfigFactory.ts
57
+ import { ok } from "assert";
58
+ import { createHash } from "crypto";
59
+ import { join } from "path";
60
+ import { mergeConfig } from "vite";
61
+ var initialServerPort = 6001;
62
+ function createExtensionViteConfigFactory({
63
+ config: astroConfig,
64
+ env: env2,
65
+ integrationName
66
+ }) {
67
+ return ({ name: extensionName, config: extensionConfig }) => {
68
+ ok(astroConfig.build?.outDir != null);
69
+ ok(!Array.isArray(extensionConfig.build?.rollupOptions?.output));
70
+ const hash = createShortHash(integrationName);
71
+ const outputDir2 = `_wix_${hash}-${extensionName}`;
72
+ return mergeConfig(
73
+ {
74
+ build: {
75
+ assetsDir: outputDir2,
76
+ emptyOutDir: false,
77
+ outDir: astroConfig.build.outDir,
78
+ rollupOptions: {
79
+ output: {
80
+ assetFileNames: join(outputDir2, `[name]-[hash][extname]`),
81
+ chunkFileNames: join(outputDir2, `[name]-[hash].js`),
82
+ entryFileNames: join(outputDir2, `[name]-[hash].js`),
83
+ format: "esm"
84
+ }
85
+ },
86
+ target: astroConfig.build.target
87
+ },
88
+ cacheDir: join("node_modules", ".vite-wix", `${hash}-${extensionName}`),
89
+ clearScreen: false,
90
+ configFile: false,
91
+ customLogger: astroConfig.customLogger,
92
+ define: {
93
+ "import.meta.env.WIX_CLIENT_ID": JSON.stringify(env2.WIX_CLIENT_ID)
94
+ },
95
+ root: astroConfig.root,
96
+ server: {
97
+ cors: true,
98
+ port: initialServerPort++
99
+ }
100
+ },
101
+ extensionConfig
102
+ );
103
+ };
104
+ }
105
+ function createShortHash(str) {
106
+ return createHash("sha256").update(str).digest("hex").substring(0, 8);
107
+ }
108
+
109
+ // src/utils/createModel.ts
110
+ import EventEmitter from "events";
111
+ import { createServer, mergeConfig as mergeConfig2 } from "vite";
112
+
113
+ // ../../node_modules/chalk/source/vendor/ansi-styles/index.js
114
+ var ANSI_BACKGROUND_OFFSET = 10;
115
+ var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
116
+ var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
117
+ var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
118
+ var styles = {
119
+ modifier: {
120
+ reset: [0, 0],
121
+ // 21 isn't widely supported and 22 does the same thing
122
+ bold: [1, 22],
123
+ dim: [2, 22],
124
+ italic: [3, 23],
125
+ underline: [4, 24],
126
+ overline: [53, 55],
127
+ inverse: [7, 27],
128
+ hidden: [8, 28],
129
+ strikethrough: [9, 29]
130
+ },
131
+ color: {
132
+ black: [30, 39],
133
+ red: [31, 39],
134
+ green: [32, 39],
135
+ yellow: [33, 39],
136
+ blue: [34, 39],
137
+ magenta: [35, 39],
138
+ cyan: [36, 39],
139
+ white: [37, 39],
140
+ // Bright color
141
+ blackBright: [90, 39],
142
+ gray: [90, 39],
143
+ // Alias of `blackBright`
144
+ grey: [90, 39],
145
+ // Alias of `blackBright`
146
+ redBright: [91, 39],
147
+ greenBright: [92, 39],
148
+ yellowBright: [93, 39],
149
+ blueBright: [94, 39],
150
+ magentaBright: [95, 39],
151
+ cyanBright: [96, 39],
152
+ whiteBright: [97, 39]
153
+ },
154
+ bgColor: {
155
+ bgBlack: [40, 49],
156
+ bgRed: [41, 49],
157
+ bgGreen: [42, 49],
158
+ bgYellow: [43, 49],
159
+ bgBlue: [44, 49],
160
+ bgMagenta: [45, 49],
161
+ bgCyan: [46, 49],
162
+ bgWhite: [47, 49],
163
+ // Bright color
164
+ bgBlackBright: [100, 49],
165
+ bgGray: [100, 49],
166
+ // Alias of `bgBlackBright`
167
+ bgGrey: [100, 49],
168
+ // Alias of `bgBlackBright`
169
+ bgRedBright: [101, 49],
170
+ bgGreenBright: [102, 49],
171
+ bgYellowBright: [103, 49],
172
+ bgBlueBright: [104, 49],
173
+ bgMagentaBright: [105, 49],
174
+ bgCyanBright: [106, 49],
175
+ bgWhiteBright: [107, 49]
176
+ }
177
+ };
178
+ var modifierNames = Object.keys(styles.modifier);
179
+ var foregroundColorNames = Object.keys(styles.color);
180
+ var backgroundColorNames = Object.keys(styles.bgColor);
181
+ var colorNames = [...foregroundColorNames, ...backgroundColorNames];
182
+ function assembleStyles() {
183
+ const codes = /* @__PURE__ */ new Map();
184
+ for (const [groupName, group] of Object.entries(styles)) {
185
+ for (const [styleName, style] of Object.entries(group)) {
186
+ styles[styleName] = {
187
+ open: `\x1B[${style[0]}m`,
188
+ close: `\x1B[${style[1]}m`
189
+ };
190
+ group[styleName] = styles[styleName];
191
+ codes.set(style[0], style[1]);
192
+ }
193
+ Object.defineProperty(styles, groupName, {
194
+ value: group,
195
+ enumerable: false
196
+ });
197
+ }
198
+ Object.defineProperty(styles, "codes", {
199
+ value: codes,
200
+ enumerable: false
201
+ });
202
+ styles.color.close = "\x1B[39m";
203
+ styles.bgColor.close = "\x1B[49m";
204
+ styles.color.ansi = wrapAnsi16();
205
+ styles.color.ansi256 = wrapAnsi256();
206
+ styles.color.ansi16m = wrapAnsi16m();
207
+ styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
208
+ styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
209
+ styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
210
+ Object.defineProperties(styles, {
211
+ rgbToAnsi256: {
212
+ value(red, green, blue) {
213
+ if (red === green && green === blue) {
214
+ if (red < 8) {
215
+ return 16;
216
+ }
217
+ if (red > 248) {
218
+ return 231;
219
+ }
220
+ return Math.round((red - 8) / 247 * 24) + 232;
221
+ }
222
+ return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
223
+ },
224
+ enumerable: false
225
+ },
226
+ hexToRgb: {
227
+ value(hex) {
228
+ const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
229
+ if (!matches) {
230
+ return [0, 0, 0];
231
+ }
232
+ let [colorString] = matches;
233
+ if (colorString.length === 3) {
234
+ colorString = [...colorString].map((character) => character + character).join("");
235
+ }
236
+ const integer = Number.parseInt(colorString, 16);
237
+ return [
238
+ /* eslint-disable no-bitwise */
239
+ integer >> 16 & 255,
240
+ integer >> 8 & 255,
241
+ integer & 255
242
+ /* eslint-enable no-bitwise */
243
+ ];
244
+ },
245
+ enumerable: false
246
+ },
247
+ hexToAnsi256: {
248
+ value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
249
+ enumerable: false
250
+ },
251
+ ansi256ToAnsi: {
252
+ value(code) {
253
+ if (code < 8) {
254
+ return 30 + code;
255
+ }
256
+ if (code < 16) {
257
+ return 90 + (code - 8);
258
+ }
259
+ let red;
260
+ let green;
261
+ let blue;
262
+ if (code >= 232) {
263
+ red = ((code - 232) * 10 + 8) / 255;
264
+ green = red;
265
+ blue = red;
266
+ } else {
267
+ code -= 16;
268
+ const remainder = code % 36;
269
+ red = Math.floor(code / 36) / 5;
270
+ green = Math.floor(remainder / 6) / 5;
271
+ blue = remainder % 6 / 5;
272
+ }
273
+ const value = Math.max(red, green, blue) * 2;
274
+ if (value === 0) {
275
+ return 30;
276
+ }
277
+ let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
278
+ if (value === 2) {
279
+ result += 60;
280
+ }
281
+ return result;
282
+ },
283
+ enumerable: false
284
+ },
285
+ rgbToAnsi: {
286
+ value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
287
+ enumerable: false
288
+ },
289
+ hexToAnsi: {
290
+ value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
291
+ enumerable: false
292
+ }
293
+ });
294
+ return styles;
295
+ }
296
+ var ansiStyles = assembleStyles();
297
+ var ansi_styles_default = ansiStyles;
298
+
299
+ // ../../node_modules/chalk/source/vendor/supports-color/index.js
300
+ import process3 from "process";
301
+ import os from "os";
302
+ import tty from "tty";
303
+ function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process3.argv) {
304
+ const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
305
+ const position = argv.indexOf(prefix + flag);
306
+ const terminatorPosition = argv.indexOf("--");
307
+ return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
308
+ }
309
+ var { env } = process3;
310
+ var flagForceColor;
311
+ if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
312
+ flagForceColor = 0;
313
+ } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
314
+ flagForceColor = 1;
315
+ }
316
+ function envForceColor() {
317
+ if ("FORCE_COLOR" in env) {
318
+ if (env.FORCE_COLOR === "true") {
319
+ return 1;
320
+ }
321
+ if (env.FORCE_COLOR === "false") {
322
+ return 0;
323
+ }
324
+ return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
325
+ }
326
+ }
327
+ function translateLevel(level) {
328
+ if (level === 0) {
329
+ return false;
330
+ }
331
+ return {
332
+ level,
333
+ hasBasic: true,
334
+ has256: level >= 2,
335
+ has16m: level >= 3
336
+ };
337
+ }
338
+ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
339
+ const noFlagForceColor = envForceColor();
340
+ if (noFlagForceColor !== void 0) {
341
+ flagForceColor = noFlagForceColor;
342
+ }
343
+ const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
344
+ if (forceColor === 0) {
345
+ return 0;
346
+ }
347
+ if (sniffFlags) {
348
+ if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
349
+ return 3;
350
+ }
351
+ if (hasFlag("color=256")) {
352
+ return 2;
353
+ }
354
+ }
355
+ if ("TF_BUILD" in env && "AGENT_NAME" in env) {
356
+ return 1;
357
+ }
358
+ if (haveStream && !streamIsTTY && forceColor === void 0) {
359
+ return 0;
360
+ }
361
+ const min = forceColor || 0;
362
+ if (env.TERM === "dumb") {
363
+ return min;
364
+ }
365
+ if (process3.platform === "win32") {
366
+ const osRelease = os.release().split(".");
367
+ if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
368
+ return Number(osRelease[2]) >= 14931 ? 3 : 2;
369
+ }
370
+ return 1;
371
+ }
372
+ if ("CI" in env) {
373
+ if (["GITHUB_ACTIONS", "GITEA_ACTIONS", "CIRCLECI"].some((key) => key in env)) {
374
+ return 3;
375
+ }
376
+ if (["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
377
+ return 1;
378
+ }
379
+ return min;
380
+ }
381
+ if ("TEAMCITY_VERSION" in env) {
382
+ return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
383
+ }
384
+ if (env.COLORTERM === "truecolor") {
385
+ return 3;
386
+ }
387
+ if (env.TERM === "xterm-kitty") {
388
+ return 3;
389
+ }
390
+ if (env.TERM === "xterm-ghostty") {
391
+ return 3;
392
+ }
393
+ if (env.TERM === "wezterm") {
394
+ return 3;
395
+ }
396
+ if ("TERM_PROGRAM" in env) {
397
+ const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
398
+ switch (env.TERM_PROGRAM) {
399
+ case "iTerm.app": {
400
+ return version >= 3 ? 3 : 2;
401
+ }
402
+ case "Apple_Terminal": {
403
+ return 2;
404
+ }
405
+ }
406
+ }
407
+ if (/-256(color)?$/i.test(env.TERM)) {
408
+ return 2;
409
+ }
410
+ if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
411
+ return 1;
412
+ }
413
+ if ("COLORTERM" in env) {
414
+ return 1;
415
+ }
416
+ return min;
417
+ }
418
+ function createSupportsColor(stream, options = {}) {
419
+ const level = _supportsColor(stream, {
420
+ streamIsTTY: stream && stream.isTTY,
421
+ ...options
422
+ });
423
+ return translateLevel(level);
424
+ }
425
+ var supportsColor = {
426
+ stdout: createSupportsColor({ isTTY: tty.isatty(1) }),
427
+ stderr: createSupportsColor({ isTTY: tty.isatty(2) })
428
+ };
429
+ var supports_color_default = supportsColor;
430
+
431
+ // ../../node_modules/chalk/source/utilities.js
432
+ function stringReplaceAll(string, substring, replacer) {
433
+ let index = string.indexOf(substring);
434
+ if (index === -1) {
435
+ return string;
436
+ }
437
+ const substringLength = substring.length;
438
+ let endIndex = 0;
439
+ let returnValue = "";
440
+ do {
441
+ returnValue += string.slice(endIndex, index) + substring + replacer;
442
+ endIndex = index + substringLength;
443
+ index = string.indexOf(substring, endIndex);
444
+ } while (index !== -1);
445
+ returnValue += string.slice(endIndex);
446
+ return returnValue;
447
+ }
448
+ function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
449
+ let endIndex = 0;
450
+ let returnValue = "";
451
+ do {
452
+ const gotCR = string[index - 1] === "\r";
453
+ returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
454
+ endIndex = index + 1;
455
+ index = string.indexOf("\n", endIndex);
456
+ } while (index !== -1);
457
+ returnValue += string.slice(endIndex);
458
+ return returnValue;
459
+ }
460
+
461
+ // ../../node_modules/chalk/source/index.js
462
+ var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default;
463
+ var GENERATOR = Symbol("GENERATOR");
464
+ var STYLER = Symbol("STYLER");
465
+ var IS_EMPTY = Symbol("IS_EMPTY");
466
+ var levelMapping = [
467
+ "ansi",
468
+ "ansi",
469
+ "ansi256",
470
+ "ansi16m"
471
+ ];
472
+ var styles2 = /* @__PURE__ */ Object.create(null);
473
+ var applyOptions = (object, options = {}) => {
474
+ if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
475
+ throw new Error("The `level` option should be an integer from 0 to 3");
476
+ }
477
+ const colorLevel = stdoutColor ? stdoutColor.level : 0;
478
+ object.level = options.level === void 0 ? colorLevel : options.level;
479
+ };
480
+ var chalkFactory = (options) => {
481
+ const chalk2 = (...strings) => strings.join(" ");
482
+ applyOptions(chalk2, options);
483
+ Object.setPrototypeOf(chalk2, createChalk.prototype);
484
+ return chalk2;
485
+ };
486
+ function createChalk(options) {
487
+ return chalkFactory(options);
488
+ }
489
+ Object.setPrototypeOf(createChalk.prototype, Function.prototype);
490
+ for (const [styleName, style] of Object.entries(ansi_styles_default)) {
491
+ styles2[styleName] = {
492
+ get() {
493
+ const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
494
+ Object.defineProperty(this, styleName, { value: builder });
495
+ return builder;
496
+ }
497
+ };
498
+ }
499
+ styles2.visible = {
500
+ get() {
501
+ const builder = createBuilder(this, this[STYLER], true);
502
+ Object.defineProperty(this, "visible", { value: builder });
503
+ return builder;
504
+ }
505
+ };
506
+ var getModelAnsi = (model, level, type, ...arguments_) => {
507
+ if (model === "rgb") {
508
+ if (level === "ansi16m") {
509
+ return ansi_styles_default[type].ansi16m(...arguments_);
510
+ }
511
+ if (level === "ansi256") {
512
+ return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
513
+ }
514
+ return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
515
+ }
516
+ if (model === "hex") {
517
+ return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));
518
+ }
519
+ return ansi_styles_default[type][model](...arguments_);
520
+ };
521
+ var usedModels = ["rgb", "hex", "ansi256"];
522
+ for (const model of usedModels) {
523
+ styles2[model] = {
524
+ get() {
525
+ const { level } = this;
526
+ return function(...arguments_) {
527
+ const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
528
+ return createBuilder(this, styler, this[IS_EMPTY]);
529
+ };
530
+ }
531
+ };
532
+ const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
533
+ styles2[bgModel] = {
534
+ get() {
535
+ const { level } = this;
536
+ return function(...arguments_) {
537
+ const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
538
+ return createBuilder(this, styler, this[IS_EMPTY]);
539
+ };
540
+ }
541
+ };
542
+ }
543
+ var proto = Object.defineProperties(() => {
544
+ }, {
545
+ ...styles2,
546
+ level: {
547
+ enumerable: true,
548
+ get() {
549
+ return this[GENERATOR].level;
550
+ },
551
+ set(level) {
552
+ this[GENERATOR].level = level;
553
+ }
554
+ }
555
+ });
556
+ var createStyler = (open, close, parent) => {
557
+ let openAll;
558
+ let closeAll;
559
+ if (parent === void 0) {
560
+ openAll = open;
561
+ closeAll = close;
562
+ } else {
563
+ openAll = parent.openAll + open;
564
+ closeAll = close + parent.closeAll;
565
+ }
566
+ return {
567
+ open,
568
+ close,
569
+ openAll,
570
+ closeAll,
571
+ parent
572
+ };
573
+ };
574
+ var createBuilder = (self, _styler, _isEmpty) => {
575
+ const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
576
+ Object.setPrototypeOf(builder, proto);
577
+ builder[GENERATOR] = self;
578
+ builder[STYLER] = _styler;
579
+ builder[IS_EMPTY] = _isEmpty;
580
+ return builder;
581
+ };
582
+ var applyStyle = (self, string) => {
583
+ if (self.level <= 0 || !string) {
584
+ return self[IS_EMPTY] ? "" : string;
585
+ }
586
+ let styler = self[STYLER];
587
+ if (styler === void 0) {
588
+ return string;
589
+ }
590
+ const { openAll, closeAll } = styler;
591
+ if (string.includes("\x1B")) {
592
+ while (styler !== void 0) {
593
+ string = stringReplaceAll(string, styler.close, styler.open);
594
+ styler = styler.parent;
595
+ }
596
+ }
597
+ const lfIndex = string.indexOf("\n");
598
+ if (lfIndex !== -1) {
599
+ string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
600
+ }
601
+ return openAll + string + closeAll;
602
+ };
603
+ Object.defineProperties(createChalk.prototype, styles2);
604
+ var chalk = createChalk();
605
+ var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
606
+ var source_default = chalk;
607
+
608
+ // ../../node_modules/outdent/lib-module/index.js
609
+ function noop() {
610
+ var args = [];
611
+ for (var _i = 0; _i < arguments.length; _i++) {
612
+ args[_i] = arguments[_i];
613
+ }
614
+ }
615
+ function createWeakMap() {
616
+ if (typeof WeakMap !== "undefined") {
617
+ return /* @__PURE__ */ new WeakMap();
618
+ } else {
619
+ return fakeSetOrMap();
620
+ }
621
+ }
622
+ function fakeSetOrMap() {
623
+ return {
624
+ add: noop,
625
+ delete: noop,
626
+ get: noop,
627
+ set: noop,
628
+ has: function(k) {
629
+ return false;
630
+ }
631
+ };
632
+ }
633
+ var hop = Object.prototype.hasOwnProperty;
634
+ var has = function(obj, prop) {
635
+ return hop.call(obj, prop);
636
+ };
637
+ function extend(target, source) {
638
+ for (var prop in source) {
639
+ if (has(source, prop)) {
640
+ target[prop] = source[prop];
641
+ }
642
+ }
643
+ return target;
644
+ }
645
+ var reLeadingNewline = /^[ \t]*(?:\r\n|\r|\n)/;
646
+ var reTrailingNewline = /(?:\r\n|\r|\n)[ \t]*$/;
647
+ var reStartsWithNewlineOrIsEmpty = /^(?:[\r\n]|$)/;
648
+ var reDetectIndentation = /(?:\r\n|\r|\n)([ \t]*)(?:[^ \t\r\n]|$)/;
649
+ var reOnlyWhitespaceWithAtLeastOneNewline = /^[ \t]*[\r\n][ \t\r\n]*$/;
650
+ function _outdentArray(strings, firstInterpolatedValueSetsIndentationLevel, options) {
651
+ var indentationLevel = 0;
652
+ var match = strings[0].match(reDetectIndentation);
653
+ if (match) {
654
+ indentationLevel = match[1].length;
655
+ }
656
+ var reSource = "(\\r\\n|\\r|\\n).{0," + indentationLevel + "}";
657
+ var reMatchIndent = new RegExp(reSource, "g");
658
+ if (firstInterpolatedValueSetsIndentationLevel) {
659
+ strings = strings.slice(1);
660
+ }
661
+ var newline = options.newline, trimLeadingNewline = options.trimLeadingNewline, trimTrailingNewline = options.trimTrailingNewline;
662
+ var normalizeNewlines = typeof newline === "string";
663
+ var l = strings.length;
664
+ var outdentedStrings = strings.map(function(v, i) {
665
+ v = v.replace(reMatchIndent, "$1");
666
+ if (i === 0 && trimLeadingNewline) {
667
+ v = v.replace(reLeadingNewline, "");
668
+ }
669
+ if (i === l - 1 && trimTrailingNewline) {
670
+ v = v.replace(reTrailingNewline, "");
671
+ }
672
+ if (normalizeNewlines) {
673
+ v = v.replace(/\r\n|\n|\r/g, function(_) {
674
+ return newline;
675
+ });
676
+ }
677
+ return v;
678
+ });
679
+ return outdentedStrings;
680
+ }
681
+ function concatStringsAndValues(strings, values) {
682
+ var ret = "";
683
+ for (var i = 0, l = strings.length; i < l; i++) {
684
+ ret += strings[i];
685
+ if (i < l - 1) {
686
+ ret += values[i];
687
+ }
688
+ }
689
+ return ret;
690
+ }
691
+ function isTemplateStringsArray(v) {
692
+ return has(v, "raw") && has(v, "length");
693
+ }
694
+ function createInstance(options) {
695
+ var arrayAutoIndentCache = createWeakMap();
696
+ var arrayFirstInterpSetsIndentCache = createWeakMap();
697
+ function outdent(stringsOrOptions) {
698
+ var values = [];
699
+ for (var _i = 1; _i < arguments.length; _i++) {
700
+ values[_i - 1] = arguments[_i];
701
+ }
702
+ if (isTemplateStringsArray(stringsOrOptions)) {
703
+ var strings = stringsOrOptions;
704
+ var firstInterpolatedValueSetsIndentationLevel = (values[0] === outdent || values[0] === defaultOutdent) && reOnlyWhitespaceWithAtLeastOneNewline.test(strings[0]) && reStartsWithNewlineOrIsEmpty.test(strings[1]);
705
+ var cache = firstInterpolatedValueSetsIndentationLevel ? arrayFirstInterpSetsIndentCache : arrayAutoIndentCache;
706
+ var renderedArray = cache.get(strings);
707
+ if (!renderedArray) {
708
+ renderedArray = _outdentArray(strings, firstInterpolatedValueSetsIndentationLevel, options);
709
+ cache.set(strings, renderedArray);
710
+ }
711
+ if (values.length === 0) {
712
+ return renderedArray[0];
713
+ }
714
+ var rendered = concatStringsAndValues(renderedArray, firstInterpolatedValueSetsIndentationLevel ? values.slice(1) : values);
715
+ return rendered;
716
+ } else {
717
+ return createInstance(extend(extend({}, options), stringsOrOptions || {}));
718
+ }
719
+ }
720
+ var fullOutdent = extend(outdent, {
721
+ string: function(str) {
722
+ return _outdentArray([str], false, options)[0];
723
+ }
724
+ });
725
+ return fullOutdent;
726
+ }
727
+ var defaultOutdent = createInstance({
728
+ trimLeadingNewline: true,
729
+ trimTrailingNewline: true
730
+ });
731
+ if (typeof module !== "undefined") {
732
+ try {
733
+ module.exports = defaultOutdent;
734
+ Object.defineProperty(defaultOutdent, "__esModule", { value: true });
735
+ defaultOutdent.default = defaultOutdent;
736
+ defaultOutdent.outdent = defaultOutdent;
737
+ } catch (e) {
738
+ }
739
+ }
740
+
741
+ // src/utils/loadEnvVars.ts
742
+ import { loadEnv } from "vite";
743
+ var wixClientIdEnvVar = "WIX_CLIENT_ID";
744
+ function loadEnvVars({
745
+ logger,
746
+ rootDir
747
+ }) {
748
+ const env2 = loadEnv("development", rootDir, "");
749
+ const appId = env2[wixClientIdEnvVar];
750
+ if (appId == null) {
751
+ logger.error(
752
+ defaultOutdent`
753
+ Missing environment variable ${source_default.blueBright(wixClientIdEnvVar)}
754
+ To use the Wix SDK, you must provide the ${source_default.blueBright(
755
+ wixClientIdEnvVar
756
+ )} environment variable.
757
+ 💡 To pull the required environment variables from Wix, run:
758
+ ${source_default.magenta("npx wix env pull")}
759
+ 🔍 Need Help?
760
+ - Visit our docs: https://dev.wix.com/docs/go-headless
761
+ - Join the community: https://discord.com/channels/1114269395317968906/1288424190969511987
762
+ `
763
+ );
764
+ throw new Error(
765
+ `${source_default.magenta(
766
+ wixClientIdEnvVar
767
+ )} not found in loaded environment variables`
768
+ );
769
+ }
770
+ return {
771
+ appId,
772
+ env: env2
773
+ };
774
+ }
775
+
776
+ // src/utils/createModel.ts
777
+ var Model = class extends EventEmitter {
778
+ appId;
779
+ env;
780
+ extensions;
781
+ server;
782
+ constructor({
783
+ appId,
784
+ env: env2,
785
+ extensions,
786
+ server
787
+ }) {
788
+ super();
789
+ this.appId = appId;
790
+ this.env = env2;
791
+ this.extensions = extensions;
792
+ this.server = server;
793
+ this.server.watcher.on("change", async () => {
794
+ this.extensions = await loadExtensions(this.server);
795
+ this.emit("change");
796
+ });
797
+ }
798
+ };
799
+ async function createModel({
800
+ logger,
801
+ rootDir,
802
+ srcDir
803
+ }) {
804
+ const { appId, env: env2 } = loadEnvVars({ logger, rootDir });
805
+ const server = await getTempViteServer({
806
+ viteConfig: {
807
+ root: srcDir
808
+ }
809
+ });
810
+ const extensions = await loadExtensions(server);
811
+ const model = new Model({
812
+ appId,
813
+ env: env2,
814
+ extensions,
815
+ server
816
+ });
817
+ return model;
818
+ }
819
+ async function getTempViteServer({
820
+ viteConfig
821
+ }) {
822
+ const tempViteServer = await createServer(
823
+ mergeConfig2(viteConfig, {
824
+ logLevel: "silent",
825
+ optimizeDeps: { noDiscovery: true },
826
+ server: {
827
+ middlewareMode: true,
828
+ ws: false
829
+ },
830
+ ssr: { external: [] }
831
+ })
832
+ );
833
+ return tempViteServer;
834
+ }
835
+ async function loadExtensions(server) {
836
+ const mod = await server.ssrLoadModule("/extensions.ts").catch((error) => {
837
+ if (error != null && typeof error === "object" && "code" in error && error.code === "ERR_LOAD_URL") {
838
+ return null;
839
+ }
840
+ throw error;
841
+ });
842
+ if (mod) {
843
+ return mod.default.extensions;
844
+ }
845
+ return [];
846
+ }
847
+
848
+ // src/utils/generateAppManifest.ts
849
+ async function generateAppManifest({
850
+ integrations,
851
+ model
852
+ }) {
853
+ const unknownComponents = model.extensions.filter(
854
+ (extension) => extension.type === "GenericExtension"
855
+ ).map((extension) => extension.options);
856
+ let appManifest = {
857
+ appId: model.appId,
858
+ components: unknownComponents
859
+ };
860
+ for (const integration of integrations) {
861
+ if (integration.hooks["wix:app-manifest:setup"]) {
862
+ await integration.hooks["wix:app-manifest:setup"]({
863
+ model,
864
+ updateAppManifest: (newAppManifest) => {
865
+ appManifest = {
866
+ ...appManifest,
867
+ ...newAppManifest,
868
+ components: [
869
+ ...appManifest.components,
870
+ ...newAppManifest.components ?? []
871
+ ]
872
+ };
873
+ }
874
+ });
875
+ }
876
+ }
877
+ return appManifest;
878
+ }
879
+
880
+ // src/utils/generateBuildMetadata.ts
881
+ import { fileURLToPath as fileURLToPath2 } from "url";
882
+ async function generateBuildMetadata(appManifestPath, config) {
883
+ const outDir = fileURLToPath2(config.outDir);
884
+ const buildClientDir = fileURLToPath2(config.build.client);
885
+ const buildServerDir = fileURLToPath2(config.build.server);
886
+ const clientDir = await pathExists(buildClientDir) ? buildClientDir : outDir;
887
+ const serverDir = await pathExists(buildServerDir) ? buildServerDir : void 0;
888
+ return {
889
+ appManifestPath,
890
+ clientDir,
891
+ outDir,
892
+ serverDir
893
+ };
894
+ }
895
+
896
+ // src/integration.ts
897
+ var createIntegration = ({
898
+ integrations
899
+ }) => {
900
+ let config;
901
+ let model;
902
+ return {
903
+ name: "@wix/astro/core",
904
+ hooks: {
905
+ async "astro:config:setup"({
906
+ config: astroConfig,
907
+ logger,
908
+ updateConfig
909
+ }) {
910
+ config = astroConfig;
911
+ const rootDir = fileURLToPath3(astroConfig.root);
912
+ const srcDir = fileURLToPath3(astroConfig.srcDir);
913
+ updateConfig({
914
+ env: {
915
+ schema: {
916
+ WIX_CLIENT_ID: envField.string({
917
+ access: "public",
918
+ context: "client"
919
+ }),
920
+ WIX_CLIENT_INSTANCE_ID: envField.string({
921
+ access: "secret",
922
+ context: "server"
923
+ }),
924
+ WIX_CLIENT_PUBLIC_KEY: envField.string({
925
+ access: "secret",
926
+ context: "server"
927
+ }),
928
+ WIX_CLIENT_SECRET: envField.string({
929
+ access: "secret",
930
+ context: "server"
931
+ })
932
+ }
933
+ },
934
+ image: {
935
+ domains: ["static.wixstatic.com"],
936
+ service: passthroughImageService()
937
+ },
938
+ integrations,
939
+ vite: {
940
+ optimizeDeps: {
941
+ include: [
942
+ "@wix/sdk-runtime/context",
943
+ "@wix/dashboard/internal",
944
+ "@wix/sdk-context",
945
+ "@wix/sdk",
946
+ "@wix/sdk/auth/site-session",
947
+ "@wix/headless-site",
948
+ "@wix/stores",
949
+ "@wix/site"
950
+ ]
951
+ },
952
+ plugins: [patchGlobal()]
953
+ }
954
+ });
955
+ model = await createModel({ logger, rootDir, srcDir });
956
+ model.on("change", async () => {
957
+ for (const integration of integrations) {
958
+ if (integration.hooks["wix:model:changed"]) {
959
+ await integration.hooks["wix:model:changed"]({ model });
960
+ }
961
+ }
962
+ });
963
+ },
964
+ async "astro:config:done"() {
965
+ for (const integration of integrations) {
966
+ if (integration.hooks["wix:model:setup"]) {
967
+ await integration.hooks["wix:model:setup"]({ model });
968
+ }
969
+ }
970
+ },
971
+ async "astro:server:setup"({ server }) {
972
+ server.middlewares.use(async (req, res, next) => {
973
+ if (req.url === "/_wix/app-manifest.json") {
974
+ const appManifest = await generateAppManifest({
975
+ integrations,
976
+ model
977
+ });
978
+ res.setHeader("Content-Type", "application/json");
979
+ res.end(JSON.stringify(appManifest));
980
+ return;
981
+ }
982
+ next();
983
+ });
984
+ for (const integration of integrations) {
985
+ const createExtensionViteConfig = createExtensionViteConfigFactory({
986
+ config: server.config,
987
+ env: model.env,
988
+ integrationName: integration.name
989
+ });
990
+ if (integration.hooks["wix:server:setup"]) {
991
+ await integration.hooks["wix:server:setup"]({
992
+ createExtensionViteConfig
993
+ });
994
+ }
995
+ }
996
+ },
997
+ async "astro:build:setup"({ target, vite }) {
998
+ if (target === "server") {
999
+ return;
1000
+ }
1001
+ for (const integration of integrations) {
1002
+ const createExtensionViteConfig = createExtensionViteConfigFactory({
1003
+ config: vite,
1004
+ env: model.env,
1005
+ integrationName: integration.name
1006
+ });
1007
+ if (integration.hooks["wix:build:setup"]) {
1008
+ await integration.hooks["wix:build:setup"]({
1009
+ createExtensionViteConfig
1010
+ });
1011
+ }
1012
+ }
1013
+ },
1014
+ async "astro:build:done"() {
1015
+ const rootDir = fileURLToPath3(config.root);
1016
+ const outDir = fileURLToPath3(config.outDir);
1017
+ const buildMetadataPath = join2(rootDir, ".wix/build-metadata.json");
1018
+ const appManifestPath = join2(outDir, "_wix/app-manifest.json");
1019
+ const buildMetadata = await generateBuildMetadata(
1020
+ appManifestPath,
1021
+ config
1022
+ );
1023
+ const appManifest = await generateAppManifest({ integrations, model });
1024
+ await writeJson(appManifestPath, appManifest);
1025
+ await writeJson(buildMetadataPath, buildMetadata);
1026
+ }
1027
+ }
1028
+ };
1029
+ };
1030
+
1031
+ // src/builders/app.ts
1032
+ var App = class {
1033
+ extensions = [];
1034
+ use(extension) {
1035
+ this.extensions.push(extension);
1036
+ return this;
1037
+ }
1038
+ };
1039
+ function app() {
1040
+ return new App();
1041
+ }
1042
+
1043
+ // src/builders/generic-extension.ts
1044
+ function genericExtension(options) {
1045
+ return {
1046
+ type: "GenericExtension",
1047
+ options
1048
+ };
1049
+ }
1050
+ export {
1051
+ app,
1052
+ createIntegration as default,
1053
+ genericExtension
1054
+ };
1055
+ //# sourceMappingURL=index.js.map