@wix/astro 2.25.0 → 2.27.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.
- package/build/dependencies/astro-translations/{chunk-YRKN4TFH.js → backend-runtime/middleware/static-translations.js} +54 -1
- package/build/dependencies/astro-translations/backend-runtime/runtime/i18n.d.ts +4 -0
- package/build/dependencies/astro-translations/backend-runtime/runtime/i18n.js +42 -0
- package/build/dependencies/astro-translations/integration/index.js +296 -0
- package/build/dependencies/astro-translations/types/wix-astro-i18n.d.ts +18 -0
- package/build/dependencies/astro-viewer-services-extensions/browser-runtime/sdk.js +21 -0
- package/build/dependencies/astro-viewer-services-extensions/types/index.d.ts +27 -0
- package/build/integration/builders-experimental.js +1 -1
- package/build/integration/builders-trusted.js +2 -2
- package/build/integration/builders.d.ts +27 -4
- package/build/integration/builders.js +2 -2
- package/build/integration/{chunk-LQFJQHEX.js → chunk-6UOFHB2M.js} +2 -2
- package/build/integration/{chunk-S5CQHYTB.js → chunk-L6JEDTVM.js} +437 -13
- package/build/integration/chunk-L6JEDTVM.js.map +1 -0
- package/build/integration/{chunk-XF55M5AE.js → chunk-MNQWQ2MC.js} +2 -2
- package/build/integration/{chunk-XF55M5AE.js.map → chunk-MNQWQ2MC.js.map} +1 -1
- package/build/integration/{chunk-CTGNWVC3.js → chunk-XN6SBNMI.js} +21 -12
- package/build/integration/{chunk-CTGNWVC3.js.map → chunk-XN6SBNMI.js.map} +1 -1
- package/build/integration/index.js +78 -29
- package/build/integration/index.js.map +1 -1
- package/package.json +4 -2
- package/build/dependencies/astro-translations/index.js +0 -133
- package/build/dependencies/astro-translations/middleware/static-translations.js +0 -58
- package/build/integration/chunk-S5CQHYTB.js.map +0 -1
- /package/build/dependencies/astro-translations/{middleware → backend-runtime/middleware}/static-translations.d.ts +0 -0
- /package/build/dependencies/astro-translations/{index.d.ts → integration/index.d.ts} +0 -0
- /package/build/integration/{chunk-LQFJQHEX.js.map → chunk-6UOFHB2M.js.map} +0 -0
|
@@ -3,14 +3,15 @@ const require = _createRequire(import.meta.url);
|
|
|
3
3
|
import {
|
|
4
4
|
createIntegration,
|
|
5
5
|
createIntegration2
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-MNQWQ2MC.js";
|
|
7
7
|
import {
|
|
8
8
|
createIntegration as createIntegration9
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-6UOFHB2M.js";
|
|
10
10
|
import {
|
|
11
11
|
createIntegration as createIntegration10,
|
|
12
|
+
createIntegration2 as createIntegration11,
|
|
12
13
|
extensions
|
|
13
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-L6JEDTVM.js";
|
|
14
15
|
import {
|
|
15
16
|
createIntegration as createIntegration3,
|
|
16
17
|
createIntegration2 as createIntegration4,
|
|
@@ -19,7 +20,7 @@ import {
|
|
|
19
20
|
createIntegration5 as createIntegration7,
|
|
20
21
|
createIntegration6 as createIntegration8,
|
|
21
22
|
readJson
|
|
22
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-XN6SBNMI.js";
|
|
23
24
|
import {
|
|
24
25
|
defaultOutdent,
|
|
25
26
|
init_esm_shims,
|
|
@@ -96,7 +97,7 @@ var setupContextUrl = new URL(
|
|
|
96
97
|
"../dependencies/astro-auth/browser-runtime/setup.js",
|
|
97
98
|
import.meta.url
|
|
98
99
|
);
|
|
99
|
-
var
|
|
100
|
+
var createIntegration12 = ({
|
|
100
101
|
enableAuthRoutes,
|
|
101
102
|
enableWixEssentials
|
|
102
103
|
}) => {
|
|
@@ -181,11 +182,11 @@ var createIntegration11 = ({
|
|
|
181
182
|
}
|
|
182
183
|
};
|
|
183
184
|
};
|
|
184
|
-
var src_default =
|
|
185
|
+
var src_default = createIntegration12;
|
|
185
186
|
|
|
186
187
|
// ../astro-html-embeds/src/index.ts
|
|
187
188
|
init_esm_shims();
|
|
188
|
-
var
|
|
189
|
+
var createIntegration13 = () => {
|
|
189
190
|
return {
|
|
190
191
|
name: "@wix/astro/html-embeds",
|
|
191
192
|
hooks: {
|
|
@@ -201,11 +202,11 @@ var createIntegration12 = () => {
|
|
|
201
202
|
}
|
|
202
203
|
};
|
|
203
204
|
};
|
|
204
|
-
var src_default2 =
|
|
205
|
+
var src_default2 = createIntegration13;
|
|
205
206
|
|
|
206
207
|
// ../astro-payment-links/src/index.ts
|
|
207
208
|
init_esm_shims();
|
|
208
|
-
var
|
|
209
|
+
var createIntegration14 = () => {
|
|
209
210
|
return {
|
|
210
211
|
name: "@wix/astro/payment-links",
|
|
211
212
|
hooks: {
|
|
@@ -246,11 +247,11 @@ var createIntegration13 = () => {
|
|
|
246
247
|
}
|
|
247
248
|
};
|
|
248
249
|
};
|
|
249
|
-
var src_default3 =
|
|
250
|
+
var src_default3 = createIntegration14;
|
|
250
251
|
|
|
251
252
|
// ../astro-robots/src/index.ts
|
|
252
253
|
init_esm_shims();
|
|
253
|
-
var
|
|
254
|
+
var createIntegration15 = () => {
|
|
254
255
|
return {
|
|
255
256
|
name: "@wix/astro/robots",
|
|
256
257
|
hooks: {
|
|
@@ -267,15 +268,17 @@ var createIntegration14 = () => {
|
|
|
267
268
|
}
|
|
268
269
|
};
|
|
269
270
|
};
|
|
270
|
-
var src_default4 =
|
|
271
|
+
var src_default4 = createIntegration15;
|
|
271
272
|
|
|
272
273
|
// ../astro-translations/src/index.ts
|
|
273
274
|
init_esm_shims();
|
|
275
|
+
import { readFileSync } from "fs";
|
|
276
|
+
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
274
277
|
|
|
275
278
|
// ../astro-translations/src/utils/loadTranslations.ts
|
|
276
279
|
init_esm_shims();
|
|
277
280
|
import { readdir } from "fs/promises";
|
|
278
|
-
import { join } from "path";
|
|
281
|
+
import { join as join2 } from "path";
|
|
279
282
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
280
283
|
import { toNamespaceDictionary } from "@wix/headless-localization-utils";
|
|
281
284
|
|
|
@@ -286,10 +289,11 @@ var TRANSLATIONS_FILENAME = "translations.json";
|
|
|
286
289
|
|
|
287
290
|
// ../astro-translations/src/utils/errorMessages.ts
|
|
288
291
|
init_esm_shims();
|
|
292
|
+
import { join } from "path";
|
|
289
293
|
function createTranslationFilesError(translationsDir) {
|
|
290
294
|
return new Error(defaultOutdent`
|
|
291
295
|
Failed to load translation file(s).
|
|
292
|
-
💡 Tip: create a file '${translationsDir
|
|
296
|
+
💡 Tip: create a file '${join(translationsDir, "translations.json")}' in your project, then use the Wix CLI to push these keys.
|
|
293
297
|
|
|
294
298
|
Example translation file structure:
|
|
295
299
|
{
|
|
@@ -311,10 +315,10 @@ async function loadTranslationFile(filePath) {
|
|
|
311
315
|
async function loadAllTranslations(astroConfig) {
|
|
312
316
|
const srcDir = fileURLToPath2(astroConfig.srcDir);
|
|
313
317
|
const rootDir = fileURLToPath2(astroConfig.root);
|
|
314
|
-
const tempDir =
|
|
315
|
-
const multilingualDir =
|
|
316
|
-
const primaryTranslationPath =
|
|
317
|
-
const pulledTranslationsDir =
|
|
318
|
+
const tempDir = join2(rootDir, ".wix");
|
|
319
|
+
const multilingualDir = join2(tempDir, "multilingual");
|
|
320
|
+
const primaryTranslationPath = join2(srcDir, TRANSLATIONS_FILENAME);
|
|
321
|
+
const pulledTranslationsDir = join2(multilingualDir, "translations");
|
|
318
322
|
let metadata;
|
|
319
323
|
let primaryTranslation;
|
|
320
324
|
try {
|
|
@@ -330,7 +334,7 @@ async function loadAllTranslations(astroConfig) {
|
|
|
330
334
|
return { ...wixTranslations, ...primaryTranslation };
|
|
331
335
|
}
|
|
332
336
|
async function loadMetadata(translationsMetadataDir) {
|
|
333
|
-
const metadataPath =
|
|
337
|
+
const metadataPath = join2(
|
|
334
338
|
translationsMetadataDir,
|
|
335
339
|
TRANSLATIONS_METADATA_FILENAME
|
|
336
340
|
);
|
|
@@ -348,14 +352,47 @@ async function loadTranslations(translationsDir) {
|
|
|
348
352
|
const translations = {};
|
|
349
353
|
for (const file of jsonFiles) {
|
|
350
354
|
const languageCode = file.replace(".json", "");
|
|
351
|
-
const filePath =
|
|
355
|
+
const filePath = join2(translationsDir, file);
|
|
352
356
|
translations[languageCode] = await loadTranslationFile(filePath);
|
|
353
357
|
}
|
|
354
358
|
return translations;
|
|
355
359
|
}
|
|
356
360
|
|
|
361
|
+
// ../astro-translations/src/vite/wix-astro-i18n-plugin.ts
|
|
362
|
+
init_esm_shims();
|
|
363
|
+
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
364
|
+
var VIRTUAL_MODULE_ID = "wix:astro:i18n";
|
|
365
|
+
var RESOLVED_VIRTUAL_MODULE_ID = `\0${VIRTUAL_MODULE_ID}`;
|
|
366
|
+
var i18nRuntimePath = fileURLToPath3(
|
|
367
|
+
new URL(
|
|
368
|
+
"../dependencies/astro-translations/backend-runtime/runtime/i18n.js",
|
|
369
|
+
import.meta.url
|
|
370
|
+
)
|
|
371
|
+
);
|
|
372
|
+
var wixAstroI18nPlugin = () => {
|
|
373
|
+
return {
|
|
374
|
+
name: "vite-plugin-wix-astro-i18n",
|
|
375
|
+
enforce: "pre",
|
|
376
|
+
load(id) {
|
|
377
|
+
if (id !== RESOLVED_VIRTUAL_MODULE_ID) {
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
return `export * from '${i18nRuntimePath}';`;
|
|
381
|
+
},
|
|
382
|
+
resolveId(id) {
|
|
383
|
+
return id === VIRTUAL_MODULE_ID ? RESOLVED_VIRTUAL_MODULE_ID : void 0;
|
|
384
|
+
}
|
|
385
|
+
};
|
|
386
|
+
};
|
|
387
|
+
|
|
357
388
|
// ../astro-translations/src/index.ts
|
|
358
|
-
var
|
|
389
|
+
var i18nTypesPath = fileURLToPath4(
|
|
390
|
+
new URL(
|
|
391
|
+
"../dependencies/astro-translations/types/wix-astro-i18n.d.ts",
|
|
392
|
+
import.meta.url
|
|
393
|
+
)
|
|
394
|
+
);
|
|
395
|
+
var createIntegration16 = () => {
|
|
359
396
|
return {
|
|
360
397
|
name: "@wix/astro/static-translations",
|
|
361
398
|
hooks: {
|
|
@@ -368,29 +405,40 @@ var createIntegration15 = () => {
|
|
|
368
405
|
updateConfig({
|
|
369
406
|
vite: {
|
|
370
407
|
define: {
|
|
371
|
-
|
|
372
|
-
|
|
408
|
+
__WIX_ASTRO_I18N__: JSON.stringify({
|
|
409
|
+
base: astroConfig.base,
|
|
410
|
+
siteUrl: astroConfig.site ?? null,
|
|
411
|
+
translations
|
|
412
|
+
})
|
|
413
|
+
},
|
|
414
|
+
plugins: [wixAstroI18nPlugin()]
|
|
373
415
|
}
|
|
374
416
|
});
|
|
375
417
|
addMiddleware({
|
|
376
418
|
entrypoint: new URL(
|
|
377
|
-
"../dependencies/astro-translations/middleware/static-translations.js",
|
|
419
|
+
"../dependencies/astro-translations/backend-runtime/middleware/static-translations.js",
|
|
378
420
|
import.meta.url
|
|
379
421
|
),
|
|
380
422
|
order: "pre"
|
|
381
423
|
});
|
|
424
|
+
},
|
|
425
|
+
"astro:config:done": async ({ injectTypes }) => {
|
|
426
|
+
injectTypes({
|
|
427
|
+
content: readFileSync(i18nTypesPath, "utf-8"),
|
|
428
|
+
filename: "wix-astro-i18n.d.ts"
|
|
429
|
+
});
|
|
382
430
|
}
|
|
383
431
|
}
|
|
384
432
|
};
|
|
385
433
|
};
|
|
386
|
-
var src_default5 =
|
|
434
|
+
var src_default5 = createIntegration16;
|
|
387
435
|
|
|
388
436
|
// ../astro-viewer-api/src/index.ts
|
|
389
437
|
init_esm_shims();
|
|
390
438
|
|
|
391
439
|
// ../astro-viewer-api/src/integration.ts
|
|
392
440
|
init_esm_shims();
|
|
393
|
-
var
|
|
441
|
+
var createIntegration17 = () => {
|
|
394
442
|
return {
|
|
395
443
|
name: "@wix/astro/viewer-api",
|
|
396
444
|
hooks: {
|
|
@@ -415,7 +463,7 @@ function isEnabled(value, defaultValue = true) {
|
|
|
415
463
|
}
|
|
416
464
|
return value?.enable ?? defaultValue;
|
|
417
465
|
}
|
|
418
|
-
var
|
|
466
|
+
var createIntegration18 = (config) => {
|
|
419
467
|
const enableAuthRoutes = isEnabled(config?.auth);
|
|
420
468
|
const enableHtmlEmbeds = isEnabled(config?.htmlEmbeds);
|
|
421
469
|
const enableRobots = isEnabled(config?.robots);
|
|
@@ -431,17 +479,18 @@ var createIntegration17 = (config) => {
|
|
|
431
479
|
...enableBackofficeExtensions ? [createIntegration10(), createIntegration9()] : [],
|
|
432
480
|
createIntegration5(),
|
|
433
481
|
...enableHtmlEmbeds ? [src_default2()] : [],
|
|
434
|
-
...enableWixSitePages ? [src_default3(),
|
|
482
|
+
...enableWixSitePages ? [src_default3(), createIntegration17()] : [],
|
|
435
483
|
createIntegration6(),
|
|
436
484
|
createIntegration8(),
|
|
437
485
|
createIntegration7(),
|
|
486
|
+
createIntegration11(),
|
|
438
487
|
createIntegration2(),
|
|
439
488
|
createIntegration(),
|
|
440
489
|
...enableRobots ? [src_default4()] : []
|
|
441
490
|
];
|
|
442
491
|
return [createIntegration4({ integrations }), ...integrations];
|
|
443
492
|
};
|
|
444
|
-
var index_default =
|
|
493
|
+
var index_default = createIntegration18;
|
|
445
494
|
export {
|
|
446
495
|
index_default as default,
|
|
447
496
|
extensions
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../../astro-auth/src/index.ts","../../../astro-auth/src/plugins/patchAstroInlineScripts.ts","../../../astro-auth/src/plugins/setupContentCollectionContext.ts","../../../astro-html-embeds/src/index.ts","../../../astro-payment-links/src/index.ts","../../../astro-robots/src/index.ts","../../../astro-translations/src/index.ts","../../../astro-translations/src/utils/loadTranslations.ts","../../../astro-translations/src/constants.ts","../../../astro-translations/src/utils/errorMessages.ts","../../../astro-viewer-api/src/index.ts","../../../astro-viewer-api/src/integration.ts"],"sourcesContent":["import type { AstroIntegration } from 'astro';\nimport auth from '@wix/astro-auth';\nimport backend from '@wix/astro-backend-extensions';\nimport backoffice from '@wix/astro-backoffice-extensions';\nimport contextProviders from '@wix/astro-context-providers-extensions';\nimport core from '@wix/astro-core';\nimport customElements from '@wix/astro-custom-elements-extensions';\nimport embeddedScripts from '@wix/astro-embedded-scripts-extensions';\nimport functionLibraries from '@wix/astro-function-libraries-extensions';\nimport htmlEmbeds from '@wix/astro-html-embeds';\nimport paymentLinks from '@wix/astro-payment-links';\nimport robots from '@wix/astro-robots';\nimport siteComponentPanels from '@wix/astro-site-component-panels-extensions';\nimport siteComponents from '@wix/astro-site-components-extensions';\nimport translations from '@wix/astro-translations';\nimport internalBackoffice from '@wix/astro-trusted-backoffice-extensions';\nimport viewerApi from '@wix/astro-viewer-api';\n\nexport { extensions } from './builders.js';\n\ninterface WixAstroConfig {\n auth?: boolean | { enable?: boolean };\n backendExtensions?: boolean | { enable?: boolean };\n backofficeExtensions?: boolean | { enable?: boolean };\n essentials?: boolean | { enable?: boolean };\n htmlEmbeds?: boolean | { enable?: boolean };\n robots?: boolean | { enable?: boolean };\n translations?: boolean | { enable?: boolean };\n wixSitePages?: boolean | { enable?: boolean };\n}\n\nfunction isEnabled(\n value?: boolean | { enable?: boolean },\n defaultValue = true\n): boolean {\n if (typeof value === 'boolean') {\n return value;\n }\n return value?.enable ?? defaultValue;\n}\n\nconst createIntegration = (config?: WixAstroConfig): AstroIntegration[] => {\n const enableAuthRoutes = isEnabled(config?.auth);\n const enableHtmlEmbeds = isEnabled(config?.htmlEmbeds);\n const enableRobots = isEnabled(config?.robots);\n const enableBackendExtensions = isEnabled(config?.backendExtensions);\n const enableBackofficeExtensions = isEnabled(config?.backofficeExtensions);\n const enableWixSitePages = isEnabled(config?.wixSitePages);\n const enableWixEssentials = isEnabled(config?.essentials, false);\n const enableTranslations = isEnabled(config?.translations, false);\n\n const integrations = [\n auth({ enableAuthRoutes, enableWixEssentials }),\n ...(enableTranslations && enableWixEssentials ? [translations()] : []),\n ...(enableBackendExtensions ? [backend()] : []),\n ...(enableBackofficeExtensions ? [backoffice(), internalBackoffice()] : []),\n customElements(),\n ...(enableHtmlEmbeds ? [htmlEmbeds()] : []),\n ...(enableWixSitePages ? [paymentLinks(), viewerApi()] : []),\n embeddedScripts(),\n siteComponents(),\n siteComponentPanels(),\n functionLibraries(),\n contextProviders(),\n ...(enableRobots ? [robots()] : []),\n ];\n\n return [core({ integrations }), ...integrations];\n};\n\nexport default createIntegration;\n","import { fileURLToPath } from 'node:url';\nimport type { WixIntegration } from '@wix/astro-core';\nimport { normalizePath } from '@wix/vite-utils';\nimport { outdent } from 'outdent';\nimport { patchAstroInlineScripts } from './plugins/patchAstroInlineScripts.js';\nimport { setupContentCollectionContext } from './plugins/setupContentCollectionContext.js';\n\nconst setupContextUrl = new URL(\n '../dependencies/astro-auth/browser-runtime/setup.js',\n import.meta.url\n);\n\nconst createIntegration = ({\n enableAuthRoutes,\n enableWixEssentials,\n}: {\n enableAuthRoutes: boolean;\n enableWixEssentials: boolean;\n}): WixIntegration => {\n return {\n name: '@wix/astro/auth',\n hooks: {\n 'astro:config:setup'({\n addMiddleware,\n config,\n injectRoute,\n injectScript,\n updateConfig,\n }) {\n const srcDir = fileURLToPath(config.srcDir);\n\n updateConfig({\n vite: {\n plugins: [\n setupContentCollectionContext(srcDir),\n patchAstroInlineScripts(),\n ],\n },\n });\n\n const setupContextCode = outdent`\n import { WIX_CLIENT_ID } from 'astro:env/client';\n import { setup } from '${normalizePath(setupContextUrl)}';\n\n setup({ clientId: WIX_CLIENT_ID });\n `;\n\n // support client-side context calls\n injectScript('before-hydration', setupContextCode);\n injectScript('page', setupContextCode);\n\n // support server side context calls\n addMiddleware({\n entrypoint: new URL(\n '../dependencies/astro-auth/backend-runtime/middleware/auth.js',\n import.meta.url\n ),\n order: 'pre',\n });\n\n // support localization\n if (enableWixEssentials) {\n addMiddleware({\n entrypoint: new URL(\n '../dependencies/astro-auth/backend-runtime/middleware/localization.js',\n import.meta.url\n ),\n order: 'pre',\n });\n }\n\n // support built-in auth routes\n if (enableAuthRoutes) {\n injectRoute({\n entrypoint: new URL(\n '../dependencies/astro-auth/backend-runtime/routes/login.js',\n import.meta.url\n ),\n pattern: '/api/auth/login',\n prerender: false,\n });\n\n injectRoute({\n entrypoint: new URL(\n '../dependencies/astro-auth/backend-runtime/routes/logout.js',\n import.meta.url\n ),\n pattern: '/api/auth/logout',\n prerender: false,\n });\n\n injectRoute({\n entrypoint: new URL(\n '../dependencies/astro-auth/backend-runtime/routes/callback.js',\n import.meta.url\n ),\n pattern: '/api/auth/callback',\n prerender: false,\n });\n\n injectRoute({\n entrypoint: new URL(\n '../dependencies/astro-auth/backend-runtime/routes/logout-callback.js',\n import.meta.url\n ),\n pattern: '/api/auth/logout-callback',\n prerender: false,\n });\n }\n },\n },\n };\n};\n\nexport default createIntegration;\n","import type { PluginOption } from 'vite';\nimport { outdent } from 'outdent';\n\nexport function patchAstroInlineScripts(): PluginOption {\n return {\n name: 'patch-astro-inline-scripts',\n transform(code, id) {\n const [_filename, rawQuery] = id.split(`?`, 2);\n const query = Object.fromEntries(new URLSearchParams(rawQuery).entries());\n\n if (\n query.astro == null ||\n query.type !== 'script' ||\n query['lang.ts'] == null ||\n code === ''\n ) {\n return null;\n }\n\n return outdent`\n import 'astro:scripts/page.js';\n\n ${code}\n `;\n },\n };\n}\n","import { relative } from 'node:path';\nimport type { PluginOption } from 'vite';\nimport { normalizePath } from '@wix/vite-utils';\nimport { outdent } from 'outdent';\n\n// https://github.com/withastro/astro/blob/e0c4460c5b6cc0c19b705d81820809aef0544100/packages/astro/src/content/utils.ts#L748-L763\nconst contentCollectionFilePaths = [\n 'content.config.mjs',\n 'content.config.js',\n 'content.config.mts',\n 'content.config.ts',\n 'content/config.mjs',\n 'content/config.js',\n 'content/config.mts',\n 'content/config.ts',\n];\n\nconst setupContextualClientUrl = new URL(\n '../dependencies/astro-auth/backend-runtime/runtime/backend/setupContextualClient.js',\n import.meta.url\n);\n\nexport function setupContentCollectionContext(srcDir: string): PluginOption {\n return {\n name: 'setup-content-collection-context',\n applyToEnvironment(environment) {\n return environment.name === 'ssr';\n },\n transform(code, id) {\n const relativeId = relative(srcDir, id);\n\n const isContentCollectionFile =\n contentCollectionFilePaths.includes(relativeId);\n\n if (isContentCollectionFile) {\n return outdent`\n import '${normalizePath(setupContextualClientUrl)}';\n\n ${code}\n `;\n }\n\n return null;\n },\n };\n}\n","import type { WixIntegration } from '@wix/astro-core';\n\nconst createIntegration = (): WixIntegration => {\n return {\n name: '@wix/astro/html-embeds',\n hooks: {\n 'astro:config:setup'({ addMiddleware }) {\n addMiddleware({\n entrypoint: new URL(\n '../dependencies/astro-html-embeds/backend-runtime/html-embeds.js',\n import.meta.url\n ),\n order: 'post',\n });\n },\n },\n };\n};\n\nexport default createIntegration;\n","import type { WixIntegration } from '@wix/astro-core';\n\nconst createIntegration = (): WixIntegration => {\n return {\n name: '@wix/astro/payment-links',\n hooks: {\n 'astro:config:setup'({ injectRoute }) {\n /*\n 1. A user generates a paylink -> https://mysite.com/_paylink/[id]\n 2. When accessing the paylink, our route redirects them to the Wix Payments link\n 3. Wix Payments then redirects the user to Wix Checkout,\n which may resolve to either https://mysite.com/checkout/... or https://mysite.com/__ecom/checkout/...,\n depending on the flow within Wix.\n */\n\n injectRoute({\n entrypoint: new URL(\n '../dependencies/astro-payment-links/backend-runtime/payment-link.js',\n import.meta.url\n ),\n pattern: '/_paylink/[id]',\n prerender: false,\n });\n\n injectRoute({\n entrypoint: new URL(\n '../dependencies/astro-payment-links/backend-runtime/payment-checkout.js',\n import.meta.url\n ),\n pattern: '/checkout',\n prerender: false,\n });\n\n injectRoute({\n entrypoint: new URL(\n '../dependencies/astro-payment-links/backend-runtime/payment-checkout.js',\n import.meta.url\n ),\n pattern: '/__ecom/checkout',\n prerender: false,\n });\n\n injectRoute({\n entrypoint: new URL(\n '../dependencies/astro-payment-links/backend-runtime/proposal.js',\n import.meta.url\n ),\n pattern: '/_proposal',\n prerender: false,\n });\n },\n },\n };\n};\n\nexport default createIntegration;\n","import type { WixIntegration } from '@wix/astro-core';\n\nconst createIntegration = (): WixIntegration => {\n return {\n name: '@wix/astro/robots',\n hooks: {\n 'astro:config:setup'({ injectRoute }) {\n injectRoute({\n entrypoint: new URL(\n '../dependencies/astro-robots/backend-runtime/robots.js',\n import.meta.url\n ),\n pattern: '/robots.txt',\n prerender: false,\n });\n },\n },\n };\n};\n\nexport default createIntegration;\n","import type { WixIntegration } from '@wix/astro-core';\nimport { loadAllTranslations } from './utils/loadTranslations.js';\n\nconst createIntegration = (): WixIntegration => {\n return {\n name: '@wix/astro/static-translations',\n hooks: {\n 'astro:config:setup': async ({\n addMiddleware,\n config: astroConfig,\n updateConfig,\n }) => {\n const translations = await loadAllTranslations(astroConfig);\n\n updateConfig({\n vite: {\n define: {\n __WIX_TRANSLATIONS__: JSON.stringify(translations),\n },\n },\n });\n\n addMiddleware({\n entrypoint: new URL(\n '../dependencies/astro-translations/middleware/static-translations.js',\n import.meta.url\n ),\n order: 'pre',\n });\n },\n },\n };\n};\n\nexport default createIntegration;\n","import { readdir } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport type { AstroConfig } from 'astro';\nimport { readJson } from '@wix/fs-utils';\nimport { toNamespaceDictionary } from '@wix/headless-localization-utils';\nimport type { Translations, TranslationsMetadata } from '../types.js';\nimport {\n TRANSLATIONS_FILENAME,\n TRANSLATIONS_METADATA_FILENAME,\n} from '../constants.js';\nimport { createTranslationFilesError } from './errorMessages.js';\n\nasync function loadTranslationFile(filePath: string) {\n return readJson(filePath).then((data) =>\n toNamespaceDictionary(data as Record<string, unknown>)\n );\n}\n\n/**\n * Load the primary translation from `src/translations.json` and the other translation files from `.wix/multilingual/translations`.\n * Merges translations with `src/translations.json` taking priority over `.wix/multilingual/translations`.\n */\nexport async function loadAllTranslations(astroConfig: AstroConfig) {\n const srcDir = fileURLToPath(astroConfig.srcDir);\n const rootDir = fileURLToPath(astroConfig.root);\n\n const tempDir = join(rootDir, '.wix');\n const multilingualDir = join(tempDir, 'multilingual');\n const primaryTranslationPath = join(srcDir, TRANSLATIONS_FILENAME);\n const pulledTranslationsDir = join(multilingualDir, 'translations');\n\n let metadata;\n let primaryTranslation;\n\n try {\n metadata = await loadMetadata(multilingualDir);\n primaryTranslation = await loadPrimaryTranslation(\n primaryTranslationPath,\n metadata\n );\n } catch {\n throw createTranslationFilesError(srcDir);\n }\n\n const wixTranslations = await loadTranslations(pulledTranslationsDir);\n\n return { ...wixTranslations, ...primaryTranslation };\n}\n\nasync function loadMetadata(translationsMetadataDir: string) {\n const metadataPath = join(\n translationsMetadataDir,\n TRANSLATIONS_METADATA_FILENAME\n );\n return (await readJson(metadataPath)) as TranslationsMetadata;\n}\n\nasync function loadPrimaryTranslation(\n primaryTranslationPath: string,\n metadata: TranslationsMetadata\n) {\n const translationContent = await loadTranslationFile(primaryTranslationPath);\n\n return {\n [metadata.primaryLanguageCode]: translationContent,\n };\n}\n\nasync function loadTranslations(translationsDir: string) {\n const files = await readdir(translationsDir);\n const jsonFiles = files.filter((file) => file.endsWith('.json'));\n\n const translations: Translations = {};\n\n for (const file of jsonFiles) {\n const languageCode = file.replace('.json', '');\n const filePath = join(translationsDir, file);\n translations[languageCode] = await loadTranslationFile(filePath);\n }\n\n return translations;\n}\n","export const TRANSLATIONS_METADATA_FILENAME = 'metadata.json';\nexport const TRANSLATIONS_FILENAME = 'translations.json';\n","import { outdent } from 'outdent';\n\nexport function createTranslationFilesError(translationsDir: string): Error {\n return new Error(outdent`\n Failed to load translation file(s).\n 💡 Tip: create a file '${translationsDir}/translations.json' in your project, then use the Wix CLI to push these keys.\n\n Example translation file structure:\n {\n \"hello\": \"Hello\",\n \"goodbye\": \"Goodbye\"\n }\n\n 🔍 Need Help?\n - Visit our docs: https://dev.wix.com/docs/go-headless\n `);\n}\n","export { createIntegration as default } from './integration.js';\n","import type { WixIntegration } from '@wix/astro-core';\n\nexport const createIntegration = (): WixIntegration => {\n return {\n name: '@wix/astro/viewer-api',\n hooks: {\n 'astro:config:setup'({ injectRoute }) {\n injectRoute({\n entrypoint: new URL(\n '../dependencies/astro-viewer-api/backend-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AA,EACF;AACF;;;AZaA,SAAS,UACP,OACA,eAAe,MACN;AACT,MAAI,OAAO,UAAU,WAAW;AAC9B,WAAO;AAAA,EACT;AACA,SAAO,OAAO,UAAU;AAC1B;AAEA,IAAMC,sBAAoB,CAAC,WAAgD;AACzE,QAAM,mBAAmB,UAAU,QAAQ,IAAI;AAC/C,QAAM,mBAAmB,UAAU,QAAQ,UAAU;AACrD,QAAM,eAAe,UAAU,QAAQ,MAAM;AAC7C,QAAM,0BAA0B,UAAU,QAAQ,iBAAiB;AACnE,QAAM,6BAA6B,UAAU,QAAQ,oBAAoB;AACzE,QAAM,qBAAqB,UAAU,QAAQ,YAAY;AACzD,QAAM,sBAAsB,UAAU,QAAQ,YAAY,KAAK;AAC/D,QAAM,qBAAqB,UAAU,QAAQ,cAAc,KAAK;AAEhE,QAAM,eAAe;AAAA,IACnB,YAAK,EAAE,kBAAkB,oBAAoB,CAAC;AAAA,IAC9C,GAAI,sBAAsB,sBAAsB,CAACC,aAAa,CAAC,IAAI,CAAC;AAAA,IACpE,GAAI,0BAA0B,CAACD,mBAAQ,CAAC,IAAI,CAAC;AAAA,IAC7C,GAAI,6BAA6B,CAACA,oBAAW,GAAGA,mBAAmB,CAAC,IAAI,CAAC;AAAA,IACzEA,mBAAe;AAAA,IACf,GAAI,mBAAmB,CAACC,aAAW,CAAC,IAAI,CAAC;AAAA,IACzC,GAAI,qBAAqB,CAACA,aAAa,GAAGD,oBAAU,CAAC,IAAI,CAAC;AAAA,IAC1DA,mBAAgB;AAAA,IAChBA,mBAAe;AAAA,IACfA,mBAAoB;AAAA,IACpBA,mBAAkB;AAAA,IAClB,kBAAiB;AAAA,IACjB,GAAI,eAAe,CAACC,aAAO,CAAC,IAAI,CAAC;AAAA,EACnC;AAEA,SAAO,CAACD,mBAAK,EAAE,aAAa,CAAC,GAAG,GAAG,YAAY;AACjD;AAEA,IAAO,gBAAQA;","names":["createIntegration","createIntegration","src_default","createIntegration","src_default","createIntegration","src_default","fileURLToPath","fileURLToPath","createIntegration","src_default","createIntegration","createIntegration","src_default"]}
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts","../../../astro-auth/src/index.ts","../../../astro-auth/src/plugins/patchAstroInlineScripts.ts","../../../astro-auth/src/plugins/setupContentCollectionContext.ts","../../../astro-html-embeds/src/index.ts","../../../astro-payment-links/src/index.ts","../../../astro-robots/src/index.ts","../../../astro-translations/src/index.ts","../../../astro-translations/src/utils/loadTranslations.ts","../../../astro-translations/src/constants.ts","../../../astro-translations/src/utils/errorMessages.ts","../../../astro-translations/src/vite/wix-astro-i18n-plugin.ts","../../../astro-viewer-api/src/index.ts","../../../astro-viewer-api/src/integration.ts"],"sourcesContent":["import type { AstroIntegration } from 'astro';\nimport auth from '@wix/astro-auth';\nimport backend from '@wix/astro-backend-extensions';\nimport backoffice from '@wix/astro-backoffice-extensions';\nimport contextProviders from '@wix/astro-context-providers-extensions';\nimport core from '@wix/astro-core';\nimport customElements from '@wix/astro-custom-elements-extensions';\nimport embeddedScripts from '@wix/astro-embedded-scripts-extensions';\nimport functionLibraries from '@wix/astro-function-libraries-extensions';\nimport htmlEmbeds from '@wix/astro-html-embeds';\nimport paymentLinks from '@wix/astro-payment-links';\nimport robots from '@wix/astro-robots';\nimport siteComponentPanels from '@wix/astro-site-component-panels-extensions';\nimport siteComponents from '@wix/astro-site-components-extensions';\nimport translations from '@wix/astro-translations';\nimport internalBackoffice from '@wix/astro-trusted-backoffice-extensions';\nimport viewerApi from '@wix/astro-viewer-api';\nimport viewerServices from '@wix/astro-viewer-services-extensions';\n\nexport { extensions } from './builders.js';\n\ninterface WixAstroConfig {\n auth?: boolean | { enable?: boolean };\n backendExtensions?: boolean | { enable?: boolean };\n backofficeExtensions?: boolean | { enable?: boolean };\n essentials?: boolean | { enable?: boolean };\n htmlEmbeds?: boolean | { enable?: boolean };\n robots?: boolean | { enable?: boolean };\n translations?: boolean | { enable?: boolean };\n wixSitePages?: boolean | { enable?: boolean };\n}\n\nfunction isEnabled(\n value?: boolean | { enable?: boolean },\n defaultValue = true\n): boolean {\n if (typeof value === 'boolean') {\n return value;\n }\n return value?.enable ?? defaultValue;\n}\n\nconst createIntegration = (config?: WixAstroConfig): AstroIntegration[] => {\n const enableAuthRoutes = isEnabled(config?.auth);\n const enableHtmlEmbeds = isEnabled(config?.htmlEmbeds);\n const enableRobots = isEnabled(config?.robots);\n const enableBackendExtensions = isEnabled(config?.backendExtensions);\n const enableBackofficeExtensions = isEnabled(config?.backofficeExtensions);\n const enableWixSitePages = isEnabled(config?.wixSitePages);\n const enableWixEssentials = isEnabled(config?.essentials, false);\n const enableTranslations = isEnabled(config?.translations, false);\n\n const integrations = [\n auth({ enableAuthRoutes, enableWixEssentials }),\n ...(enableTranslations && enableWixEssentials ? [translations()] : []),\n ...(enableBackendExtensions ? [backend()] : []),\n ...(enableBackofficeExtensions ? [backoffice(), internalBackoffice()] : []),\n customElements(),\n ...(enableHtmlEmbeds ? [htmlEmbeds()] : []),\n ...(enableWixSitePages ? [paymentLinks(), viewerApi()] : []),\n embeddedScripts(),\n siteComponents(),\n siteComponentPanels(),\n viewerServices(),\n functionLibraries(),\n contextProviders(),\n ...(enableRobots ? [robots()] : []),\n ];\n\n return [core({ integrations }), ...integrations];\n};\n\nexport default createIntegration;\n","import { fileURLToPath } from 'node:url';\nimport type { WixIntegration } from '@wix/astro-core';\nimport { normalizePath } from '@wix/vite-utils';\nimport { outdent } from 'outdent';\nimport { patchAstroInlineScripts } from './plugins/patchAstroInlineScripts.js';\nimport { setupContentCollectionContext } from './plugins/setupContentCollectionContext.js';\n\nconst setupContextUrl = new URL(\n '../dependencies/astro-auth/browser-runtime/setup.js',\n import.meta.url\n);\n\nconst createIntegration = ({\n enableAuthRoutes,\n enableWixEssentials,\n}: {\n enableAuthRoutes: boolean;\n enableWixEssentials: boolean;\n}): WixIntegration => {\n return {\n name: '@wix/astro/auth',\n hooks: {\n 'astro:config:setup'({\n addMiddleware,\n config,\n injectRoute,\n injectScript,\n updateConfig,\n }) {\n const srcDir = fileURLToPath(config.srcDir);\n\n updateConfig({\n vite: {\n plugins: [\n setupContentCollectionContext(srcDir),\n patchAstroInlineScripts(),\n ],\n },\n });\n\n const setupContextCode = outdent`\n import { WIX_CLIENT_ID } from 'astro:env/client';\n import { setup } from '${normalizePath(setupContextUrl)}';\n\n setup({ clientId: WIX_CLIENT_ID });\n `;\n\n // support client-side context calls\n injectScript('before-hydration', setupContextCode);\n injectScript('page', setupContextCode);\n\n // support server side context calls\n addMiddleware({\n entrypoint: new URL(\n '../dependencies/astro-auth/backend-runtime/middleware/auth.js',\n import.meta.url\n ),\n order: 'pre',\n });\n\n // support localization\n if (enableWixEssentials) {\n addMiddleware({\n entrypoint: new URL(\n '../dependencies/astro-auth/backend-runtime/middleware/localization.js',\n import.meta.url\n ),\n order: 'pre',\n });\n }\n\n // support built-in auth routes\n if (enableAuthRoutes) {\n injectRoute({\n entrypoint: new URL(\n '../dependencies/astro-auth/backend-runtime/routes/login.js',\n import.meta.url\n ),\n pattern: '/api/auth/login',\n prerender: false,\n });\n\n injectRoute({\n entrypoint: new URL(\n '../dependencies/astro-auth/backend-runtime/routes/logout.js',\n import.meta.url\n ),\n pattern: '/api/auth/logout',\n prerender: false,\n });\n\n injectRoute({\n entrypoint: new URL(\n '../dependencies/astro-auth/backend-runtime/routes/callback.js',\n import.meta.url\n ),\n pattern: '/api/auth/callback',\n prerender: false,\n });\n\n injectRoute({\n entrypoint: new URL(\n '../dependencies/astro-auth/backend-runtime/routes/logout-callback.js',\n import.meta.url\n ),\n pattern: '/api/auth/logout-callback',\n prerender: false,\n });\n }\n },\n },\n };\n};\n\nexport default createIntegration;\n","import type { PluginOption } from 'vite';\nimport { outdent } from 'outdent';\n\nexport function patchAstroInlineScripts(): PluginOption {\n return {\n name: 'patch-astro-inline-scripts',\n transform(code, id) {\n const [_filename, rawQuery] = id.split(`?`, 2);\n const query = Object.fromEntries(new URLSearchParams(rawQuery).entries());\n\n if (\n query.astro == null ||\n query.type !== 'script' ||\n query['lang.ts'] == null ||\n code === ''\n ) {\n return null;\n }\n\n return outdent`\n import 'astro:scripts/page.js';\n\n ${code}\n `;\n },\n };\n}\n","import { relative } from 'node:path';\nimport type { PluginOption } from 'vite';\nimport { normalizePath } from '@wix/vite-utils';\nimport { outdent } from 'outdent';\n\n// https://github.com/withastro/astro/blob/e0c4460c5b6cc0c19b705d81820809aef0544100/packages/astro/src/content/utils.ts#L748-L763\nconst contentCollectionFilePaths = [\n 'content.config.mjs',\n 'content.config.js',\n 'content.config.mts',\n 'content.config.ts',\n 'content/config.mjs',\n 'content/config.js',\n 'content/config.mts',\n 'content/config.ts',\n];\n\nconst setupContextualClientUrl = new URL(\n '../dependencies/astro-auth/backend-runtime/runtime/backend/setupContextualClient.js',\n import.meta.url\n);\n\nexport function setupContentCollectionContext(srcDir: string): PluginOption {\n return {\n name: 'setup-content-collection-context',\n applyToEnvironment(environment) {\n return environment.name === 'ssr';\n },\n transform(code, id) {\n const relativeId = relative(srcDir, id);\n\n const isContentCollectionFile =\n contentCollectionFilePaths.includes(relativeId);\n\n if (isContentCollectionFile) {\n return outdent`\n import '${normalizePath(setupContextualClientUrl)}';\n\n ${code}\n `;\n }\n\n return null;\n },\n };\n}\n","import type { WixIntegration } from '@wix/astro-core';\n\nconst createIntegration = (): WixIntegration => {\n return {\n name: '@wix/astro/html-embeds',\n hooks: {\n 'astro:config:setup'({ addMiddleware }) {\n addMiddleware({\n entrypoint: new URL(\n '../dependencies/astro-html-embeds/backend-runtime/html-embeds.js',\n import.meta.url\n ),\n order: 'post',\n });\n },\n },\n };\n};\n\nexport default createIntegration;\n","import type { WixIntegration } from '@wix/astro-core';\n\nconst createIntegration = (): WixIntegration => {\n return {\n name: '@wix/astro/payment-links',\n hooks: {\n 'astro:config:setup'({ injectRoute }) {\n /*\n 1. A user generates a paylink -> https://mysite.com/_paylink/[id]\n 2. When accessing the paylink, our route redirects them to the Wix Payments link\n 3. Wix Payments then redirects the user to Wix Checkout,\n which may resolve to either https://mysite.com/checkout/... or https://mysite.com/__ecom/checkout/...,\n depending on the flow within Wix.\n */\n\n injectRoute({\n entrypoint: new URL(\n '../dependencies/astro-payment-links/backend-runtime/payment-link.js',\n import.meta.url\n ),\n pattern: '/_paylink/[id]',\n prerender: false,\n });\n\n injectRoute({\n entrypoint: new URL(\n '../dependencies/astro-payment-links/backend-runtime/payment-checkout.js',\n import.meta.url\n ),\n pattern: '/checkout',\n prerender: false,\n });\n\n injectRoute({\n entrypoint: new URL(\n '../dependencies/astro-payment-links/backend-runtime/payment-checkout.js',\n import.meta.url\n ),\n pattern: '/__ecom/checkout',\n prerender: false,\n });\n\n injectRoute({\n entrypoint: new URL(\n '../dependencies/astro-payment-links/backend-runtime/proposal.js',\n import.meta.url\n ),\n pattern: '/_proposal',\n prerender: false,\n });\n },\n },\n };\n};\n\nexport default createIntegration;\n","import type { WixIntegration } from '@wix/astro-core';\n\nconst createIntegration = (): WixIntegration => {\n return {\n name: '@wix/astro/robots',\n hooks: {\n 'astro:config:setup'({ injectRoute }) {\n injectRoute({\n entrypoint: new URL(\n '../dependencies/astro-robots/backend-runtime/robots.js',\n import.meta.url\n ),\n pattern: '/robots.txt',\n prerender: false,\n });\n },\n },\n };\n};\n\nexport default createIntegration;\n","import { readFileSync } from 'node:fs';\nimport { fileURLToPath } from 'node:url';\nimport type { WixIntegration } from '@wix/astro-core';\nimport { loadAllTranslations } from './utils/loadTranslations.js';\nimport { wixAstroI18nPlugin } from './vite/wix-astro-i18n-plugin.js';\n\nconst i18nTypesPath = fileURLToPath(\n new URL(\n '../dependencies/astro-translations/types/wix-astro-i18n.d.ts',\n import.meta.url\n )\n);\n\nconst createIntegration = (): WixIntegration => {\n return {\n name: '@wix/astro/static-translations',\n hooks: {\n 'astro:config:setup': async ({\n addMiddleware,\n config: astroConfig,\n updateConfig,\n }) => {\n const translations = await loadAllTranslations(astroConfig);\n\n updateConfig({\n vite: {\n define: {\n __WIX_ASTRO_I18N__: JSON.stringify({\n base: astroConfig.base,\n siteUrl: astroConfig.site ?? null,\n translations,\n }),\n },\n plugins: [wixAstroI18nPlugin()],\n },\n });\n\n addMiddleware({\n entrypoint: new URL(\n '../dependencies/astro-translations/backend-runtime/middleware/static-translations.js',\n import.meta.url\n ),\n order: 'pre',\n });\n },\n\n 'astro:config:done': async ({ injectTypes }) => {\n injectTypes({\n content: readFileSync(i18nTypesPath, 'utf-8'),\n filename: 'wix-astro-i18n.d.ts',\n });\n },\n },\n };\n};\n\nexport default createIntegration;\n","import { readdir } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport type { AstroConfig } from 'astro';\nimport { readJson } from '@wix/fs-utils';\nimport { toNamespaceDictionary } from '@wix/headless-localization-utils';\nimport type { Translations, TranslationsMetadata } from '../types.js';\nimport {\n TRANSLATIONS_FILENAME,\n TRANSLATIONS_METADATA_FILENAME,\n} from '../constants.js';\nimport { createTranslationFilesError } from './errorMessages.js';\n\nasync function loadTranslationFile(filePath: string) {\n return readJson(filePath).then((data) =>\n toNamespaceDictionary(data as Record<string, unknown>)\n );\n}\n\n/**\n * Load the primary translation from `src/translations.json` and the other translation files from `.wix/multilingual/translations`.\n * Merges translations with `src/translations.json` taking priority over `.wix/multilingual/translations`.\n */\nexport async function loadAllTranslations(astroConfig: AstroConfig) {\n const srcDir = fileURLToPath(astroConfig.srcDir);\n const rootDir = fileURLToPath(astroConfig.root);\n\n const tempDir = join(rootDir, '.wix');\n const multilingualDir = join(tempDir, 'multilingual');\n const primaryTranslationPath = join(srcDir, TRANSLATIONS_FILENAME);\n const pulledTranslationsDir = join(multilingualDir, 'translations');\n\n let metadata;\n let primaryTranslation;\n\n try {\n metadata = await loadMetadata(multilingualDir);\n primaryTranslation = await loadPrimaryTranslation(\n primaryTranslationPath,\n metadata\n );\n } catch {\n throw createTranslationFilesError(srcDir);\n }\n\n const wixTranslations = await loadTranslations(pulledTranslationsDir);\n\n return { ...wixTranslations, ...primaryTranslation };\n}\n\nasync function loadMetadata(translationsMetadataDir: string) {\n const metadataPath = join(\n translationsMetadataDir,\n TRANSLATIONS_METADATA_FILENAME\n );\n return (await readJson(metadataPath)) as TranslationsMetadata;\n}\n\nasync function loadPrimaryTranslation(\n primaryTranslationPath: string,\n metadata: TranslationsMetadata\n) {\n const translationContent = await loadTranslationFile(primaryTranslationPath);\n\n return {\n [metadata.primaryLanguageCode]: translationContent,\n };\n}\n\nasync function loadTranslations(translationsDir: string) {\n const files = await readdir(translationsDir);\n\n const jsonFiles = files.filter((file) => file.endsWith('.json'));\n\n const translations: Translations = {};\n\n for (const file of jsonFiles) {\n const languageCode = file.replace('.json', '');\n const filePath = join(translationsDir, file);\n translations[languageCode] = await loadTranslationFile(filePath);\n }\n\n return translations;\n}\n","export const TRANSLATIONS_METADATA_FILENAME = 'metadata.json';\nexport const TRANSLATIONS_FILENAME = 'translations.json';\n","import { join } from 'node:path';\nimport { outdent } from 'outdent';\n\nexport function createTranslationFilesError(translationsDir: string): Error {\n return new Error(outdent`\n Failed to load translation file(s).\n 💡 Tip: create a file '${join(translationsDir, 'translations.json')}' in your project, then use the Wix CLI to push these keys.\n\n Example translation file structure:\n {\n \"hello\": \"Hello\",\n \"goodbye\": \"Goodbye\"\n }\n\n 🔍 Need Help?\n - Visit our docs: https://dev.wix.com/docs/go-headless\n `);\n}\n","import { fileURLToPath } from 'node:url';\nimport type { PluginOption } from 'vite';\n\nconst VIRTUAL_MODULE_ID = 'wix:astro:i18n';\nconst RESOLVED_VIRTUAL_MODULE_ID = `\\0${VIRTUAL_MODULE_ID}`;\n\nconst i18nRuntimePath = fileURLToPath(\n new URL(\n '../dependencies/astro-translations/backend-runtime/runtime/i18n.js',\n import.meta.url\n )\n);\n\nexport const wixAstroI18nPlugin = (): PluginOption => {\n return {\n name: 'vite-plugin-wix-astro-i18n',\n\n enforce: 'pre',\n\n load(id) {\n if (id !== RESOLVED_VIRTUAL_MODULE_ID) {\n return;\n }\n\n return `export * from '${i18nRuntimePath}';`;\n },\n\n resolveId(id) {\n return id === VIRTUAL_MODULE_ID ? RESOLVED_VIRTUAL_MODULE_ID : undefined;\n },\n };\n};\n","export { createIntegration as default } from './integration.js';\n","import type { WixIntegration } from '@wix/astro-core';\n\nexport const createIntegration = (): WixIntegration => {\n return {\n name: '@wix/astro/viewer-api',\n hooks: {\n 'astro:config:setup'({ injectRoute }) {\n injectRoute({\n entrypoint: new URL(\n '../dependencies/astro-viewer-api/backend-runtime/api.js',\n import.meta.url\n ),\n pattern: '/_api/[...path]',\n prerender: false,\n });\n },\n },\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;ACAA;AAAA,SAAS,qBAAqB;;;ACA9B;AAGO,SAAS,0BAAwC;AACtD,SAAO;AAAA,IACL,MAAM;AAAA,IACN,UAAU,MAAM,IAAI;AAClB,YAAM,CAAC,WAAW,QAAQ,IAAI,GAAG,MAAM,KAAK,CAAC;AAC7C,YAAM,QAAQ,OAAO,YAAY,IAAI,gBAAgB,QAAQ,EAAE,QAAQ,CAAC;AAExE,UACE,MAAM,SAAS,QACf,MAAM,SAAS,YACf,MAAM,SAAS,KAAK,QACpB,SAAS,IACT;AACA,eAAO;AAAA,MACT;AAEA,aAAO;AAAA;AAAA;AAAA,UAGH,IAAI;AAAA;AAAA,IAEV;AAAA,EACF;AACF;;;AC1BA;AAAA,SAAS,gBAAgB;AAMzB,IAAM,6BAA6B;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,IAAM,2BAA2B,IAAI;AAAA,EACnC;AAAA,EACA,YAAY;AACd;AAEO,SAAS,8BAA8B,QAA8B;AAC1E,SAAO;AAAA,IACL,MAAM;AAAA,IACN,mBAAmB,aAAa;AAC9B,aAAO,YAAY,SAAS;AAAA,IAC9B;AAAA,IACA,UAAU,MAAM,IAAI;AAClB,YAAM,aAAa,SAAS,QAAQ,EAAE;AAEtC,YAAM,0B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AAO,UAAU,WAAW;AAC9B,WAAO;AAAA,EACT;AACA,SAAO,OAAO,UAAU;AAC1B;AAEA,IAAMC,sBAAoB,CAAC,WAAgD;AACzE,QAAM,mBAAmB,UAAU,QAAQ,IAAI;AAC/C,QAAM,mBAAmB,UAAU,QAAQ,UAAU;AACrD,QAAM,eAAe,UAAU,QAAQ,MAAM;AAC7C,QAAM,0BAA0B,UAAU,QAAQ,iBAAiB;AACnE,QAAM,6BAA6B,UAAU,QAAQ,oBAAoB;AACzE,QAAM,qBAAqB,UAAU,QAAQ,YAAY;AACzD,QAAM,sBAAsB,UAAU,QAAQ,YAAY,KAAK;AAC/D,QAAM,qBAAqB,UAAU,QAAQ,cAAc,KAAK;AAEhE,QAAM,eAAe;AAAA,IACnB,YAAK,EAAE,kBAAkB,oBAAoB,CAAC;AAAA,IAC9C,GAAI,sBAAsB,sBAAsB,CAACC,aAAa,CAAC,IAAI,CAAC;AAAA,IACpE,GAAI,0BAA0B,CAACD,mBAAQ,CAAC,IAAI,CAAC;AAAA,IAC7C,GAAI,6BAA6B,CAACA,oBAAW,GAAGA,mBAAmB,CAAC,IAAI,CAAC;AAAA,IACzEA,mBAAe;AAAA,IACf,GAAI,mBAAmB,CAACC,aAAW,CAAC,IAAI,CAAC;AAAA,IACzC,GAAI,qBAAqB,CAACA,aAAa,GAAGD,oBAAU,CAAC,IAAI,CAAC;AAAA,IAC1DA,mBAAgB;AAAA,IAChBA,mBAAe;AAAA,IACfA,mBAAoB;AAAA,IACpBA,oBAAe;AAAA,IACfA,mBAAkB;AAAA,IAClB,kBAAiB;AAAA,IACjB,GAAI,eAAe,CAACC,aAAO,CAAC,IAAI,CAAC;AAAA,EACnC;AAEA,SAAO,CAACD,mBAAK,EAAE,aAAa,CAAC,GAAG,GAAG,YAAY;AACjD;AAEA,IAAO,gBAAQA;","names":["createIntegration","createIntegration","src_default","createIntegration","src_default","createIntegration","src_default","fileURLToPath","join","fileURLToPath","fileURLToPath","join","fileURLToPath","fileURLToPath","createIntegration","src_default","createIntegration","createIntegration","src_default"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/astro",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.27.0",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@wix/auth-management": "^1.0.71",
|
|
6
6
|
"@wix/dashboard": "^1.3.40",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"@wix/headless-node": "^1.28.0",
|
|
11
11
|
"@wix/headless-site": "^1.28.0",
|
|
12
12
|
"@wix/headless-site-assets": "^1.0.9",
|
|
13
|
+
"@wix/multilingual-manager": "^1.5.0",
|
|
13
14
|
"@wix/sdk": "^1.21.2",
|
|
14
15
|
"@wix/sdk-runtime": "^1.0.0",
|
|
15
16
|
"@wix/sdk-types": "^1.17.1",
|
|
@@ -32,6 +33,7 @@
|
|
|
32
33
|
"@wix/astro-translations": "0.0.0",
|
|
33
34
|
"@wix/astro-trusted-backoffice-extensions": "0.0.0",
|
|
34
35
|
"@wix/astro-viewer-api": "0.0.0",
|
|
36
|
+
"@wix/astro-viewer-services-extensions": "0.0.0",
|
|
35
37
|
"astro": "^5.16.6",
|
|
36
38
|
"is-ci": "^4.1.0",
|
|
37
39
|
"outdent": "^0.8.0",
|
|
@@ -74,5 +76,5 @@
|
|
|
74
76
|
]
|
|
75
77
|
}
|
|
76
78
|
},
|
|
77
|
-
"falconPackageHash": "
|
|
79
|
+
"falconPackageHash": "a1097f88303ea50f23c0bd32da56b14fe6efc25869201c5b40f4fa49"
|
|
78
80
|
}
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
defaultOutdent
|
|
3
|
-
} from "./chunk-YRKN4TFH.js";
|
|
4
|
-
|
|
5
|
-
// src/utils/loadTranslations.ts
|
|
6
|
-
import { readdir } from "fs/promises";
|
|
7
|
-
import { join as join2 } from "path";
|
|
8
|
-
import { fileURLToPath } from "url";
|
|
9
|
-
|
|
10
|
-
// ../fs-utils/src/index.ts
|
|
11
|
-
import { randomBytes } from "crypto";
|
|
12
|
-
import {
|
|
13
|
-
access,
|
|
14
|
-
readFile as fsReadFile,
|
|
15
|
-
writeFile as fsWriteFile,
|
|
16
|
-
mkdir,
|
|
17
|
-
rm
|
|
18
|
-
} from "fs/promises";
|
|
19
|
-
import { EOL, tmpdir } from "os";
|
|
20
|
-
import { dirname, join } from "path";
|
|
21
|
-
async function readJson(file) {
|
|
22
|
-
return JSON.parse(await fsReadFile(file, "utf-8"));
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// src/utils/loadTranslations.ts
|
|
26
|
-
import { toNamespaceDictionary } from "@wix/headless-localization-utils";
|
|
27
|
-
|
|
28
|
-
// src/constants.ts
|
|
29
|
-
var TRANSLATIONS_METADATA_FILENAME = "metadata.json";
|
|
30
|
-
var TRANSLATIONS_FILENAME = "translations.json";
|
|
31
|
-
|
|
32
|
-
// src/utils/errorMessages.ts
|
|
33
|
-
function createTranslationFilesError(translationsDir) {
|
|
34
|
-
return new Error(defaultOutdent`
|
|
35
|
-
Failed to load translation file(s).
|
|
36
|
-
💡 Tip: create a file '${translationsDir}/translations.json' in your project, then use the Wix CLI to push these keys.
|
|
37
|
-
|
|
38
|
-
Example translation file structure:
|
|
39
|
-
{
|
|
40
|
-
"hello": "Hello",
|
|
41
|
-
"goodbye": "Goodbye"
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
🔍 Need Help?
|
|
45
|
-
- Visit our docs: https://dev.wix.com/docs/go-headless
|
|
46
|
-
`);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// src/utils/loadTranslations.ts
|
|
50
|
-
async function loadTranslationFile(filePath) {
|
|
51
|
-
return readJson(filePath).then(
|
|
52
|
-
(data) => toNamespaceDictionary(data)
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
async function loadAllTranslations(astroConfig) {
|
|
56
|
-
const srcDir = fileURLToPath(astroConfig.srcDir);
|
|
57
|
-
const rootDir = fileURLToPath(astroConfig.root);
|
|
58
|
-
const tempDir = join2(rootDir, ".wix");
|
|
59
|
-
const multilingualDir = join2(tempDir, "multilingual");
|
|
60
|
-
const primaryTranslationPath = join2(srcDir, TRANSLATIONS_FILENAME);
|
|
61
|
-
const pulledTranslationsDir = join2(multilingualDir, "translations");
|
|
62
|
-
let metadata;
|
|
63
|
-
let primaryTranslation;
|
|
64
|
-
try {
|
|
65
|
-
metadata = await loadMetadata(multilingualDir);
|
|
66
|
-
primaryTranslation = await loadPrimaryTranslation(
|
|
67
|
-
primaryTranslationPath,
|
|
68
|
-
metadata
|
|
69
|
-
);
|
|
70
|
-
} catch {
|
|
71
|
-
throw createTranslationFilesError(srcDir);
|
|
72
|
-
}
|
|
73
|
-
const wixTranslations = await loadTranslations(pulledTranslationsDir);
|
|
74
|
-
return { ...wixTranslations, ...primaryTranslation };
|
|
75
|
-
}
|
|
76
|
-
async function loadMetadata(translationsMetadataDir) {
|
|
77
|
-
const metadataPath = join2(
|
|
78
|
-
translationsMetadataDir,
|
|
79
|
-
TRANSLATIONS_METADATA_FILENAME
|
|
80
|
-
);
|
|
81
|
-
return await readJson(metadataPath);
|
|
82
|
-
}
|
|
83
|
-
async function loadPrimaryTranslation(primaryTranslationPath, metadata) {
|
|
84
|
-
const translationContent = await loadTranslationFile(primaryTranslationPath);
|
|
85
|
-
return {
|
|
86
|
-
[metadata.primaryLanguageCode]: translationContent
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
async function loadTranslations(translationsDir) {
|
|
90
|
-
const files = await readdir(translationsDir);
|
|
91
|
-
const jsonFiles = files.filter((file) => file.endsWith(".json"));
|
|
92
|
-
const translations = {};
|
|
93
|
-
for (const file of jsonFiles) {
|
|
94
|
-
const languageCode = file.replace(".json", "");
|
|
95
|
-
const filePath = join2(translationsDir, file);
|
|
96
|
-
translations[languageCode] = await loadTranslationFile(filePath);
|
|
97
|
-
}
|
|
98
|
-
return translations;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// src/index.ts
|
|
102
|
-
var createIntegration = () => {
|
|
103
|
-
return {
|
|
104
|
-
name: "@wix/astro/static-translations",
|
|
105
|
-
hooks: {
|
|
106
|
-
"astro:config:setup": async ({
|
|
107
|
-
addMiddleware,
|
|
108
|
-
config: astroConfig,
|
|
109
|
-
updateConfig
|
|
110
|
-
}) => {
|
|
111
|
-
const translations = await loadAllTranslations(astroConfig);
|
|
112
|
-
updateConfig({
|
|
113
|
-
vite: {
|
|
114
|
-
define: {
|
|
115
|
-
__WIX_TRANSLATIONS__: JSON.stringify(translations)
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
addMiddleware({
|
|
120
|
-
entrypoint: new URL(
|
|
121
|
-
"../dependencies/astro-translations/middleware/static-translations.js",
|
|
122
|
-
import.meta.url
|
|
123
|
-
),
|
|
124
|
-
order: "pre"
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
};
|
|
130
|
-
var index_default = createIntegration;
|
|
131
|
-
export {
|
|
132
|
-
index_default as default
|
|
133
|
-
};
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
defaultOutdent
|
|
3
|
-
} from "../chunk-YRKN4TFH.js";
|
|
4
|
-
|
|
5
|
-
// src/middleware/static-translations.ts
|
|
6
|
-
import { i18n } from "@wix/essentials";
|
|
7
|
-
|
|
8
|
-
// ../request-transform-utils/src/transformStreamUtils.ts
|
|
9
|
-
function injectBeforeTransformStream(predicate, htmlToInject) {
|
|
10
|
-
let hasInjected = false;
|
|
11
|
-
return new TransformStream({
|
|
12
|
-
transform: (chunk, controller) => {
|
|
13
|
-
if (!hasInjected) {
|
|
14
|
-
const index = chunk.indexOf(predicate);
|
|
15
|
-
if (index > -1) {
|
|
16
|
-
chunk = chunk.slice(0, index) + htmlToInject + chunk.slice(index);
|
|
17
|
-
hasInjected = true;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
controller.enqueue(chunk);
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// ../request-transform-utils/src/index.ts
|
|
26
|
-
var headTransformStream = (htmlToInject) => injectBeforeTransformStream("</head>", htmlToInject);
|
|
27
|
-
|
|
28
|
-
// src/middleware/static-translations.ts
|
|
29
|
-
import { multilingual } from "@wix/site";
|
|
30
|
-
globalThis.__wix_translations__ = __WIX_TRANSLATIONS__;
|
|
31
|
-
var onRequest = async (context, next) => {
|
|
32
|
-
const response = await next();
|
|
33
|
-
const contentType = response.headers.get("Content-Type");
|
|
34
|
-
if (contentType !== "text/html" || context.url.pathname.startsWith("/_wix") || !response.body) {
|
|
35
|
-
return response;
|
|
36
|
-
}
|
|
37
|
-
const filteredTranslations = getFilteredTranslations();
|
|
38
|
-
const translationsScript = defaultOutdent`
|
|
39
|
-
<script>window.__wix_translations__ = ${JSON.stringify(filteredTranslations)};</script>
|
|
40
|
-
`;
|
|
41
|
-
return new Response(
|
|
42
|
-
response.body.pipeThrough(new TextDecoderStream()).pipeThrough(headTransformStream(translationsScript)).pipeThrough(new TextEncoderStream()),
|
|
43
|
-
response
|
|
44
|
-
);
|
|
45
|
-
};
|
|
46
|
-
function getFilteredTranslations() {
|
|
47
|
-
const allTranslations = globalThis.__wix_translations__ ?? {};
|
|
48
|
-
const pickLanguage = (lang) => lang != null && allTranslations[lang] ? { [lang]: allTranslations[lang] } : {};
|
|
49
|
-
const currentLanguage = i18n.getLanguage();
|
|
50
|
-
const primaryLanguage = multilingual.listSupportedLanguages().find((language) => language.primary)?.id;
|
|
51
|
-
return {
|
|
52
|
-
...pickLanguage(currentLanguage),
|
|
53
|
-
...pickLanguage(primaryLanguage)
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
export {
|
|
57
|
-
onRequest
|
|
58
|
-
};
|