@wix/astro 2.26.0 → 2.28.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-auth/backend-runtime/constants-Dbkf3D5f.mjs +6 -0
- package/build/dependencies/astro-auth/backend-runtime/elevatedContextualClient-tJx9dIn_.mjs +41 -0
- package/build/dependencies/astro-auth/backend-runtime/host-utils-B2Fs_Z4S.mjs +17 -0
- package/build/dependencies/astro-auth/backend-runtime/middleware/auth.d.mts +6 -0
- package/build/dependencies/astro-auth/backend-runtime/middleware/auth.mjs +3643 -0
- package/build/dependencies/astro-auth/backend-runtime/middleware/localization.d.mts +6 -0
- package/build/dependencies/astro-auth/backend-runtime/middleware/localization.mjs +193 -0
- package/build/dependencies/astro-auth/backend-runtime/routes/callback.d.mts +6 -0
- package/build/dependencies/astro-auth/backend-runtime/routes/callback.mjs +34 -0
- package/build/dependencies/astro-auth/backend-runtime/routes/login.d.mts +6 -0
- package/build/dependencies/astro-auth/backend-runtime/routes/login.mjs +32 -0
- package/build/dependencies/astro-auth/backend-runtime/routes/logout-callback.d.mts +6 -0
- package/build/dependencies/astro-auth/backend-runtime/routes/logout-callback.mjs +14 -0
- package/build/dependencies/astro-auth/backend-runtime/routes/logout.d.mts +6 -0
- package/build/dependencies/astro-auth/backend-runtime/routes/logout.mjs +19 -0
- package/build/dependencies/astro-auth/backend-runtime/runtime/backend/setupContextualClient.d.mts +1 -0
- package/build/dependencies/astro-auth/backend-runtime/runtime/backend/setupContextualClient.mjs +8 -0
- package/build/dependencies/astro-auth/backend-runtime/saveSessionTokensToCookie-DK3xvtzk.mjs +24 -0
- package/build/dependencies/astro-auth/backend-runtime/schemas-XrMhpOYn.mjs +2771 -0
- package/build/dependencies/astro-auth/browser-runtime/setup.d.ts +4 -3
- package/build/dependencies/astro-auth/browser-runtime/setup.js +55 -81
- package/build/dependencies/astro-backend-extensions/backend-runtime/routes/extensions.d.mts +6 -0
- package/build/dependencies/astro-backend-extensions/backend-runtime/routes/extensions.mjs +37 -0
- package/build/dependencies/astro-backend-extensions/backend-runtime/runtime/setupServicePlugin.d.mts +10 -0
- package/build/dependencies/astro-backend-extensions/backend-runtime/runtime/setupServicePlugin.mjs +22 -0
- package/build/dependencies/astro-backend-extensions/backend-runtime/runtime/setupWebhook.d.mts +9 -0
- package/build/dependencies/astro-backend-extensions/backend-runtime/runtime/setupWebhook.mjs +22 -0
- package/build/dependencies/astro-backend-extensions/backend-runtime/utils-DDHGZHjR.mjs +56 -0
- package/build/dependencies/astro-backend-extensions/backend-runtime/utils-mYlwmIjd.d.mts +6 -0
- package/build/dependencies/astro-backoffice-extensions/browser-runtime/wrapComponent.d.ts +4 -3
- package/build/dependencies/astro-backoffice-extensions/browser-runtime/wrapComponent.js +6 -5
- package/build/dependencies/astro-context-providers-extensions/browser-runtime/hmr.d.ts +10 -0
- package/build/dependencies/astro-context-providers-extensions/browser-runtime/hmr.js +20 -23
- package/build/dependencies/astro-context-providers-extensions/browser-runtime/sdk.d.ts +9 -0
- package/build/dependencies/astro-context-providers-extensions/browser-runtime/sdk.js +16 -15
- package/build/dependencies/astro-custom-elements-extensions/browser-runtime/customElementHmr.d.ts +9 -5
- package/build/dependencies/astro-custom-elements-extensions/browser-runtime/customElementHmr.js +23 -40
- package/build/dependencies/astro-custom-elements-extensions/browser-runtime/reactHmr.d.ts +10 -1
- package/build/dependencies/astro-custom-elements-extensions/browser-runtime/reactHmr.js +20 -23
- package/build/dependencies/astro-custom-elements-extensions/browser-runtime/renderSettingsPanel.d.ts +4 -3
- package/build/dependencies/astro-custom-elements-extensions/browser-runtime/renderSettingsPanel.js +14 -18
- package/build/dependencies/astro-custom-elements-extensions/browser-runtime/wrapCustomElement.d.ts +9 -5
- package/build/dependencies/astro-custom-elements-extensions/browser-runtime/wrapCustomElement.js +23 -25
- package/build/dependencies/astro-embedded-scripts-extensions/browser-runtime/setupContext.d.ts +8 -4
- package/build/dependencies/astro-embedded-scripts-extensions/browser-runtime/setupContext.js +18 -17
- package/build/dependencies/astro-function-libraries-extensions/browser-runtime/sdk.d.ts +9 -0
- package/build/dependencies/astro-function-libraries-extensions/browser-runtime/sdk.js +16 -15
- package/build/dependencies/astro-html-embeds/backend-runtime/html-embeds.d.mts +6 -0
- package/build/dependencies/astro-html-embeds/backend-runtime/html-embeds.mjs +53 -0
- package/build/dependencies/astro-monitor/backend-runtime/monitor.d.mts +6 -0
- package/build/dependencies/astro-monitor/backend-runtime/monitor.mjs +43 -0
- package/build/dependencies/astro-payment-links/backend-runtime/elevate-CDDLuCIf.mjs +9 -0
- package/build/dependencies/astro-payment-links/backend-runtime/payment-checkout.d.mts +6 -0
- package/build/dependencies/astro-payment-links/backend-runtime/payment-checkout.mjs +20 -0
- package/build/dependencies/astro-payment-links/backend-runtime/payment-link.d.mts +6 -0
- package/build/dependencies/astro-payment-links/backend-runtime/payment-link.mjs +15 -0
- package/build/dependencies/astro-payment-links/backend-runtime/proposal.d.mts +6 -0
- package/build/dependencies/astro-payment-links/backend-runtime/proposal.mjs +20 -0
- package/build/dependencies/astro-robots/backend-runtime/robots.d.mts +6 -0
- package/build/dependencies/astro-robots/backend-runtime/robots.mjs +26 -0
- package/build/dependencies/astro-site-component-panels-extensions/browser-runtime/hmr.d.ts +10 -0
- package/build/dependencies/astro-site-component-panels-extensions/browser-runtime/hmr.js +20 -23
- package/build/dependencies/astro-site-component-panels-extensions/browser-runtime/sdk.d.ts +12 -0
- package/build/dependencies/astro-site-component-panels-extensions/browser-runtime/sdk.js +10 -10
- package/build/dependencies/astro-site-components-extensions/browser-runtime/hmr.d.ts +10 -0
- package/build/dependencies/astro-site-components-extensions/browser-runtime/hmr.js +20 -23
- package/build/dependencies/astro-site-components-extensions/browser-runtime/sdk.d.ts +9 -0
- package/build/dependencies/astro-site-components-extensions/browser-runtime/sdk.js +16 -15
- package/build/dependencies/astro-translations/backend-runtime/middleware/static-translations.d.mts +6 -0
- package/build/dependencies/astro-translations/backend-runtime/middleware/static-translations.mjs +177 -0
- package/build/dependencies/astro-translations/backend-runtime/runtime/{i18n.d.ts → i18n.d.mts} +3 -2
- package/build/dependencies/astro-translations/backend-runtime/runtime/i18n.mjs +38 -0
- package/build/dependencies/astro-translations/integration/index.d.mts +105 -0
- package/build/dependencies/astro-translations/integration/index.mjs +264 -0
- package/build/dependencies/astro-trusted-backoffice-extensions/browser-runtime/hmr.d.ts +10 -1
- package/build/dependencies/astro-trusted-backoffice-extensions/browser-runtime/hmr.js +20 -23
- package/build/dependencies/astro-trusted-backoffice-extensions/browser-runtime/wrapComponent.d.ts +12 -8
- package/build/dependencies/astro-trusted-backoffice-extensions/browser-runtime/wrapComponent.js +25 -35
- package/build/dependencies/astro-viewer-api/backend-runtime/api.d.mts +6 -0
- package/build/dependencies/astro-viewer-api/backend-runtime/api.mjs +27 -0
- package/build/dependencies/astro-viewer-services-extensions/browser-runtime/sdk.d.ts +9 -0
- package/build/dependencies/astro-viewer-services-extensions/browser-runtime/sdk.js +16 -15
- package/build/integration/builders-B9yQdgSz.mjs +76 -0
- package/build/integration/builders-DP0350YQ.d.mts +121 -0
- package/build/integration/builders-DVfxT6EC.mjs +225 -0
- package/build/integration/builders-experimental.d.mts +56 -0
- package/build/integration/builders-experimental.mjs +26 -0
- package/build/integration/builders-trusted.d.mts +75 -0
- package/build/integration/builders-trusted.mjs +46 -0
- package/build/integration/builders.d.mts +4 -0
- package/build/integration/builders.mjs +4 -0
- package/build/integration/index-B3B_5bgh.d.mts +248 -0
- package/build/integration/index-D5k6Bmue.d.mts +32 -0
- package/build/integration/index.d.mts +35 -0
- package/build/integration/index.mjs +29236 -0
- package/package.json +12 -12
- package/build/dependencies/astro-auth/backend-runtime/chunk-24J7STEA.js +0 -8
- package/build/dependencies/astro-auth/backend-runtime/chunk-352W54SQ.js +0 -70
- package/build/dependencies/astro-auth/backend-runtime/chunk-BIARYLOZ.js +0 -3267
- package/build/dependencies/astro-auth/backend-runtime/chunk-DZHZMKUF.js +0 -26
- package/build/dependencies/astro-auth/backend-runtime/chunk-MLKGABMK.js +0 -9
- package/build/dependencies/astro-auth/backend-runtime/chunk-USQSPPTM.js +0 -14
- package/build/dependencies/astro-auth/backend-runtime/middleware/auth.d.ts +0 -5
- package/build/dependencies/astro-auth/backend-runtime/middleware/auth.js +0 -136
- package/build/dependencies/astro-auth/backend-runtime/middleware/localization.d.ts +0 -5
- package/build/dependencies/astro-auth/backend-runtime/middleware/localization.js +0 -219
- package/build/dependencies/astro-auth/backend-runtime/routes/callback.d.ts +0 -5
- package/build/dependencies/astro-auth/backend-runtime/routes/callback.js +0 -53
- package/build/dependencies/astro-auth/backend-runtime/routes/login.d.ts +0 -5
- package/build/dependencies/astro-auth/backend-runtime/routes/login.js +0 -46
- package/build/dependencies/astro-auth/backend-runtime/routes/logout-callback.d.ts +0 -5
- package/build/dependencies/astro-auth/backend-runtime/routes/logout-callback.js +0 -24
- package/build/dependencies/astro-auth/backend-runtime/routes/logout.d.ts +0 -5
- package/build/dependencies/astro-auth/backend-runtime/routes/logout.js +0 -33
- package/build/dependencies/astro-auth/backend-runtime/runtime/backend/setupContextualClient.d.ts +0 -2
- package/build/dependencies/astro-auth/backend-runtime/runtime/backend/setupContextualClient.js +0 -10
- package/build/dependencies/astro-backend-extensions/backend-runtime/chunk-CPGTXQVH.js +0 -75
- package/build/dependencies/astro-backend-extensions/backend-runtime/routes/extensions.d.ts +0 -5
- package/build/dependencies/astro-backend-extensions/backend-runtime/routes/extensions.js +0 -41
- package/build/dependencies/astro-backend-extensions/backend-runtime/runtime/setupServicePlugin.d.ts +0 -10
- package/build/dependencies/astro-backend-extensions/backend-runtime/runtime/setupServicePlugin.js +0 -35
- package/build/dependencies/astro-backend-extensions/backend-runtime/runtime/setupWebhook.d.ts +0 -9
- package/build/dependencies/astro-backend-extensions/backend-runtime/runtime/setupWebhook.js +0 -34
- package/build/dependencies/astro-backend-extensions/backend-runtime/utils-B7jr2PES.d.ts +0 -5
- package/build/dependencies/astro-backend-extensions/types/index.d.ts +0 -102
- package/build/dependencies/astro-backoffice-extensions/types/index.d.ts +0 -68
- package/build/dependencies/astro-context-providers-extensions/types/index.d.ts +0 -32
- package/build/dependencies/astro-core/types/index.d.ts +0 -109
- package/build/dependencies/astro-custom-elements-extensions/types/index.d.ts +0 -45
- package/build/dependencies/astro-embedded-scripts-extensions/types/index.d.ts +0 -18
- package/build/dependencies/astro-function-libraries-extensions/types/index.d.ts +0 -23
- package/build/dependencies/astro-html-embeds/backend-runtime/html-embeds.d.ts +0 -5
- package/build/dependencies/astro-html-embeds/backend-runtime/html-embeds.js +0 -66
- package/build/dependencies/astro-payment-links/backend-runtime/chunk-656BVIJ3.js +0 -9
- package/build/dependencies/astro-payment-links/backend-runtime/payment-checkout.d.ts +0 -5
- package/build/dependencies/astro-payment-links/backend-runtime/payment-checkout.js +0 -24
- package/build/dependencies/astro-payment-links/backend-runtime/payment-link.d.ts +0 -5
- package/build/dependencies/astro-payment-links/backend-runtime/payment-link.js +0 -20
- package/build/dependencies/astro-payment-links/backend-runtime/proposal.d.ts +0 -5
- package/build/dependencies/astro-payment-links/backend-runtime/proposal.js +0 -24
- package/build/dependencies/astro-robots/backend-runtime/robots.d.ts +0 -5
- package/build/dependencies/astro-robots/backend-runtime/robots.js +0 -38
- package/build/dependencies/astro-site-component-panels-extensions/types/index.d.ts +0 -21
- package/build/dependencies/astro-site-components-extensions/types/index.d.ts +0 -48
- package/build/dependencies/astro-translations/backend-runtime/middleware/static-translations.d.ts +0 -5
- package/build/dependencies/astro-translations/backend-runtime/middleware/static-translations.js +0 -168
- package/build/dependencies/astro-translations/backend-runtime/runtime/i18n.js +0 -42
- package/build/dependencies/astro-translations/integration/index.d.ts +0 -5
- package/build/dependencies/astro-translations/integration/index.js +0 -296
- package/build/dependencies/astro-trusted-backoffice-extensions/types/index.d.ts +0 -50
- package/build/dependencies/astro-viewer-api/backend-runtime/api.d.ts +0 -5
- package/build/dependencies/astro-viewer-api/backend-runtime/api.js +0 -34
- package/build/dependencies/astro-viewer-services-extensions/types/index.d.ts +0 -27
- package/build/integration/builders-experimental.d.ts +0 -53
- package/build/integration/builders-experimental.js +0 -20
- package/build/integration/builders-experimental.js.map +0 -1
- package/build/integration/builders-trusted.d.ts +0 -69
- package/build/integration/builders-trusted.js +0 -52
- package/build/integration/builders-trusted.js.map +0 -1
- package/build/integration/builders.d.ts +0 -112
- package/build/integration/builders.js +0 -14
- package/build/integration/builders.js.map +0 -1
- package/build/integration/chunk-23MOLCVI.js +0 -1087
- package/build/integration/chunk-23MOLCVI.js.map +0 -1
- package/build/integration/chunk-CBVCNKLN.js +0 -7458
- package/build/integration/chunk-CBVCNKLN.js.map +0 -1
- package/build/integration/chunk-E42TF2A2.js +0 -23747
- package/build/integration/chunk-E42TF2A2.js.map +0 -1
- package/build/integration/chunk-KCOYXYJL.js +0 -386
- package/build/integration/chunk-KCOYXYJL.js.map +0 -1
- package/build/integration/chunk-MNQWQ2MC.js +0 -809
- package/build/integration/chunk-MNQWQ2MC.js.map +0 -1
- package/build/integration/index.d-BUVlSCHa.d.ts +0 -211
- package/build/integration/index.d-D4c48TR0.d.ts +0 -58
- package/build/integration/index.d.ts +0 -34
- package/build/integration/index.js +0 -498
- package/build/integration/index.js.map +0 -1
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
// ../astro-browser-runtime/src/sdk/site.ts
|
|
2
1
|
import { createClient } from "@wix/sdk";
|
|
3
2
|
import { site } from "@wix/site";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
3
|
+
|
|
4
|
+
//#region ../astro-browser-runtime/src/sdk/site.ts
|
|
5
|
+
const enableClient = (applicationId) => {
|
|
6
|
+
const host = site.host({ applicationId });
|
|
7
|
+
const auth = site.auth();
|
|
8
|
+
createClient({
|
|
9
|
+
auth,
|
|
10
|
+
host
|
|
11
|
+
}).enableContext("module");
|
|
12
|
+
return auth.getAccessTokenInjector();
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/runtime/sdk.ts
|
|
16
17
|
function createContext() {
|
|
17
|
-
|
|
18
|
+
return enableClient(import.meta.env.WIX_CLIENT_ID);
|
|
18
19
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
};
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
export { createContext };
|
package/build/dependencies/astro-translations/backend-runtime/middleware/static-translations.mjs
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { i18n } from "@wix/essentials";
|
|
2
|
+
import { multilingual } from "@wix/site";
|
|
3
|
+
|
|
4
|
+
//#region rolldown:runtime
|
|
5
|
+
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
6
|
+
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region ../request-transform-utils/src/transformStreamUtils.ts
|
|
9
|
+
function injectBeforeTransformStream(predicate, htmlToInject) {
|
|
10
|
+
let hasInjected = false;
|
|
11
|
+
return new TransformStream({ transform: (chunk, controller) => {
|
|
12
|
+
if (!hasInjected) {
|
|
13
|
+
const index = chunk.indexOf(predicate);
|
|
14
|
+
if (index > -1) {
|
|
15
|
+
chunk = chunk.slice(0, index) + htmlToInject + chunk.slice(index);
|
|
16
|
+
hasInjected = true;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
controller.enqueue(chunk);
|
|
20
|
+
} });
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region ../request-transform-utils/src/index.ts
|
|
25
|
+
const headTransformStream = (htmlToInject) => injectBeforeTransformStream("</head>", htmlToInject);
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region ../../node_modules/outdent/lib/index.js
|
|
29
|
+
var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
30
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
+
exports.outdent = void 0;
|
|
32
|
+
function noop() {
|
|
33
|
+
var args = [];
|
|
34
|
+
for (var _i = 0; _i < arguments.length; _i++) args[_i] = arguments[_i];
|
|
35
|
+
}
|
|
36
|
+
function createWeakMap() {
|
|
37
|
+
if (typeof WeakMap !== "undefined") return /* @__PURE__ */ new WeakMap();
|
|
38
|
+
else return fakeSetOrMap();
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Creates and returns a no-op implementation of a WeakMap / WeakSet that never stores anything.
|
|
42
|
+
*/
|
|
43
|
+
function fakeSetOrMap() {
|
|
44
|
+
return {
|
|
45
|
+
add: noop,
|
|
46
|
+
delete: noop,
|
|
47
|
+
get: noop,
|
|
48
|
+
set: noop,
|
|
49
|
+
has: function(k) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
var hop = Object.prototype.hasOwnProperty;
|
|
55
|
+
var has = function(obj, prop) {
|
|
56
|
+
return hop.call(obj, prop);
|
|
57
|
+
};
|
|
58
|
+
function extend(target, source) {
|
|
59
|
+
for (var prop in source) if (has(source, prop)) target[prop] = source[prop];
|
|
60
|
+
return target;
|
|
61
|
+
}
|
|
62
|
+
var reLeadingNewline = /^[ \t]*(?:\r\n|\r|\n)/;
|
|
63
|
+
var reTrailingNewline = /(?:\r\n|\r|\n)[ \t]*$/;
|
|
64
|
+
var reStartsWithNewlineOrIsEmpty = /^(?:[\r\n]|$)/;
|
|
65
|
+
var reDetectIndentation = /(?:\r\n|\r|\n)([ \t]*)(?:[^ \t\r\n]|$)/;
|
|
66
|
+
var reOnlyWhitespaceWithAtLeastOneNewline = /^[ \t]*[\r\n][ \t\r\n]*$/;
|
|
67
|
+
function _outdentArray(strings, firstInterpolatedValueSetsIndentationLevel, options) {
|
|
68
|
+
var indentationLevel = 0;
|
|
69
|
+
var match = strings[0].match(reDetectIndentation);
|
|
70
|
+
if (match) indentationLevel = match[1].length;
|
|
71
|
+
var reSource = "(\\r\\n|\\r|\\n).{0," + indentationLevel + "}";
|
|
72
|
+
var reMatchIndent = new RegExp(reSource, "g");
|
|
73
|
+
if (firstInterpolatedValueSetsIndentationLevel) strings = strings.slice(1);
|
|
74
|
+
var newline = options.newline, trimLeadingNewline = options.trimLeadingNewline, trimTrailingNewline = options.trimTrailingNewline;
|
|
75
|
+
var normalizeNewlines = typeof newline === "string";
|
|
76
|
+
var l = strings.length;
|
|
77
|
+
return strings.map(function(v, i) {
|
|
78
|
+
v = v.replace(reMatchIndent, "$1");
|
|
79
|
+
if (i === 0 && trimLeadingNewline) v = v.replace(reLeadingNewline, "");
|
|
80
|
+
if (i === l - 1 && trimTrailingNewline) v = v.replace(reTrailingNewline, "");
|
|
81
|
+
if (normalizeNewlines) v = v.replace(/\r\n|\n|\r/g, function(_) {
|
|
82
|
+
return newline;
|
|
83
|
+
});
|
|
84
|
+
return v;
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
function concatStringsAndValues(strings, values) {
|
|
88
|
+
var ret = "";
|
|
89
|
+
for (var i = 0, l = strings.length; i < l; i++) {
|
|
90
|
+
ret += strings[i];
|
|
91
|
+
if (i < l - 1) ret += values[i];
|
|
92
|
+
}
|
|
93
|
+
return ret;
|
|
94
|
+
}
|
|
95
|
+
function isTemplateStringsArray(v) {
|
|
96
|
+
return has(v, "raw") && has(v, "length");
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* It is assumed that opts will not change. If this is a problem, clone your options object and pass the clone to
|
|
100
|
+
* makeInstance
|
|
101
|
+
* @param options
|
|
102
|
+
* @return {outdent}
|
|
103
|
+
*/
|
|
104
|
+
function createInstance(options) {
|
|
105
|
+
/** Cache of pre-processed template literal arrays */
|
|
106
|
+
var arrayAutoIndentCache = createWeakMap();
|
|
107
|
+
/**
|
|
108
|
+
* Cache of pre-processed template literal arrays, where first interpolated value is a reference to outdent,
|
|
109
|
+
* before interpolated values are injected.
|
|
110
|
+
*/
|
|
111
|
+
var arrayFirstInterpSetsIndentCache = createWeakMap();
|
|
112
|
+
function outdent(stringsOrOptions) {
|
|
113
|
+
var values = [];
|
|
114
|
+
for (var _i = 1; _i < arguments.length; _i++) values[_i - 1] = arguments[_i];
|
|
115
|
+
if (isTemplateStringsArray(stringsOrOptions)) {
|
|
116
|
+
var strings = stringsOrOptions;
|
|
117
|
+
var firstInterpolatedValueSetsIndentationLevel = (values[0] === outdent || values[0] === defaultOutdent) && reOnlyWhitespaceWithAtLeastOneNewline.test(strings[0]) && reStartsWithNewlineOrIsEmpty.test(strings[1]);
|
|
118
|
+
var cache = firstInterpolatedValueSetsIndentationLevel ? arrayFirstInterpSetsIndentCache : arrayAutoIndentCache;
|
|
119
|
+
var renderedArray = cache.get(strings);
|
|
120
|
+
if (!renderedArray) {
|
|
121
|
+
renderedArray = _outdentArray(strings, firstInterpolatedValueSetsIndentationLevel, options);
|
|
122
|
+
cache.set(strings, renderedArray);
|
|
123
|
+
}
|
|
124
|
+
/** If no interpolated values, skip concatenation step */
|
|
125
|
+
if (values.length === 0) return renderedArray[0];
|
|
126
|
+
return concatStringsAndValues(renderedArray, firstInterpolatedValueSetsIndentationLevel ? values.slice(1) : values);
|
|
127
|
+
} else return createInstance(extend(extend({}, options), stringsOrOptions || {}));
|
|
128
|
+
}
|
|
129
|
+
return extend(outdent, { string: function(str) {
|
|
130
|
+
return _outdentArray([str], false, options)[0];
|
|
131
|
+
} });
|
|
132
|
+
}
|
|
133
|
+
var defaultOutdent = createInstance({
|
|
134
|
+
trimLeadingNewline: true,
|
|
135
|
+
trimTrailingNewline: true
|
|
136
|
+
});
|
|
137
|
+
exports.outdent = defaultOutdent;
|
|
138
|
+
exports.default = defaultOutdent;
|
|
139
|
+
if (typeof module !== "undefined") try {
|
|
140
|
+
module.exports = defaultOutdent;
|
|
141
|
+
Object.defineProperty(defaultOutdent, "__esModule", { value: true });
|
|
142
|
+
defaultOutdent.default = defaultOutdent;
|
|
143
|
+
defaultOutdent.outdent = defaultOutdent;
|
|
144
|
+
} catch (e) {}
|
|
145
|
+
}));
|
|
146
|
+
|
|
147
|
+
//#endregion
|
|
148
|
+
//#region \0@oxc-project+runtime@0.110.0/helpers/taggedTemplateLiteral.js
|
|
149
|
+
var import_lib = require_lib();
|
|
150
|
+
function _taggedTemplateLiteral(e, t) {
|
|
151
|
+
return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } }));
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
//#endregion
|
|
155
|
+
//#region src/middleware/static-translations.ts
|
|
156
|
+
var _templateObject;
|
|
157
|
+
globalThis.__wix_translations__ = __WIX_ASTRO_I18N__.translations;
|
|
158
|
+
const onRequest = async (context, next) => {
|
|
159
|
+
const response = await next();
|
|
160
|
+
if (response.headers.get("Content-Type") !== "text/html" || context.url.pathname.startsWith("/_wix") || !response.body) return response;
|
|
161
|
+
const filteredTranslations = getFilteredTranslations();
|
|
162
|
+
const translationsScript = (0, import_lib.outdent)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n <script>window.__wix_translations__ = ", ";<\/script>\n "])), JSON.stringify(filteredTranslations));
|
|
163
|
+
return new Response(response.body.pipeThrough(new TextDecoderStream()).pipeThrough(headTransformStream(translationsScript)).pipeThrough(new TextEncoderStream()), response);
|
|
164
|
+
};
|
|
165
|
+
function getFilteredTranslations() {
|
|
166
|
+
const allTranslations = globalThis.__wix_translations__ ?? {};
|
|
167
|
+
const pickLanguage = (lang) => lang != null && allTranslations[lang] ? { [lang]: allTranslations[lang] } : {};
|
|
168
|
+
const currentLanguage = i18n.getLanguage();
|
|
169
|
+
const primaryLanguage = multilingual.listSupportedLanguages().find((language) => language.primary)?.id;
|
|
170
|
+
return {
|
|
171
|
+
...pickLanguage(currentLanguage),
|
|
172
|
+
...pickLanguage(primaryLanguage)
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
//#endregion
|
|
177
|
+
export { onRequest };
|
package/build/dependencies/astro-translations/backend-runtime/runtime/{i18n.d.ts → i18n.d.mts}
RENAMED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
//#region src/runtime/i18n.d.ts
|
|
1
2
|
declare function getAbsoluteLocaleUrl(path?: string): string;
|
|
2
3
|
declare function getRelativeLocaleUrl(path?: string): string;
|
|
3
|
-
|
|
4
|
-
export { getAbsoluteLocaleUrl, getRelativeLocaleUrl };
|
|
4
|
+
//#endregion
|
|
5
|
+
export { getAbsoluteLocaleUrl, getRelativeLocaleUrl };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { i18n } from "@wix/essentials";
|
|
2
|
+
import { applyLanguageToUrl } from "@wix/headless-localization-utils";
|
|
3
|
+
import { listSupportedLanguages } from "@wix/multilingual-manager";
|
|
4
|
+
|
|
5
|
+
//#region src/runtime/i18n.ts
|
|
6
|
+
const PLACEHOLDER_BASE = "http://localhost";
|
|
7
|
+
const { base: configBase = "/", siteUrl } = __WIX_ASTRO_I18N__;
|
|
8
|
+
function getAbsoluteLocaleUrl(path) {
|
|
9
|
+
const localizedUrl = buildLocalizedUrl(siteUrl ?? PLACEHOLDER_BASE, path);
|
|
10
|
+
if (siteUrl == null) {
|
|
11
|
+
const url = new URL(localizedUrl);
|
|
12
|
+
return url.pathname + url.search + url.hash;
|
|
13
|
+
}
|
|
14
|
+
return localizedUrl;
|
|
15
|
+
}
|
|
16
|
+
function getRelativeLocaleUrl(path) {
|
|
17
|
+
const localizedUrl = new URL(buildLocalizedUrl(PLACEHOLDER_BASE, path));
|
|
18
|
+
return localizedUrl.pathname + localizedUrl.search + localizedUrl.hash;
|
|
19
|
+
}
|
|
20
|
+
function buildLocalizedUrl(baseUrl, path) {
|
|
21
|
+
const basePath = configBase === "/" ? "" : configBase.replace(/\/$/, "");
|
|
22
|
+
const pathSegment = path?.startsWith("/") ? path : `/${path ?? ""}`;
|
|
23
|
+
const url = new URL(basePath + pathSegment || "/", baseUrl);
|
|
24
|
+
const languageConfig = getCurrentLanguageConfig();
|
|
25
|
+
return languageConfig ? applyLanguageToUrl(url.href, languageConfig) : url.href;
|
|
26
|
+
}
|
|
27
|
+
function getCurrentLanguageConfig() {
|
|
28
|
+
const currentLanguage = i18n.getLanguage();
|
|
29
|
+
const language = listSupportedLanguages().find((lang) => lang.id === currentLanguage);
|
|
30
|
+
if (language == null || language.primary) return;
|
|
31
|
+
return {
|
|
32
|
+
languageCode: language.id,
|
|
33
|
+
resolutionMethod: language.resolutionMethod
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
//#endregion
|
|
38
|
+
export { getAbsoluteLocaleUrl, getRelativeLocaleUrl };
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { InlineConfig, ViteDevServer } from "vite";
|
|
2
|
+
import EventEmitter from "node:events";
|
|
3
|
+
import { AstroIntegration } from "astro";
|
|
4
|
+
|
|
5
|
+
//#region ../dev-center-schemas/src/components/base.d.ts
|
|
6
|
+
interface BaseDevCenterComponent {
|
|
7
|
+
compId: string;
|
|
8
|
+
compName?: string;
|
|
9
|
+
compType: string;
|
|
10
|
+
compData: unknown;
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region ../dev-center-schemas/src/app-manifest.d.ts
|
|
14
|
+
interface DevCenterAppManifest {
|
|
15
|
+
appId: string;
|
|
16
|
+
components: BaseDevCenterComponent[];
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region ../astro-core/src/utils/createModel.d.ts
|
|
20
|
+
interface EventMap {
|
|
21
|
+
change: [];
|
|
22
|
+
}
|
|
23
|
+
declare class Model extends EventEmitter<EventMap> {
|
|
24
|
+
appId: string;
|
|
25
|
+
env: Record<string, string>;
|
|
26
|
+
extensions: BaseExtension[];
|
|
27
|
+
rootDir: string;
|
|
28
|
+
srcDir: string;
|
|
29
|
+
private server;
|
|
30
|
+
constructor({
|
|
31
|
+
appId,
|
|
32
|
+
env,
|
|
33
|
+
extensions,
|
|
34
|
+
rootDir,
|
|
35
|
+
server,
|
|
36
|
+
srcDir
|
|
37
|
+
}: {
|
|
38
|
+
appId: string;
|
|
39
|
+
env: Record<string, string>;
|
|
40
|
+
extensions: BaseExtension[];
|
|
41
|
+
rootDir: string;
|
|
42
|
+
server: ViteDevServer;
|
|
43
|
+
srcDir: string;
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region ../astro-core/src/types.d.ts
|
|
48
|
+
interface BaseExtension {
|
|
49
|
+
type: string;
|
|
50
|
+
}
|
|
51
|
+
type CreateExtensionViteConfig = (opts: {
|
|
52
|
+
name: string;
|
|
53
|
+
config: InlineConfig;
|
|
54
|
+
}) => InlineConfig;
|
|
55
|
+
interface IntegrationHooks {
|
|
56
|
+
/**
|
|
57
|
+
* Called before the app manifest is created.
|
|
58
|
+
*
|
|
59
|
+
* Let's integrations contribute or change the app manifest.
|
|
60
|
+
*/
|
|
61
|
+
"wix:app-manifest:setup": (options: {
|
|
62
|
+
model: Model;
|
|
63
|
+
serverUrlPlaceholder: string;
|
|
64
|
+
staticsUrlPlaceholder: string;
|
|
65
|
+
updateAppManifest: (newAppManifest: Partial<DevCenterAppManifest>) => void;
|
|
66
|
+
updateAppManifestComponent: (compId: string, updater: (current: BaseDevCenterComponent) => BaseDevCenterComponent | Promise<BaseDevCenterComponent>) => Promise<void>;
|
|
67
|
+
}) => Promise<void> | void;
|
|
68
|
+
/**
|
|
69
|
+
* Called after the wix model has been set up initially.
|
|
70
|
+
*/
|
|
71
|
+
"wix:model:setup": (options: {
|
|
72
|
+
model: Model;
|
|
73
|
+
}) => Promise<void> | void;
|
|
74
|
+
/**
|
|
75
|
+
* Called during `astro dev`, after a change has been made to files that affect the
|
|
76
|
+
* wix model.
|
|
77
|
+
*/
|
|
78
|
+
"wix:model:changed": (options: {
|
|
79
|
+
model: Model;
|
|
80
|
+
}) => Promise<void> | void;
|
|
81
|
+
/**
|
|
82
|
+
* Called after main astro dev server has been started.
|
|
83
|
+
*/
|
|
84
|
+
"wix:server:start": (options: {
|
|
85
|
+
createExtensionViteConfig: CreateExtensionViteConfig;
|
|
86
|
+
setupExtensionProxy: (server: ViteDevServer) => void;
|
|
87
|
+
}) => Promise<void> | void;
|
|
88
|
+
/**
|
|
89
|
+
* Wrapper around `astro:build:setup`, called during `astro build`.
|
|
90
|
+
*/
|
|
91
|
+
"wix:build:setup": (options: {
|
|
92
|
+
createExtensionViteConfig: CreateExtensionViteConfig;
|
|
93
|
+
target: "client" | "server";
|
|
94
|
+
updateConfig: (newConfig: InlineConfig) => void;
|
|
95
|
+
vite: InlineConfig;
|
|
96
|
+
}) => Promise<void> | void;
|
|
97
|
+
}
|
|
98
|
+
type WixIntegration = AstroIntegration & {
|
|
99
|
+
hooks: { [K in keyof IntegrationHooks]?: IntegrationHooks[K] };
|
|
100
|
+
};
|
|
101
|
+
//#endregion
|
|
102
|
+
//#region src/index.d.ts
|
|
103
|
+
declare const createIntegration: () => WixIntegration;
|
|
104
|
+
//#endregion
|
|
105
|
+
export { createIntegration as default };
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
import { readFile, readdir } from "node:fs/promises";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { toNamespaceDictionary } from "@wix/headless-localization-utils";
|
|
6
|
+
|
|
7
|
+
//#region rolldown:runtime
|
|
8
|
+
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region ../fs-utils/src/index.ts
|
|
12
|
+
async function readJson(file) {
|
|
13
|
+
return JSON.parse(await readFile(file, "utf-8"));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/constants.ts
|
|
18
|
+
const TRANSLATIONS_METADATA_FILENAME = "metadata.json";
|
|
19
|
+
const TRANSLATIONS_FILENAME = "translations.json";
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region ../../node_modules/outdent/lib/index.js
|
|
23
|
+
var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.outdent = void 0;
|
|
26
|
+
function noop() {
|
|
27
|
+
var args = [];
|
|
28
|
+
for (var _i = 0; _i < arguments.length; _i++) args[_i] = arguments[_i];
|
|
29
|
+
}
|
|
30
|
+
function createWeakMap() {
|
|
31
|
+
if (typeof WeakMap !== "undefined") return /* @__PURE__ */ new WeakMap();
|
|
32
|
+
else return fakeSetOrMap();
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Creates and returns a no-op implementation of a WeakMap / WeakSet that never stores anything.
|
|
36
|
+
*/
|
|
37
|
+
function fakeSetOrMap() {
|
|
38
|
+
return {
|
|
39
|
+
add: noop,
|
|
40
|
+
delete: noop,
|
|
41
|
+
get: noop,
|
|
42
|
+
set: noop,
|
|
43
|
+
has: function(k) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
var hop = Object.prototype.hasOwnProperty;
|
|
49
|
+
var has = function(obj, prop) {
|
|
50
|
+
return hop.call(obj, prop);
|
|
51
|
+
};
|
|
52
|
+
function extend(target, source) {
|
|
53
|
+
for (var prop in source) if (has(source, prop)) target[prop] = source[prop];
|
|
54
|
+
return target;
|
|
55
|
+
}
|
|
56
|
+
var reLeadingNewline = /^[ \t]*(?:\r\n|\r|\n)/;
|
|
57
|
+
var reTrailingNewline = /(?:\r\n|\r|\n)[ \t]*$/;
|
|
58
|
+
var reStartsWithNewlineOrIsEmpty = /^(?:[\r\n]|$)/;
|
|
59
|
+
var reDetectIndentation = /(?:\r\n|\r|\n)([ \t]*)(?:[^ \t\r\n]|$)/;
|
|
60
|
+
var reOnlyWhitespaceWithAtLeastOneNewline = /^[ \t]*[\r\n][ \t\r\n]*$/;
|
|
61
|
+
function _outdentArray(strings, firstInterpolatedValueSetsIndentationLevel, options) {
|
|
62
|
+
var indentationLevel = 0;
|
|
63
|
+
var match = strings[0].match(reDetectIndentation);
|
|
64
|
+
if (match) indentationLevel = match[1].length;
|
|
65
|
+
var reSource = "(\\r\\n|\\r|\\n).{0," + indentationLevel + "}";
|
|
66
|
+
var reMatchIndent = new RegExp(reSource, "g");
|
|
67
|
+
if (firstInterpolatedValueSetsIndentationLevel) strings = strings.slice(1);
|
|
68
|
+
var newline = options.newline, trimLeadingNewline = options.trimLeadingNewline, trimTrailingNewline = options.trimTrailingNewline;
|
|
69
|
+
var normalizeNewlines = typeof newline === "string";
|
|
70
|
+
var l = strings.length;
|
|
71
|
+
return strings.map(function(v, i) {
|
|
72
|
+
v = v.replace(reMatchIndent, "$1");
|
|
73
|
+
if (i === 0 && trimLeadingNewline) v = v.replace(reLeadingNewline, "");
|
|
74
|
+
if (i === l - 1 && trimTrailingNewline) v = v.replace(reTrailingNewline, "");
|
|
75
|
+
if (normalizeNewlines) v = v.replace(/\r\n|\n|\r/g, function(_) {
|
|
76
|
+
return newline;
|
|
77
|
+
});
|
|
78
|
+
return v;
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
function concatStringsAndValues(strings, values) {
|
|
82
|
+
var ret = "";
|
|
83
|
+
for (var i = 0, l = strings.length; i < l; i++) {
|
|
84
|
+
ret += strings[i];
|
|
85
|
+
if (i < l - 1) ret += values[i];
|
|
86
|
+
}
|
|
87
|
+
return ret;
|
|
88
|
+
}
|
|
89
|
+
function isTemplateStringsArray(v) {
|
|
90
|
+
return has(v, "raw") && has(v, "length");
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* It is assumed that opts will not change. If this is a problem, clone your options object and pass the clone to
|
|
94
|
+
* makeInstance
|
|
95
|
+
* @param options
|
|
96
|
+
* @return {outdent}
|
|
97
|
+
*/
|
|
98
|
+
function createInstance(options) {
|
|
99
|
+
/** Cache of pre-processed template literal arrays */
|
|
100
|
+
var arrayAutoIndentCache = createWeakMap();
|
|
101
|
+
/**
|
|
102
|
+
* Cache of pre-processed template literal arrays, where first interpolated value is a reference to outdent,
|
|
103
|
+
* before interpolated values are injected.
|
|
104
|
+
*/
|
|
105
|
+
var arrayFirstInterpSetsIndentCache = createWeakMap();
|
|
106
|
+
function outdent(stringsOrOptions) {
|
|
107
|
+
var values = [];
|
|
108
|
+
for (var _i = 1; _i < arguments.length; _i++) values[_i - 1] = arguments[_i];
|
|
109
|
+
if (isTemplateStringsArray(stringsOrOptions)) {
|
|
110
|
+
var strings = stringsOrOptions;
|
|
111
|
+
var firstInterpolatedValueSetsIndentationLevel = (values[0] === outdent || values[0] === defaultOutdent) && reOnlyWhitespaceWithAtLeastOneNewline.test(strings[0]) && reStartsWithNewlineOrIsEmpty.test(strings[1]);
|
|
112
|
+
var cache = firstInterpolatedValueSetsIndentationLevel ? arrayFirstInterpSetsIndentCache : arrayAutoIndentCache;
|
|
113
|
+
var renderedArray = cache.get(strings);
|
|
114
|
+
if (!renderedArray) {
|
|
115
|
+
renderedArray = _outdentArray(strings, firstInterpolatedValueSetsIndentationLevel, options);
|
|
116
|
+
cache.set(strings, renderedArray);
|
|
117
|
+
}
|
|
118
|
+
/** If no interpolated values, skip concatenation step */
|
|
119
|
+
if (values.length === 0) return renderedArray[0];
|
|
120
|
+
return concatStringsAndValues(renderedArray, firstInterpolatedValueSetsIndentationLevel ? values.slice(1) : values);
|
|
121
|
+
} else return createInstance(extend(extend({}, options), stringsOrOptions || {}));
|
|
122
|
+
}
|
|
123
|
+
return extend(outdent, { string: function(str) {
|
|
124
|
+
return _outdentArray([str], false, options)[0];
|
|
125
|
+
} });
|
|
126
|
+
}
|
|
127
|
+
var defaultOutdent = createInstance({
|
|
128
|
+
trimLeadingNewline: true,
|
|
129
|
+
trimTrailingNewline: true
|
|
130
|
+
});
|
|
131
|
+
exports.outdent = defaultOutdent;
|
|
132
|
+
exports.default = defaultOutdent;
|
|
133
|
+
if (typeof module !== "undefined") try {
|
|
134
|
+
module.exports = defaultOutdent;
|
|
135
|
+
Object.defineProperty(defaultOutdent, "__esModule", { value: true });
|
|
136
|
+
defaultOutdent.default = defaultOutdent;
|
|
137
|
+
defaultOutdent.outdent = defaultOutdent;
|
|
138
|
+
} catch (e) {}
|
|
139
|
+
}));
|
|
140
|
+
|
|
141
|
+
//#endregion
|
|
142
|
+
//#region src/utils/errorMessages.ts
|
|
143
|
+
var import_lib = require_lib();
|
|
144
|
+
function createPrimaryTranslationsFileError(translationsDir) {
|
|
145
|
+
return new Error(import_lib.outdent`
|
|
146
|
+
Failed to load primary translation file.
|
|
147
|
+
💡 Tip: create a file '${join(translationsDir, "translations.json")}' in your project, then use the Wix CLI to push these keys.
|
|
148
|
+
|
|
149
|
+
Example translation file structure:
|
|
150
|
+
{
|
|
151
|
+
"hello": "Hello",
|
|
152
|
+
"goodbye": "Goodbye"
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
🔍 Need Help?
|
|
156
|
+
- Visit our docs: https://dev.wix.com/docs/go-headless
|
|
157
|
+
`);
|
|
158
|
+
}
|
|
159
|
+
function createTranslationsFilesError() {
|
|
160
|
+
return new Error(import_lib.outdent`
|
|
161
|
+
Failed to load translation file(s).
|
|
162
|
+
💡 Tip: Use the Wix CLI to pull the translation files from Wix.
|
|
163
|
+
`);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
//#endregion
|
|
167
|
+
//#region src/utils/loadTranslations.ts
|
|
168
|
+
async function loadTranslationFile(filePath) {
|
|
169
|
+
return readJson(filePath).then((data) => toNamespaceDictionary(data));
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Load the primary translation from `src/translations.json` and the other translation files from `.wix/multilingual/translations`.
|
|
173
|
+
* Merges translations with `src/translations.json` taking priority over `.wix/multilingual/translations`.
|
|
174
|
+
*/
|
|
175
|
+
async function loadAllTranslations(astroConfig) {
|
|
176
|
+
const srcDir = fileURLToPath(astroConfig.srcDir);
|
|
177
|
+
const multilingualDir = join(join(fileURLToPath(astroConfig.root), ".wix"), "multilingual");
|
|
178
|
+
const primaryTranslationPath = join(srcDir, TRANSLATIONS_FILENAME);
|
|
179
|
+
const pulledTranslationsDir = join(multilingualDir, "translations");
|
|
180
|
+
let metadata;
|
|
181
|
+
let primaryTranslation;
|
|
182
|
+
try {
|
|
183
|
+
metadata = await loadMetadata(multilingualDir);
|
|
184
|
+
primaryTranslation = await loadPrimaryTranslation(primaryTranslationPath, metadata);
|
|
185
|
+
} catch {
|
|
186
|
+
throw createPrimaryTranslationsFileError(srcDir);
|
|
187
|
+
}
|
|
188
|
+
return {
|
|
189
|
+
...await loadTranslations(pulledTranslationsDir),
|
|
190
|
+
...primaryTranslation
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
async function loadMetadata(translationsMetadataDir) {
|
|
194
|
+
return await readJson(join(translationsMetadataDir, TRANSLATIONS_METADATA_FILENAME));
|
|
195
|
+
}
|
|
196
|
+
async function loadPrimaryTranslation(primaryTranslationPath, metadata) {
|
|
197
|
+
const translationContent = await loadTranslationFile(primaryTranslationPath);
|
|
198
|
+
return { [metadata.primaryLanguageCode]: translationContent };
|
|
199
|
+
}
|
|
200
|
+
async function loadTranslations(translationsDir) {
|
|
201
|
+
if (!existsSync(translationsDir)) throw createTranslationsFilesError();
|
|
202
|
+
const jsonFiles = (await readdir(translationsDir)).filter((file) => file.endsWith(".json"));
|
|
203
|
+
const translations = {};
|
|
204
|
+
for (const file of jsonFiles) {
|
|
205
|
+
const languageCode = file.replace(".json", "");
|
|
206
|
+
translations[languageCode] = await loadTranslationFile(join(translationsDir, file));
|
|
207
|
+
}
|
|
208
|
+
return translations;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
//#endregion
|
|
212
|
+
//#region src/vite/wix-astro-i18n-plugin.ts
|
|
213
|
+
const VIRTUAL_MODULE_ID = "wix:astro:i18n";
|
|
214
|
+
const RESOLVED_VIRTUAL_MODULE_ID = `\0${VIRTUAL_MODULE_ID}`;
|
|
215
|
+
const i18nRuntimePath = fileURLToPath(new URL("../dependencies/astro-translations/backend-runtime/runtime/i18n.mjs", import.meta.url));
|
|
216
|
+
const wixAstroI18nPlugin = () => {
|
|
217
|
+
return {
|
|
218
|
+
name: "vite-plugin-wix-astro-i18n",
|
|
219
|
+
enforce: "pre",
|
|
220
|
+
load(id) {
|
|
221
|
+
if (id !== RESOLVED_VIRTUAL_MODULE_ID) return;
|
|
222
|
+
return `export * from '${i18nRuntimePath}';`;
|
|
223
|
+
},
|
|
224
|
+
resolveId(id) {
|
|
225
|
+
return id === VIRTUAL_MODULE_ID ? RESOLVED_VIRTUAL_MODULE_ID : void 0;
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
//#endregion
|
|
231
|
+
//#region src/index.ts
|
|
232
|
+
const i18nTypesPath = fileURLToPath(new URL("../dependencies/astro-translations/types/wix-astro-i18n.d.ts", import.meta.url));
|
|
233
|
+
const createIntegration = () => {
|
|
234
|
+
return {
|
|
235
|
+
name: "@wix/astro/static-translations",
|
|
236
|
+
hooks: {
|
|
237
|
+
"astro:config:setup": async ({ addMiddleware, config: astroConfig, updateConfig }) => {
|
|
238
|
+
const translations = await loadAllTranslations(astroConfig);
|
|
239
|
+
updateConfig({ vite: {
|
|
240
|
+
define: { __WIX_ASTRO_I18N__: JSON.stringify({
|
|
241
|
+
base: astroConfig.base,
|
|
242
|
+
siteUrl: astroConfig.site ?? null,
|
|
243
|
+
translations
|
|
244
|
+
}) },
|
|
245
|
+
plugins: [wixAstroI18nPlugin()]
|
|
246
|
+
} });
|
|
247
|
+
addMiddleware({
|
|
248
|
+
entrypoint: new URL("../dependencies/astro-translations/backend-runtime/middleware/static-translations.mjs", import.meta.url),
|
|
249
|
+
order: "pre"
|
|
250
|
+
});
|
|
251
|
+
},
|
|
252
|
+
"astro:config:done": async ({ injectTypes }) => {
|
|
253
|
+
injectTypes({
|
|
254
|
+
content: readFileSync(i18nTypesPath, "utf-8"),
|
|
255
|
+
filename: "wix-astro-i18n.d.ts"
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
};
|
|
261
|
+
var src_default = createIntegration;
|
|
262
|
+
|
|
263
|
+
//#endregion
|
|
264
|
+
export { src_default as default };
|
|
@@ -1 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import { ComponentType } from "react";
|
|
2
|
+
|
|
3
|
+
//#region ../astro-browser-runtime/src/hmr/react-component.d.ts
|
|
4
|
+
interface HotData {
|
|
5
|
+
Component?: ComponentType;
|
|
6
|
+
setComponent?: (NewComponent: ComponentType) => void;
|
|
7
|
+
}
|
|
8
|
+
declare function createComponentHmrWrapper(OriginalComponent: ComponentType, hotData: HotData): ComponentType;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { createComponentHmrWrapper };
|