@wix/astro 2.18.0 → 2.20.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/chunk-24J7STEA.js +8 -0
- package/build/dependencies/astro-auth/backend-runtime/chunk-352W54SQ.js +70 -0
- package/build/dependencies/astro-auth/backend-runtime/chunk-USQSPPTM.js +14 -0
- package/build/dependencies/astro-auth/backend-runtime/middleware/auth.js +68 -20
- package/build/dependencies/astro-auth/backend-runtime/middleware/localization.d.ts +5 -0
- package/build/dependencies/astro-auth/backend-runtime/middleware/localization.js +219 -0
- package/build/dependencies/astro-auth/backend-runtime/routes/callback.js +3 -2
- package/build/dependencies/astro-auth/backend-runtime/routes/login.js +3 -2
- package/build/dependencies/astro-auth/backend-runtime/routes/logout-callback.js +3 -2
- package/build/dependencies/astro-auth/backend-runtime/routes/logout.js +3 -2
- package/build/dependencies/astro-auth/backend-runtime/runtime/backend/setupContextualClient.js +9 -1
- package/build/dependencies/astro-backend-extensions/backend-runtime/chunk-CPGTXQVH.js +75 -0
- package/build/dependencies/astro-backend-extensions/backend-runtime/routes/extensions.js +41 -0
- package/build/dependencies/astro-backend-extensions/backend-runtime/runtime/setupServicePlugin.d.ts +7 -2
- package/build/dependencies/astro-backend-extensions/backend-runtime/runtime/setupServicePlugin.js +25 -4
- package/build/dependencies/astro-backend-extensions/backend-runtime/runtime/setupWebhook.d.ts +6 -2
- package/build/dependencies/astro-backend-extensions/backend-runtime/runtime/setupWebhook.js +24 -5
- package/build/dependencies/astro-backend-extensions/backend-runtime/utils-B7jr2PES.d.ts +5 -0
- package/build/dependencies/astro-context-providers-extensions/browser-runtime/hmr.js +26 -0
- package/build/dependencies/astro-context-providers-extensions/browser-runtime/sdk.js +21 -0
- package/build/dependencies/astro-context-providers-extensions/types/index.d.ts +32 -0
- package/build/dependencies/astro-core/types/index.d.ts +4 -3
- package/build/dependencies/astro-function-libraries-extensions/browser-runtime/sdk.js +21 -0
- package/build/dependencies/astro-function-libraries-extensions/types/index.d.ts +23 -0
- package/build/dependencies/astro-html-embeds/backend-runtime/html-embeds.js +4 -2
- package/build/dependencies/astro-site-components-extensions/types/index.d.ts +5 -0
- package/build/integration/builders-experimental.d.ts +53 -0
- package/build/integration/builders-experimental.js +20 -0
- package/build/integration/builders-experimental.js.map +1 -0
- package/build/integration/builders.d.ts +8 -57
- package/build/integration/builders.js +3 -41
- package/build/integration/builders.js.map +1 -1
- package/build/integration/chunk-QHGDEGZS.js +809 -0
- package/build/integration/chunk-QHGDEGZS.js.map +1 -0
- package/build/integration/chunk-WK4OVFTZ.js +1078 -0
- package/build/integration/chunk-WK4OVFTZ.js.map +1 -0
- package/build/integration/{chunk-IOVROVEX.js → chunk-ZOHC6VQD.js} +1960 -2845
- package/build/integration/chunk-ZOHC6VQD.js.map +1 -0
- package/build/integration/index.d-DMz9m26S.d.ts +58 -0
- package/build/integration/index.d.ts +5 -0
- package/build/integration/index.js +51 -30
- package/build/integration/index.js.map +1 -1
- package/package.json +10 -6
- package/build/dependencies/astro-auth/backend-runtime/chunk-IUZYED2S.js +0 -90
- package/build/dependencies/astro-auth/backend-runtime/chunk-YHKPE45V.js +0 -13
- package/build/dependencies/astro-backend-extensions/backend-runtime/chunk-F7JXR3EK.js +0 -25
- package/build/dependencies/astro-backend-extensions/backend-runtime/routes/servicePlugins.js +0 -18
- package/build/dependencies/astro-backend-extensions/backend-runtime/routes/webhooks.d.ts +0 -5
- package/build/dependencies/astro-backend-extensions/backend-runtime/routes/webhooks.js +0 -18
- package/build/integration/chunk-IOVROVEX.js.map +0 -1
- /package/build/dependencies/astro-backend-extensions/backend-runtime/routes/{servicePlugins.d.ts → extensions.d.ts} +0 -0
|
@@ -0,0 +1,809 @@
|
|
|
1
|
+
import { createRequire as _createRequire } from 'node:module';
|
|
2
|
+
const require = _createRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
appendToDevServerUrl,
|
|
5
|
+
buildAll,
|
|
6
|
+
cloneDeep,
|
|
7
|
+
createVirtualRouter,
|
|
8
|
+
defaultOutdent,
|
|
9
|
+
getAssetUrlForModuleId,
|
|
10
|
+
getChunkForEntryName,
|
|
11
|
+
init_esm_shims,
|
|
12
|
+
m,
|
|
13
|
+
merge,
|
|
14
|
+
normalizePath,
|
|
15
|
+
viteVirtualRouterPlugin
|
|
16
|
+
} from "./chunk-WK4OVFTZ.js";
|
|
17
|
+
|
|
18
|
+
// ../astro-context-providers-extensions/src/integration.ts
|
|
19
|
+
init_esm_shims();
|
|
20
|
+
import { ok } from "assert";
|
|
21
|
+
import { createServer } from "vite";
|
|
22
|
+
|
|
23
|
+
// ../astro-context-providers-extensions/src/utils/getResources.ts
|
|
24
|
+
init_esm_shims();
|
|
25
|
+
|
|
26
|
+
// ../astro-context-providers-extensions/src/utils/getClientResource.ts
|
|
27
|
+
init_esm_shims();
|
|
28
|
+
|
|
29
|
+
// ../astro-context-providers-extensions/src/vite/client/build-config.ts
|
|
30
|
+
init_esm_shims();
|
|
31
|
+
import { join as join2 } from "path";
|
|
32
|
+
|
|
33
|
+
// ../astro-context-providers-extensions/src/vite/shared.ts
|
|
34
|
+
init_esm_shims();
|
|
35
|
+
var extensionName = "context-providers";
|
|
36
|
+
var externalDeps = [
|
|
37
|
+
/^react$/,
|
|
38
|
+
/^react\/jsx-runtime$/,
|
|
39
|
+
/^react\/jsx-dev-runtime$/,
|
|
40
|
+
/^@preact\/signals-react$/,
|
|
41
|
+
/^@wix\/public-schemas$/
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
// ../astro-context-providers-extensions/src/vite/virtual-modules-plugin.ts
|
|
45
|
+
init_esm_shims();
|
|
46
|
+
|
|
47
|
+
// ../astro-context-providers-extensions/src/vite/client/virtual-module.ts
|
|
48
|
+
init_esm_shims();
|
|
49
|
+
|
|
50
|
+
// ../astro-context-providers-extensions/src/runtime/index.ts
|
|
51
|
+
init_esm_shims();
|
|
52
|
+
var sdkRuntimePath = normalizePath(
|
|
53
|
+
new URL(
|
|
54
|
+
"../dependencies/astro-context-providers-extensions/browser-runtime/sdk.js",
|
|
55
|
+
import.meta.url
|
|
56
|
+
)
|
|
57
|
+
);
|
|
58
|
+
var hmrRuntimePath = normalizePath(
|
|
59
|
+
new URL(
|
|
60
|
+
"../dependencies/astro-context-providers-extensions/browser-runtime/hmr.js",
|
|
61
|
+
import.meta.url
|
|
62
|
+
)
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
// ../astro-context-providers-extensions/src/utils/getContextProvider.ts
|
|
66
|
+
init_esm_shims();
|
|
67
|
+
|
|
68
|
+
// ../astro-context-providers-extensions/src/utils/getSupportedExtensions.ts
|
|
69
|
+
init_esm_shims();
|
|
70
|
+
import { join } from "path";
|
|
71
|
+
function getSupportedExtensions({
|
|
72
|
+
extensions,
|
|
73
|
+
srcDir
|
|
74
|
+
}) {
|
|
75
|
+
const contextProviderExtensions = extensions.filter(filterContextProviders);
|
|
76
|
+
return contextProviderExtensions.map((extension) => {
|
|
77
|
+
return {
|
|
78
|
+
...extension,
|
|
79
|
+
componentPath: join(srcDir, extension.options.resources.client.url),
|
|
80
|
+
editorPreviewPath: extension.options.resources.editor?.url != null ? join(srcDir, extension.options.resources.editor.url) : null
|
|
81
|
+
};
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
function filterContextProviders(extension) {
|
|
85
|
+
return extension.type === "ContextProvider";
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// ../astro-context-providers-extensions/src/utils/getContextProvider.ts
|
|
89
|
+
function getContextProvider(model, id) {
|
|
90
|
+
return getSupportedExtensions(model).find(
|
|
91
|
+
(ext) => ext.options.id === id
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// ../astro-context-providers-extensions/src/vite/client/virtual-module.ts
|
|
96
|
+
function getClientComponentBuildTemplate(componentPath) {
|
|
97
|
+
return defaultOutdent`
|
|
98
|
+
import { createContext } from '${sdkRuntimePath}';
|
|
99
|
+
|
|
100
|
+
export const injectAccessTokenGetter = createContext();
|
|
101
|
+
|
|
102
|
+
export { default } from '${componentPath}';
|
|
103
|
+
export * from '${componentPath}';
|
|
104
|
+
`;
|
|
105
|
+
}
|
|
106
|
+
function getClientComponentServeTemplate(componentPath, hookName) {
|
|
107
|
+
return defaultOutdent`
|
|
108
|
+
import { createContext } from '${sdkRuntimePath}';
|
|
109
|
+
import { createComponentHmrWrapper } from '${hmrRuntimePath}';
|
|
110
|
+
import OriginalComponent from '${componentPath}';
|
|
111
|
+
import { ${hookName} as originalHook } from '${componentPath}';
|
|
112
|
+
|
|
113
|
+
let WrappedComponent = OriginalComponent;
|
|
114
|
+
|
|
115
|
+
if (import.meta.hot) {
|
|
116
|
+
import.meta.hot.data.contextHook = originalHook;
|
|
117
|
+
import.meta.hot.accept('${componentPath}', (newModule) => {
|
|
118
|
+
if (newModule) {
|
|
119
|
+
if (newModule['${hookName}']) {
|
|
120
|
+
import.meta.hot.data.contextHook = newModule['${hookName}'];
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (newModule.default) {
|
|
124
|
+
import.meta.hot.data.setComponent?.(newModule.default);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
WrappedComponent = createComponentHmrWrapper(OriginalComponent, import.meta.hot.data);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export const injectAccessTokenGetter = createContext();
|
|
133
|
+
export const ${hookName} = (...args) => {
|
|
134
|
+
const hookToCall = import.meta.hot?.data.contextHook ?? originalHook;
|
|
135
|
+
return hookToCall(...args);
|
|
136
|
+
}
|
|
137
|
+
export default WrappedComponent;
|
|
138
|
+
`;
|
|
139
|
+
}
|
|
140
|
+
function getVirtualModuleIdForClientComponent(componentId) {
|
|
141
|
+
return `wix/context-provider/${componentId}`;
|
|
142
|
+
}
|
|
143
|
+
function registerClientVirtualRoute({
|
|
144
|
+
model,
|
|
145
|
+
router
|
|
146
|
+
}) {
|
|
147
|
+
router.route(
|
|
148
|
+
getVirtualModuleIdForClientComponent(":id"),
|
|
149
|
+
({ id }, { command }) => {
|
|
150
|
+
const extension = getContextProvider(model, id);
|
|
151
|
+
if (extension) {
|
|
152
|
+
const componentPath = normalizePath(extension.componentPath);
|
|
153
|
+
if (command === "build") {
|
|
154
|
+
return getClientComponentBuildTemplate(componentPath);
|
|
155
|
+
}
|
|
156
|
+
return getClientComponentServeTemplate(
|
|
157
|
+
componentPath,
|
|
158
|
+
extension.options.resources.contextSpecifier.hook
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// ../astro-context-providers-extensions/src/vite/editor/virtual-module.ts
|
|
167
|
+
init_esm_shims();
|
|
168
|
+
function getVirtualModuleIdForEditorComponent(componentId) {
|
|
169
|
+
return `wix/context-provider-editor/${componentId}`;
|
|
170
|
+
}
|
|
171
|
+
function registerEditorVirtualRoute({
|
|
172
|
+
model,
|
|
173
|
+
router
|
|
174
|
+
}) {
|
|
175
|
+
router.route(
|
|
176
|
+
getVirtualModuleIdForEditorComponent(":id"),
|
|
177
|
+
({ id }, { command }) => {
|
|
178
|
+
const extension = getContextProvider(model, id);
|
|
179
|
+
if (extension?.editorPreviewPath != null) {
|
|
180
|
+
const componentPath = normalizePath(extension.editorPreviewPath);
|
|
181
|
+
if (command === "build") {
|
|
182
|
+
return getClientComponentBuildTemplate(componentPath);
|
|
183
|
+
}
|
|
184
|
+
return getClientComponentServeTemplate(
|
|
185
|
+
componentPath,
|
|
186
|
+
extension.options.resources.contextSpecifier.hook
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// ../astro-context-providers-extensions/src/vite/virtual-modules-plugin.ts
|
|
195
|
+
function virtualModulesPlugin({ model }) {
|
|
196
|
+
const router = createVirtualRouter();
|
|
197
|
+
registerClientVirtualRoute({ model, router });
|
|
198
|
+
registerEditorVirtualRoute({ model, router });
|
|
199
|
+
return viteVirtualRouterPlugin({
|
|
200
|
+
name: "wix:context-provider-virtual-modules-plugin",
|
|
201
|
+
router
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// ../astro-context-providers-extensions/src/vite/client/build-config.ts
|
|
206
|
+
var getClientBuildConfig = ({
|
|
207
|
+
createExtensionViteConfig,
|
|
208
|
+
extension: {
|
|
209
|
+
options: { id }
|
|
210
|
+
},
|
|
211
|
+
model
|
|
212
|
+
}) => {
|
|
213
|
+
return createExtensionViteConfig({
|
|
214
|
+
name: join2(extensionName, "client"),
|
|
215
|
+
config: {
|
|
216
|
+
build: {
|
|
217
|
+
rollupOptions: {
|
|
218
|
+
external: externalDeps,
|
|
219
|
+
input: {
|
|
220
|
+
[getEntryNameForClientComponent(id)]: getVirtualModuleIdForClientComponent(id)
|
|
221
|
+
},
|
|
222
|
+
preserveEntrySignatures: "strict"
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
plugins: [virtualModulesPlugin({ model })]
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
};
|
|
229
|
+
function getEntryNameForClientComponent(componentId) {
|
|
230
|
+
return `context-provider-${componentId}`;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// ../astro-context-providers-extensions/src/utils/getClientResource.ts
|
|
234
|
+
function getClientResource({
|
|
235
|
+
baseUrl,
|
|
236
|
+
buildOutput,
|
|
237
|
+
devServer,
|
|
238
|
+
extension
|
|
239
|
+
}) {
|
|
240
|
+
if (buildOutput) {
|
|
241
|
+
return getClientResourceBuild({ baseUrl, buildOutput, extension });
|
|
242
|
+
}
|
|
243
|
+
if (devServer) {
|
|
244
|
+
return getClientResourceDev({ baseUrl, devServer, extension });
|
|
245
|
+
}
|
|
246
|
+
throw new Error("Unknown error: no build output or vite dev server");
|
|
247
|
+
}
|
|
248
|
+
function getClientResourceBuild({
|
|
249
|
+
baseUrl,
|
|
250
|
+
buildOutput,
|
|
251
|
+
extension
|
|
252
|
+
}) {
|
|
253
|
+
const entryName = getEntryNameForClientComponent(extension.options.id);
|
|
254
|
+
const chunk = getChunkForEntryName({ buildOutput, entryName });
|
|
255
|
+
const componentFileName = chunk.fileName;
|
|
256
|
+
return {
|
|
257
|
+
url: appendToDevServerUrl(baseUrl, componentFileName)
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
function getClientResourceDev({
|
|
261
|
+
baseUrl,
|
|
262
|
+
devServer,
|
|
263
|
+
extension
|
|
264
|
+
}) {
|
|
265
|
+
const moduleId = getVirtualModuleIdForClientComponent(extension.options.id);
|
|
266
|
+
return {
|
|
267
|
+
url: getAssetUrlForModuleId({ baseUrl, devServer, moduleId })
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// ../astro-context-providers-extensions/src/utils/getEditorResource.ts
|
|
272
|
+
init_esm_shims();
|
|
273
|
+
|
|
274
|
+
// ../astro-context-providers-extensions/src/vite/editor/build-config.ts
|
|
275
|
+
init_esm_shims();
|
|
276
|
+
import { join as join3 } from "path";
|
|
277
|
+
function getEntryNameForEditorComponent(componentId) {
|
|
278
|
+
return `component-${componentId}-editor`;
|
|
279
|
+
}
|
|
280
|
+
var getEditorBuildConfig = ({
|
|
281
|
+
createExtensionViteConfig,
|
|
282
|
+
extension: {
|
|
283
|
+
options: { id }
|
|
284
|
+
},
|
|
285
|
+
model
|
|
286
|
+
}) => {
|
|
287
|
+
return createExtensionViteConfig({
|
|
288
|
+
name: join3(extensionName, "editor"),
|
|
289
|
+
config: {
|
|
290
|
+
build: {
|
|
291
|
+
rollupOptions: {
|
|
292
|
+
external: externalDeps,
|
|
293
|
+
input: {
|
|
294
|
+
[getEntryNameForEditorComponent(id)]: getVirtualModuleIdForEditorComponent(id)
|
|
295
|
+
},
|
|
296
|
+
preserveEntrySignatures: "strict"
|
|
297
|
+
}
|
|
298
|
+
},
|
|
299
|
+
plugins: [virtualModulesPlugin({ model })]
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
// ../astro-context-providers-extensions/src/utils/getEditorResource.ts
|
|
305
|
+
function getEditorResource({
|
|
306
|
+
baseUrl,
|
|
307
|
+
buildOutput,
|
|
308
|
+
devServer,
|
|
309
|
+
extension
|
|
310
|
+
}) {
|
|
311
|
+
if (extension.editorPreviewPath == null) {
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
if (buildOutput) {
|
|
315
|
+
return getEditorResourceBuild({ baseUrl, buildOutput, extension });
|
|
316
|
+
}
|
|
317
|
+
if (devServer) {
|
|
318
|
+
return getEditorResourceDev({ baseUrl, devServer, extension });
|
|
319
|
+
}
|
|
320
|
+
throw new Error("Unknown error: no build output or vite dev server");
|
|
321
|
+
}
|
|
322
|
+
function getEditorResourceBuild({
|
|
323
|
+
baseUrl,
|
|
324
|
+
buildOutput,
|
|
325
|
+
extension
|
|
326
|
+
}) {
|
|
327
|
+
const entryName = getEntryNameForEditorComponent(extension.options.id);
|
|
328
|
+
const chunk = getChunkForEntryName({ buildOutput, entryName });
|
|
329
|
+
const componentFileName = chunk.fileName;
|
|
330
|
+
return {
|
|
331
|
+
url: appendToDevServerUrl(baseUrl, componentFileName)
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
function getEditorResourceDev({
|
|
335
|
+
baseUrl,
|
|
336
|
+
devServer,
|
|
337
|
+
extension
|
|
338
|
+
}) {
|
|
339
|
+
const moduleId = getVirtualModuleIdForEditorComponent(extension.options.id);
|
|
340
|
+
return {
|
|
341
|
+
url: getAssetUrlForModuleId({ baseUrl, devServer, moduleId })
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
// ../astro-context-providers-extensions/src/utils/getResources.ts
|
|
346
|
+
function getResources(buildContext) {
|
|
347
|
+
return {
|
|
348
|
+
client: getClientResource(buildContext),
|
|
349
|
+
editor: getEditorResource(buildContext)
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
// ../astro-context-providers-extensions/src/vite/configs/build.ts
|
|
354
|
+
init_esm_shims();
|
|
355
|
+
function getBuildViteConfigs({
|
|
356
|
+
createExtensionViteConfig,
|
|
357
|
+
model
|
|
358
|
+
}) {
|
|
359
|
+
const extensions = getSupportedExtensions(model);
|
|
360
|
+
return extensions.reduce((acc, extension) => {
|
|
361
|
+
const { editorPreviewPath } = extension;
|
|
362
|
+
acc.push(
|
|
363
|
+
getClientBuildConfig({
|
|
364
|
+
createExtensionViteConfig,
|
|
365
|
+
extension,
|
|
366
|
+
model
|
|
367
|
+
})
|
|
368
|
+
);
|
|
369
|
+
if (editorPreviewPath != null) {
|
|
370
|
+
acc.push(
|
|
371
|
+
getEditorBuildConfig({
|
|
372
|
+
createExtensionViteConfig,
|
|
373
|
+
extension,
|
|
374
|
+
model
|
|
375
|
+
})
|
|
376
|
+
);
|
|
377
|
+
}
|
|
378
|
+
return acc;
|
|
379
|
+
}, []);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
// ../astro-context-providers-extensions/src/vite/configs/dev.ts
|
|
383
|
+
init_esm_shims();
|
|
384
|
+
function getDevViteConfig({
|
|
385
|
+
createExtensionViteConfig,
|
|
386
|
+
model
|
|
387
|
+
}) {
|
|
388
|
+
const extensionEntries = getSupportedExtensions(model).map((ext) => [
|
|
389
|
+
ext.componentPath,
|
|
390
|
+
...ext.editorPreviewPath != null ? [ext.editorPreviewPath] : []
|
|
391
|
+
]).flat();
|
|
392
|
+
return createExtensionViteConfig({
|
|
393
|
+
name: extensionName,
|
|
394
|
+
config: {
|
|
395
|
+
optimizeDeps: {
|
|
396
|
+
entries: [...extensionEntries, sdkRuntimePath, hmrRuntimePath]
|
|
397
|
+
},
|
|
398
|
+
plugins: [
|
|
399
|
+
m({
|
|
400
|
+
externals: externalDeps
|
|
401
|
+
}),
|
|
402
|
+
virtualModulesPlugin({ model })
|
|
403
|
+
]
|
|
404
|
+
}
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
// ../astro-context-providers-extensions/src/integration.ts
|
|
409
|
+
var createIntegration = () => {
|
|
410
|
+
let model = null;
|
|
411
|
+
let customBuildOutput = null;
|
|
412
|
+
let customDevServer = null;
|
|
413
|
+
return {
|
|
414
|
+
name: "@wix/astro/context-providers",
|
|
415
|
+
hooks: {
|
|
416
|
+
"wix:model:setup"({ model: newModel }) {
|
|
417
|
+
model = newModel;
|
|
418
|
+
},
|
|
419
|
+
async "wix:server:start"({
|
|
420
|
+
createExtensionViteConfig,
|
|
421
|
+
setupExtensionProxy
|
|
422
|
+
}) {
|
|
423
|
+
ok(model);
|
|
424
|
+
customDevServer = await createServer(
|
|
425
|
+
getDevViteConfig({ createExtensionViteConfig, model })
|
|
426
|
+
);
|
|
427
|
+
await customDevServer.listen();
|
|
428
|
+
setupExtensionProxy(customDevServer);
|
|
429
|
+
},
|
|
430
|
+
async "astro:server:done"() {
|
|
431
|
+
ok(customDevServer);
|
|
432
|
+
await customDevServer.close();
|
|
433
|
+
},
|
|
434
|
+
async "wix:build:setup"({ createExtensionViteConfig }) {
|
|
435
|
+
ok(model);
|
|
436
|
+
const extensions = getSupportedExtensions(model);
|
|
437
|
+
if (extensions.length === 0) {
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
440
|
+
customBuildOutput = await buildAll(
|
|
441
|
+
getBuildViteConfigs({ createExtensionViteConfig, model })
|
|
442
|
+
);
|
|
443
|
+
},
|
|
444
|
+
async "wix:app-manifest:setup"({
|
|
445
|
+
staticsUrlPlaceholder,
|
|
446
|
+
updateAppManifest
|
|
447
|
+
}) {
|
|
448
|
+
ok(model);
|
|
449
|
+
const extensions = getSupportedExtensions(model);
|
|
450
|
+
const components = [];
|
|
451
|
+
for (const extension of extensions) {
|
|
452
|
+
const buildContext = {
|
|
453
|
+
baseUrl: staticsUrlPlaceholder,
|
|
454
|
+
buildOutput: customBuildOutput,
|
|
455
|
+
devServer: customDevServer,
|
|
456
|
+
extension
|
|
457
|
+
};
|
|
458
|
+
components.push({
|
|
459
|
+
compId: extension.options.id,
|
|
460
|
+
compType: "EDITOR_CONTEXT_PROVIDER",
|
|
461
|
+
compData: {
|
|
462
|
+
editorContextProvider: merge(cloneDeep(extension.options), {
|
|
463
|
+
resources: getResources(buildContext)
|
|
464
|
+
})
|
|
465
|
+
}
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
updateAppManifest({ components });
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
};
|
|
472
|
+
};
|
|
473
|
+
|
|
474
|
+
// ../astro-context-providers-extensions/src/builders.ts
|
|
475
|
+
init_esm_shims();
|
|
476
|
+
function contextProvider(options) {
|
|
477
|
+
return {
|
|
478
|
+
type: "ContextProvider",
|
|
479
|
+
options
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
// ../astro-context-providers-extensions/src/index.ts
|
|
484
|
+
init_esm_shims();
|
|
485
|
+
|
|
486
|
+
// ../astro-function-libraries-extensions/src/integration.ts
|
|
487
|
+
init_esm_shims();
|
|
488
|
+
import { ok as ok2 } from "assert";
|
|
489
|
+
import { createServer as createServer2 } from "vite";
|
|
490
|
+
|
|
491
|
+
// ../astro-function-libraries-extensions/src/utils/getResources.ts
|
|
492
|
+
init_esm_shims();
|
|
493
|
+
|
|
494
|
+
// ../astro-function-libraries-extensions/src/utils/getClientResource.ts
|
|
495
|
+
init_esm_shims();
|
|
496
|
+
|
|
497
|
+
// ../astro-function-libraries-extensions/src/vite/client/virtual-module.ts
|
|
498
|
+
init_esm_shims();
|
|
499
|
+
|
|
500
|
+
// ../astro-function-libraries-extensions/src/utils/getFunctionLibrary.ts
|
|
501
|
+
init_esm_shims();
|
|
502
|
+
|
|
503
|
+
// ../astro-function-libraries-extensions/src/utils/getSupportedExtensions.ts
|
|
504
|
+
init_esm_shims();
|
|
505
|
+
import { join as join4 } from "path";
|
|
506
|
+
function getSupportedExtensions2({
|
|
507
|
+
extensions,
|
|
508
|
+
srcDir
|
|
509
|
+
}) {
|
|
510
|
+
const functionLibraryExtensions = extensions.filter(filterFunctionLibrary);
|
|
511
|
+
return functionLibraryExtensions.map((extension) => {
|
|
512
|
+
return {
|
|
513
|
+
...extension,
|
|
514
|
+
componentPath: join4(srcDir, extension.options.resources.client.url)
|
|
515
|
+
};
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
function filterFunctionLibrary(extension) {
|
|
519
|
+
return extension.type === "FunctionLibrary";
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
// ../astro-function-libraries-extensions/src/utils/getFunctionLibrary.ts
|
|
523
|
+
function getFunctionLibrary(model, id) {
|
|
524
|
+
return getSupportedExtensions2(model).find(
|
|
525
|
+
(ext) => ext.options.id === id
|
|
526
|
+
);
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
// ../astro-function-libraries-extensions/src/vite/client/virtual-module.ts
|
|
530
|
+
function getVirtualModuleIdForClientComponent2(componentId) {
|
|
531
|
+
return `wix/function-library/${componentId}`;
|
|
532
|
+
}
|
|
533
|
+
function registerClientVirtualRoute2({
|
|
534
|
+
model,
|
|
535
|
+
router
|
|
536
|
+
}) {
|
|
537
|
+
router.route(
|
|
538
|
+
getVirtualModuleIdForClientComponent2(":id"),
|
|
539
|
+
({ id }, { command }) => {
|
|
540
|
+
const extension = getFunctionLibrary(model, id);
|
|
541
|
+
if (extension) {
|
|
542
|
+
const componentPath = normalizePath(extension.componentPath);
|
|
543
|
+
if (command === "build") {
|
|
544
|
+
return getClientComponentBuildTemplate2(componentPath);
|
|
545
|
+
}
|
|
546
|
+
return getClientComponentServeTemplate2(
|
|
547
|
+
componentPath,
|
|
548
|
+
Object.keys(extension.options.functions)
|
|
549
|
+
);
|
|
550
|
+
}
|
|
551
|
+
return null;
|
|
552
|
+
}
|
|
553
|
+
);
|
|
554
|
+
}
|
|
555
|
+
function getClientComponentBuildTemplate2(componentPath) {
|
|
556
|
+
return defaultOutdent`
|
|
557
|
+
export * from '${componentPath}';
|
|
558
|
+
`;
|
|
559
|
+
}
|
|
560
|
+
function getClientComponentServeTemplate2(componentPath, functionsNames) {
|
|
561
|
+
return defaultOutdent`
|
|
562
|
+
import * as originalFunctions from '${componentPath}';
|
|
563
|
+
|
|
564
|
+
if (import.meta.hot) {
|
|
565
|
+
import.meta.hot.data.functionLibrary = {};
|
|
566
|
+
import.meta.hot.accept('${componentPath}', (newModule) => {
|
|
567
|
+
if (newModule) {
|
|
568
|
+
Object.entries(newModule).forEach((name, fn) => {
|
|
569
|
+
import.meta.hot.data.functionLibrary[name] = fn;
|
|
570
|
+
})
|
|
571
|
+
if (newModule.default) {
|
|
572
|
+
import.meta.hot.data.setComponent?.(newModule?.default);
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
});
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
${functionsNames.map(
|
|
579
|
+
(name) => defaultOutdent`
|
|
580
|
+
export const ${name} = (...args) => {
|
|
581
|
+
const fnToCall = import.meta.hot?.data.functionLibrary['${name}'] ?? originalFunctions['${name}'];
|
|
582
|
+
return fnToCall(...args);
|
|
583
|
+
}
|
|
584
|
+
`
|
|
585
|
+
).join("\n")}
|
|
586
|
+
|
|
587
|
+
export * from '${componentPath}';
|
|
588
|
+
`;
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
// ../astro-function-libraries-extensions/src/vite/configs/build.ts
|
|
592
|
+
init_esm_shims();
|
|
593
|
+
import { join as join5 } from "path";
|
|
594
|
+
|
|
595
|
+
// ../astro-function-libraries-extensions/src/vite/shared.ts
|
|
596
|
+
init_esm_shims();
|
|
597
|
+
var extensionName2 = "function-libraries";
|
|
598
|
+
var externalDeps2 = [/^@wix\/public-schemas$/];
|
|
599
|
+
|
|
600
|
+
// ../astro-function-libraries-extensions/src/vite/virtual-modules-plugin.ts
|
|
601
|
+
init_esm_shims();
|
|
602
|
+
function virtualModulesPlugin2({ model }) {
|
|
603
|
+
const router = createVirtualRouter();
|
|
604
|
+
registerClientVirtualRoute2({ model, router });
|
|
605
|
+
return viteVirtualRouterPlugin({
|
|
606
|
+
name: "wix:function-library-virtual-modules-plugin",
|
|
607
|
+
router
|
|
608
|
+
});
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
// ../astro-function-libraries-extensions/src/vite/configs/build.ts
|
|
612
|
+
function getBuildViteConfigs2({
|
|
613
|
+
createExtensionViteConfig,
|
|
614
|
+
model
|
|
615
|
+
}) {
|
|
616
|
+
const extensions = getSupportedExtensions2(model);
|
|
617
|
+
return extensions.reduce((acc, extension) => {
|
|
618
|
+
const {
|
|
619
|
+
options: { id: extensionId }
|
|
620
|
+
} = extension;
|
|
621
|
+
const input = {
|
|
622
|
+
[getEntryNameForClientComponent2(extensionId)]: getVirtualModuleIdForClientComponent2(extensionId)
|
|
623
|
+
};
|
|
624
|
+
acc.push(
|
|
625
|
+
createExtensionViteConfig({
|
|
626
|
+
name: join5(extensionName2, "client"),
|
|
627
|
+
config: {
|
|
628
|
+
build: {
|
|
629
|
+
rollupOptions: {
|
|
630
|
+
external: externalDeps2,
|
|
631
|
+
input,
|
|
632
|
+
preserveEntrySignatures: "strict"
|
|
633
|
+
}
|
|
634
|
+
},
|
|
635
|
+
plugins: [virtualModulesPlugin2({ model })]
|
|
636
|
+
}
|
|
637
|
+
})
|
|
638
|
+
);
|
|
639
|
+
return acc;
|
|
640
|
+
}, []);
|
|
641
|
+
}
|
|
642
|
+
function getEntryNameForClientComponent2(componentId) {
|
|
643
|
+
return `component-${componentId}`;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
// ../astro-function-libraries-extensions/src/utils/getClientResource.ts
|
|
647
|
+
function getClientResource2({
|
|
648
|
+
baseUrl,
|
|
649
|
+
buildOutput,
|
|
650
|
+
devServer,
|
|
651
|
+
extension
|
|
652
|
+
}) {
|
|
653
|
+
if (buildOutput) {
|
|
654
|
+
return getClientResourceBuild2({ baseUrl, buildOutput, extension });
|
|
655
|
+
}
|
|
656
|
+
if (devServer) {
|
|
657
|
+
return getClientResourceDev2({ baseUrl, devServer, extension });
|
|
658
|
+
}
|
|
659
|
+
throw new Error("Unknown error: no build output or vite dev server");
|
|
660
|
+
}
|
|
661
|
+
function getClientResourceBuild2({
|
|
662
|
+
baseUrl,
|
|
663
|
+
buildOutput,
|
|
664
|
+
extension
|
|
665
|
+
}) {
|
|
666
|
+
const entryName = getEntryNameForClientComponent2(extension.options.id);
|
|
667
|
+
const chunk = getChunkForEntryName({ buildOutput, entryName });
|
|
668
|
+
const componentFileName = chunk.fileName;
|
|
669
|
+
return {
|
|
670
|
+
url: appendToDevServerUrl(baseUrl, componentFileName)
|
|
671
|
+
};
|
|
672
|
+
}
|
|
673
|
+
function getClientResourceDev2({
|
|
674
|
+
baseUrl,
|
|
675
|
+
devServer,
|
|
676
|
+
extension
|
|
677
|
+
}) {
|
|
678
|
+
const moduleId = getVirtualModuleIdForClientComponent2(extension.options.id);
|
|
679
|
+
return {
|
|
680
|
+
url: getAssetUrlForModuleId({ baseUrl, devServer, moduleId })
|
|
681
|
+
};
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
// ../astro-function-libraries-extensions/src/utils/getResources.ts
|
|
685
|
+
function getResources2(buildContext) {
|
|
686
|
+
return {
|
|
687
|
+
client: getClientResource2(buildContext)
|
|
688
|
+
};
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
// ../astro-function-libraries-extensions/src/vite/configs/dev.ts
|
|
692
|
+
init_esm_shims();
|
|
693
|
+
|
|
694
|
+
// ../astro-function-libraries-extensions/src/runtime/index.ts
|
|
695
|
+
init_esm_shims();
|
|
696
|
+
var sdkRuntimePath2 = normalizePath(
|
|
697
|
+
new URL(
|
|
698
|
+
"../dependencies/astro-context-providers-extensions/browser-runtime/sdk.js",
|
|
699
|
+
import.meta.url
|
|
700
|
+
)
|
|
701
|
+
);
|
|
702
|
+
|
|
703
|
+
// ../astro-function-libraries-extensions/src/vite/configs/dev.ts
|
|
704
|
+
function getDevViteConfig2({
|
|
705
|
+
createExtensionViteConfig,
|
|
706
|
+
model
|
|
707
|
+
}) {
|
|
708
|
+
const extensionEntries = getSupportedExtensions2(model).map((ext) => [ext.componentPath]).flat();
|
|
709
|
+
return createExtensionViteConfig({
|
|
710
|
+
name: extensionName2,
|
|
711
|
+
config: {
|
|
712
|
+
optimizeDeps: {
|
|
713
|
+
entries: [...extensionEntries, sdkRuntimePath2]
|
|
714
|
+
},
|
|
715
|
+
plugins: [
|
|
716
|
+
m({
|
|
717
|
+
externals: externalDeps2
|
|
718
|
+
}),
|
|
719
|
+
virtualModulesPlugin2({ model })
|
|
720
|
+
]
|
|
721
|
+
}
|
|
722
|
+
});
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
// ../astro-function-libraries-extensions/src/integration.ts
|
|
726
|
+
var createIntegration2 = () => {
|
|
727
|
+
let model = null;
|
|
728
|
+
let customBuildOutput = null;
|
|
729
|
+
let customDevServer = null;
|
|
730
|
+
return {
|
|
731
|
+
name: "@wix/astro/function-libraries",
|
|
732
|
+
hooks: {
|
|
733
|
+
"wix:model:setup"({ model: newModel }) {
|
|
734
|
+
model = newModel;
|
|
735
|
+
},
|
|
736
|
+
async "wix:server:start"({
|
|
737
|
+
createExtensionViteConfig,
|
|
738
|
+
setupExtensionProxy
|
|
739
|
+
}) {
|
|
740
|
+
ok2(model);
|
|
741
|
+
customDevServer = await createServer2(
|
|
742
|
+
getDevViteConfig2({ createExtensionViteConfig, model })
|
|
743
|
+
);
|
|
744
|
+
await customDevServer.listen();
|
|
745
|
+
setupExtensionProxy(customDevServer);
|
|
746
|
+
},
|
|
747
|
+
async "astro:server:done"() {
|
|
748
|
+
ok2(customDevServer);
|
|
749
|
+
await customDevServer.close();
|
|
750
|
+
},
|
|
751
|
+
async "wix:build:setup"({ createExtensionViteConfig }) {
|
|
752
|
+
ok2(model);
|
|
753
|
+
const extensions = getSupportedExtensions2(model);
|
|
754
|
+
if (extensions.length === 0) {
|
|
755
|
+
return;
|
|
756
|
+
}
|
|
757
|
+
customBuildOutput = await buildAll(
|
|
758
|
+
getBuildViteConfigs2({ createExtensionViteConfig, model })
|
|
759
|
+
);
|
|
760
|
+
},
|
|
761
|
+
async "wix:app-manifest:setup"({
|
|
762
|
+
staticsUrlPlaceholder,
|
|
763
|
+
updateAppManifest
|
|
764
|
+
}) {
|
|
765
|
+
ok2(model);
|
|
766
|
+
const extensions = getSupportedExtensions2(model);
|
|
767
|
+
const components = [];
|
|
768
|
+
for (const extension of extensions) {
|
|
769
|
+
const buildContext = {
|
|
770
|
+
baseUrl: staticsUrlPlaceholder,
|
|
771
|
+
buildOutput: customBuildOutput,
|
|
772
|
+
devServer: customDevServer,
|
|
773
|
+
extension
|
|
774
|
+
};
|
|
775
|
+
components.push({
|
|
776
|
+
compId: extension.options.id,
|
|
777
|
+
compType: "EDITOR_FUNCTION_LIBRARY",
|
|
778
|
+
compData: {
|
|
779
|
+
editorFunctionLibrary: merge(cloneDeep(extension.options), {
|
|
780
|
+
resources: getResources2(buildContext)
|
|
781
|
+
})
|
|
782
|
+
}
|
|
783
|
+
});
|
|
784
|
+
}
|
|
785
|
+
updateAppManifest({ components });
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
};
|
|
789
|
+
};
|
|
790
|
+
|
|
791
|
+
// ../astro-function-libraries-extensions/src/builders.ts
|
|
792
|
+
init_esm_shims();
|
|
793
|
+
function functionLibrary(options) {
|
|
794
|
+
return {
|
|
795
|
+
type: "FunctionLibrary",
|
|
796
|
+
options
|
|
797
|
+
};
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
// ../astro-function-libraries-extensions/src/index.ts
|
|
801
|
+
init_esm_shims();
|
|
802
|
+
|
|
803
|
+
export {
|
|
804
|
+
createIntegration,
|
|
805
|
+
contextProvider,
|
|
806
|
+
createIntegration2,
|
|
807
|
+
functionLibrary
|
|
808
|
+
};
|
|
809
|
+
//# sourceMappingURL=chunk-QHGDEGZS.js.map
|