vike 0.4.227-commit-c9cc081 → 0.4.227-commit-25aa0f8
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/dist/cjs/node/plugin/plugins/build/pluginAutoFullBuild.js +2 -5
- package/dist/cjs/node/plugin/plugins/build/pluginDistPackageJsonFile.js +2 -5
- package/dist/cjs/node/plugin/plugins/build/pluginModuleBanner.js +16 -6
- package/dist/cjs/node/plugin/plugins/commonConfig.js +2 -1
- package/dist/cjs/node/plugin/plugins/devConfig/index.js +6 -8
- package/dist/cjs/node/plugin/plugins/envVars.js +7 -9
- package/dist/cjs/node/plugin/plugins/extractAssetsPlugin.js +6 -14
- package/dist/cjs/node/plugin/plugins/extractExportNamesPlugin.js +1 -2
- package/dist/cjs/node/plugin/plugins/fileEnv.js +13 -18
- package/dist/cjs/node/plugin/plugins/importUserCode/index.js +6 -8
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +1 -0
- package/dist/cjs/node/plugin/shared/resolveClientEntriesDev.js +2 -1
- package/dist/cjs/node/plugin/utils.js +1 -0
- package/dist/cjs/node/prerender/runPrerender.js +168 -150
- package/dist/cjs/node/prerender/utils.js +1 -1
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +0 -23
- package/dist/cjs/shared/route/executeOnBeforeRouteHook.js +1 -1
- package/dist/cjs/shared/route/index.js +13 -11
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/isScriptFile.js +4 -4
- package/dist/cjs/utils/parseUrl.js +4 -4
- package/dist/cjs/utils/preservePropertyGetters.js +30 -0
- package/dist/cjs/{node/plugin/shared → utils}/rollupSourceMap.js +4 -4
- package/dist/esm/node/plugin/plugins/build/pluginAutoFullBuild.js +2 -5
- package/dist/esm/node/plugin/plugins/build/pluginDistPackageJsonFile.js +2 -4
- package/dist/esm/node/plugin/plugins/build/pluginModuleBanner.js +16 -6
- package/dist/esm/node/plugin/plugins/commonConfig.js +2 -1
- package/dist/esm/node/plugin/plugins/devConfig/index.js +6 -8
- package/dist/esm/node/plugin/plugins/envVars.js +8 -10
- package/dist/esm/node/plugin/plugins/extractAssetsPlugin.js +7 -11
- package/dist/esm/node/plugin/plugins/extractExportNamesPlugin.js +2 -3
- package/dist/esm/node/plugin/plugins/fileEnv.js +14 -19
- package/dist/esm/node/plugin/plugins/importUserCode/index.js +6 -8
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +1 -0
- package/dist/esm/node/plugin/shared/resolveClientEntriesDev.js +2 -1
- package/dist/esm/node/plugin/utils.d.ts +1 -0
- package/dist/esm/node/plugin/utils.js +1 -0
- package/dist/esm/node/prerender/runPrerender.d.ts +2 -0
- package/dist/esm/node/prerender/runPrerender.js +171 -153
- package/dist/esm/node/prerender/utils.d.ts +1 -1
- package/dist/esm/node/prerender/utils.js +1 -1
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +0 -182
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +0 -23
- package/dist/esm/shared/route/executeOnBeforeRouteHook.js +1 -1
- package/dist/esm/shared/route/index.d.ts +1 -1
- package/dist/esm/shared/route/index.js +13 -11
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/isScriptFile.js +4 -4
- package/dist/esm/utils/parseUrl.js +4 -4
- package/dist/esm/utils/preservePropertyGetters.d.ts +2 -0
- package/dist/esm/utils/preservePropertyGetters.js +28 -0
- package/dist/esm/{node/plugin/shared → utils}/rollupSourceMap.d.ts +4 -4
- package/dist/esm/{node/plugin/shared → utils}/rollupSourceMap.js +4 -4
- package/package.json +1 -1
- package/dist/cjs/node/plugin/shared/getResolvedConfig.js +0 -6
- package/dist/esm/node/plugin/shared/getResolvedConfig.d.ts +0 -2
- package/dist/esm/node/plugin/shared/getResolvedConfig.js +0 -3
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { renderPageAlreadyRouted };
|
|
2
2
|
export { prerenderPage };
|
|
3
|
-
export { prerender404Page };
|
|
4
3
|
export { getPageContextInitEnhanced };
|
|
5
4
|
export { createPageContext };
|
|
6
5
|
export type { PageContextAfterRender };
|
|
@@ -210,187 +209,6 @@ declare function prerenderPage(pageContext: PageContextInitEnhanced & PageFiles
|
|
|
210
209
|
_urlHandler: null;
|
|
211
210
|
};
|
|
212
211
|
}>;
|
|
213
|
-
declare function prerender404Page(pageContextInit_: Record<string, unknown> | null, globalContext: GlobalContextInternal): Promise<{
|
|
214
|
-
documentHtml: string;
|
|
215
|
-
pageContextSerialized: null;
|
|
216
|
-
pageContext: {
|
|
217
|
-
_isPageContextObject: boolean;
|
|
218
|
-
isClientSide: boolean;
|
|
219
|
-
isPrerendering: boolean;
|
|
220
|
-
} & Record<string, unknown> & {
|
|
221
|
-
urlOriginal: string;
|
|
222
|
-
headersOriginal?: unknown;
|
|
223
|
-
headers?: unknown;
|
|
224
|
-
} & {
|
|
225
|
-
_objectCreatedByVike: boolean;
|
|
226
|
-
_baseServer: string;
|
|
227
|
-
_baseAssets: string;
|
|
228
|
-
_includeAssetsImportedByServer: boolean;
|
|
229
|
-
_pageFilesAll: import("../../../shared/getPageFiles.js").PageFile[];
|
|
230
|
-
_pageConfigs: import("../../../__internal/index.js").PageConfig[];
|
|
231
|
-
_pageConfigGlobal: import("../../../shared/page-configs/PageConfig.js").PageConfigGlobalRuntime;
|
|
232
|
-
_allPageIds: string[];
|
|
233
|
-
_pageRoutes: import("../../../__internal/index.js").PageRoutes;
|
|
234
|
-
_onBeforeRouteHook: import("../../../shared/hooks/getHook.js").Hook | null;
|
|
235
|
-
_globalContext: GlobalContextInternal;
|
|
236
|
-
/** @experimental This is a beta feature https://vike.dev/getGlobalContext */
|
|
237
|
-
globalContext: Pick<{
|
|
238
|
-
viteConfigRuntime: {
|
|
239
|
-
_baseViteOriginal: null | string;
|
|
240
|
-
};
|
|
241
|
-
config: import("../../../shared/page-configs/getPageConfigUserFriendly.js").PageConfigUserFriendly["config"];
|
|
242
|
-
pages: import("../../../shared/page-configs/getPageConfigUserFriendly.js").PageConfigsUserFriendly;
|
|
243
|
-
} & import("../../shared/resolveBase.js").BaseUrlsResolved & ({
|
|
244
|
-
pageFilesAll: import("../../../shared/getPageFiles.js").PageFile[];
|
|
245
|
-
pageConfigs: import("../../../__internal/index.js").PageConfig[];
|
|
246
|
-
pageConfigGlobal: import("../../../shared/page-configs/PageConfig.js").PageConfigGlobalRuntime;
|
|
247
|
-
allPageIds: string[];
|
|
248
|
-
pageRoutes: import("../../../__internal/index.js").PageRoutes;
|
|
249
|
-
onBeforeRouteHook: import("../../../shared/hooks/getHook.js").Hook | null;
|
|
250
|
-
pages: import("../../../shared/page-configs/getPageConfigUserFriendly.js").PageConfigsUserFriendly;
|
|
251
|
-
config: import("../../../types/index.js").ConfigResolved;
|
|
252
|
-
} & ({
|
|
253
|
-
isProduction: false;
|
|
254
|
-
isPrerendering: false;
|
|
255
|
-
viteConfig: import("vite").ResolvedConfig;
|
|
256
|
-
viteDevServer: import("vite").ViteDevServer;
|
|
257
|
-
assetsManifest: null;
|
|
258
|
-
} | ({
|
|
259
|
-
isProduction: true;
|
|
260
|
-
assetsManifest: import("../../shared/ViteManifest.js").ViteManifest;
|
|
261
|
-
viteDevServer: null;
|
|
262
|
-
} & ({
|
|
263
|
-
isPrerendering: false;
|
|
264
|
-
viteConfig: null;
|
|
265
|
-
} | {
|
|
266
|
-
isPrerendering: true;
|
|
267
|
-
usesClientRouter: boolean;
|
|
268
|
-
viteConfig: import("vite").ResolvedConfig;
|
|
269
|
-
})))), "pages" | "baseServer" | "baseAssets" | "config" | "assetsManifest" | "viteConfig">;
|
|
270
|
-
_pageContextInit: {
|
|
271
|
-
urlOriginal: string;
|
|
272
|
-
headersOriginal?: unknown;
|
|
273
|
-
headers?: unknown;
|
|
274
|
-
};
|
|
275
|
-
_urlRewrite: string | null;
|
|
276
|
-
_urlHandler: ((url: string) => string) | null;
|
|
277
|
-
isClientSideNavigation: boolean;
|
|
278
|
-
} & {
|
|
279
|
-
urlParsed: import("../utils.js").UrlPublic;
|
|
280
|
-
urlPathname: string;
|
|
281
|
-
url: string;
|
|
282
|
-
} & {
|
|
283
|
-
headers: Record<string, string> | null;
|
|
284
|
-
} & import("../../../shared/getPageFiles.js").PageConfigUserFriendlyOld & {
|
|
285
|
-
Page: unknown;
|
|
286
|
-
_isHtmlOnly: boolean;
|
|
287
|
-
_passToClient: string[];
|
|
288
|
-
_pageFilePathsLoaded: string[];
|
|
289
|
-
} & {
|
|
290
|
-
__getPageAssets: () => Promise<import("./getPageAssets.js").PageAsset[]>;
|
|
291
|
-
} & {
|
|
292
|
-
routeParams: Record<string, string>;
|
|
293
|
-
pageId: string;
|
|
294
|
-
_urlRewrite: null;
|
|
295
|
-
_httpRequestId: number | null;
|
|
296
|
-
_usesClientRouter: boolean;
|
|
297
|
-
_pageContextAlreadyProvidedByOnPrerenderHook?: true;
|
|
298
|
-
is404: null | boolean;
|
|
299
|
-
} & {
|
|
300
|
-
isClientSideNavigation: boolean;
|
|
301
|
-
_urlHandler: null;
|
|
302
|
-
};
|
|
303
|
-
} | {
|
|
304
|
-
documentHtml: string;
|
|
305
|
-
pageContextSerialized: string;
|
|
306
|
-
pageContext: {
|
|
307
|
-
_isPageContextObject: boolean;
|
|
308
|
-
isClientSide: boolean;
|
|
309
|
-
isPrerendering: boolean;
|
|
310
|
-
} & Record<string, unknown> & {
|
|
311
|
-
urlOriginal: string;
|
|
312
|
-
headersOriginal?: unknown;
|
|
313
|
-
headers?: unknown;
|
|
314
|
-
} & {
|
|
315
|
-
_objectCreatedByVike: boolean;
|
|
316
|
-
_baseServer: string;
|
|
317
|
-
_baseAssets: string;
|
|
318
|
-
_includeAssetsImportedByServer: boolean;
|
|
319
|
-
_pageFilesAll: import("../../../shared/getPageFiles.js").PageFile[];
|
|
320
|
-
_pageConfigs: import("../../../__internal/index.js").PageConfig[];
|
|
321
|
-
_pageConfigGlobal: import("../../../shared/page-configs/PageConfig.js").PageConfigGlobalRuntime;
|
|
322
|
-
_allPageIds: string[];
|
|
323
|
-
_pageRoutes: import("../../../__internal/index.js").PageRoutes;
|
|
324
|
-
_onBeforeRouteHook: import("../../../shared/hooks/getHook.js").Hook | null;
|
|
325
|
-
_globalContext: GlobalContextInternal;
|
|
326
|
-
/** @experimental This is a beta feature https://vike.dev/getGlobalContext */
|
|
327
|
-
globalContext: Pick<{
|
|
328
|
-
viteConfigRuntime: {
|
|
329
|
-
_baseViteOriginal: null | string;
|
|
330
|
-
};
|
|
331
|
-
config: import("../../../shared/page-configs/getPageConfigUserFriendly.js").PageConfigUserFriendly["config"];
|
|
332
|
-
pages: import("../../../shared/page-configs/getPageConfigUserFriendly.js").PageConfigsUserFriendly;
|
|
333
|
-
} & import("../../shared/resolveBase.js").BaseUrlsResolved & ({
|
|
334
|
-
pageFilesAll: import("../../../shared/getPageFiles.js").PageFile[];
|
|
335
|
-
pageConfigs: import("../../../__internal/index.js").PageConfig[];
|
|
336
|
-
pageConfigGlobal: import("../../../shared/page-configs/PageConfig.js").PageConfigGlobalRuntime;
|
|
337
|
-
allPageIds: string[];
|
|
338
|
-
pageRoutes: import("../../../__internal/index.js").PageRoutes;
|
|
339
|
-
onBeforeRouteHook: import("../../../shared/hooks/getHook.js").Hook | null;
|
|
340
|
-
pages: import("../../../shared/page-configs/getPageConfigUserFriendly.js").PageConfigsUserFriendly;
|
|
341
|
-
config: import("../../../types/index.js").ConfigResolved;
|
|
342
|
-
} & ({
|
|
343
|
-
isProduction: false;
|
|
344
|
-
isPrerendering: false;
|
|
345
|
-
viteConfig: import("vite").ResolvedConfig;
|
|
346
|
-
viteDevServer: import("vite").ViteDevServer;
|
|
347
|
-
assetsManifest: null;
|
|
348
|
-
} | ({
|
|
349
|
-
isProduction: true;
|
|
350
|
-
assetsManifest: import("../../shared/ViteManifest.js").ViteManifest;
|
|
351
|
-
viteDevServer: null;
|
|
352
|
-
} & ({
|
|
353
|
-
isPrerendering: false;
|
|
354
|
-
viteConfig: null;
|
|
355
|
-
} | {
|
|
356
|
-
isPrerendering: true;
|
|
357
|
-
usesClientRouter: boolean;
|
|
358
|
-
viteConfig: import("vite").ResolvedConfig;
|
|
359
|
-
})))), "pages" | "baseServer" | "baseAssets" | "config" | "assetsManifest" | "viteConfig">;
|
|
360
|
-
_pageContextInit: {
|
|
361
|
-
urlOriginal: string;
|
|
362
|
-
headersOriginal?: unknown;
|
|
363
|
-
headers?: unknown;
|
|
364
|
-
};
|
|
365
|
-
_urlRewrite: string | null;
|
|
366
|
-
_urlHandler: ((url: string) => string) | null;
|
|
367
|
-
isClientSideNavigation: boolean;
|
|
368
|
-
} & {
|
|
369
|
-
urlParsed: import("../utils.js").UrlPublic;
|
|
370
|
-
urlPathname: string;
|
|
371
|
-
url: string;
|
|
372
|
-
} & {
|
|
373
|
-
headers: Record<string, string> | null;
|
|
374
|
-
} & import("../../../shared/getPageFiles.js").PageConfigUserFriendlyOld & {
|
|
375
|
-
Page: unknown;
|
|
376
|
-
_isHtmlOnly: boolean;
|
|
377
|
-
_passToClient: string[];
|
|
378
|
-
_pageFilePathsLoaded: string[];
|
|
379
|
-
} & {
|
|
380
|
-
__getPageAssets: () => Promise<import("./getPageAssets.js").PageAsset[]>;
|
|
381
|
-
} & {
|
|
382
|
-
routeParams: Record<string, string>;
|
|
383
|
-
pageId: string;
|
|
384
|
-
_urlRewrite: null;
|
|
385
|
-
_httpRequestId: number | null;
|
|
386
|
-
_usesClientRouter: boolean;
|
|
387
|
-
_pageContextAlreadyProvidedByOnPrerenderHook?: true;
|
|
388
|
-
is404: null | boolean;
|
|
389
|
-
} & {
|
|
390
|
-
isClientSideNavigation: boolean;
|
|
391
|
-
_urlHandler: null;
|
|
392
|
-
};
|
|
393
|
-
} | null>;
|
|
394
212
|
type PageContextInitEnhanced = Awaited<ReturnType<typeof getPageContextInitEnhanced>>;
|
|
395
213
|
declare function getPageContextInitEnhanced(pageContextInit: {
|
|
396
214
|
urlOriginal: string;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { renderPageAlreadyRouted };
|
|
2
2
|
export { prerenderPage };
|
|
3
|
-
export { prerender404Page };
|
|
4
3
|
export { getPageContextInitEnhanced };
|
|
5
4
|
export { createPageContext };
|
|
6
5
|
import { getErrorPageId } from '../../../shared/error-page.js';
|
|
@@ -80,28 +79,6 @@ async function prerenderPage(pageContext) {
|
|
|
80
79
|
return { documentHtml, pageContextSerialized, pageContext };
|
|
81
80
|
}
|
|
82
81
|
}
|
|
83
|
-
async function prerender404Page(pageContextInit_, globalContext) {
|
|
84
|
-
const errorPageId = getErrorPageId(globalContext.pageFilesAll, globalContext.pageConfigs);
|
|
85
|
-
if (!errorPageId) {
|
|
86
|
-
return null;
|
|
87
|
-
}
|
|
88
|
-
// A URL is required for `viteDevServer.transformIndexHtml(url,html)`
|
|
89
|
-
const pageContextInit = { urlOriginal: '/fake-404-url' };
|
|
90
|
-
objectAssign(pageContextInit, pageContextInit_);
|
|
91
|
-
const pageContext = await getPageContextInitEnhanced(pageContextInit, globalContext, true);
|
|
92
|
-
objectAssign(pageContext, {
|
|
93
|
-
pageId: errorPageId,
|
|
94
|
-
_httpRequestId: null,
|
|
95
|
-
_urlRewrite: null,
|
|
96
|
-
is404: true,
|
|
97
|
-
routeParams: {},
|
|
98
|
-
// `prerender404Page()` is about generating `dist/client/404.html` for static hosts; there is no Client Routing.
|
|
99
|
-
_usesClientRouter: false,
|
|
100
|
-
_debugRouteMatches: []
|
|
101
|
-
});
|
|
102
|
-
objectAssign(pageContext, await loadUserFilesServerSide(pageContext));
|
|
103
|
-
return prerenderPage(pageContext);
|
|
104
|
-
}
|
|
105
82
|
async function getPageContextInitEnhanced(pageContextInit, globalContext, isPrerendering, { ssr: { urlRewrite, urlHandler, isClientSideNavigation } = {
|
|
106
83
|
urlRewrite: null,
|
|
107
84
|
urlHandler: null,
|
|
@@ -67,7 +67,7 @@ async function getPageContextFromHook(onBeforeRouteHook, pageContext) {
|
|
|
67
67
|
if (hasProp(hookReturn.pageContext, 'urlLogical')) {
|
|
68
68
|
assertUsageUrlPathnameAbsolute(
|
|
69
69
|
// We skip validation and type-cast instead of assertUsage() in order to save client-side KBs
|
|
70
|
-
hookReturn.pageContext.urlLogical, `${errPrefix} returned ${pc.cyan('{ pageContext: { urlLogical } }')}
|
|
70
|
+
hookReturn.pageContext.urlLogical, `${errPrefix} returned ${pc.cyan('{ pageContext: { urlLogical } }')} and ${pc.cyan('urlLogical')}`);
|
|
71
71
|
}
|
|
72
72
|
assertPageContextProvidedByUser(hookReturn.pageContext, {
|
|
73
73
|
hookFilePath: onBeforeRouteHook.hookFilePath,
|
|
@@ -30,4 +30,4 @@ type RouteMatch = {
|
|
|
30
30
|
routeParams: Record<string, string>;
|
|
31
31
|
};
|
|
32
32
|
type RouteMatches = 'CUSTOM_ROUTING' | RouteMatch[];
|
|
33
|
-
declare function route(pageContext: PageContextForRoute): Promise<PageContextFromRoute>;
|
|
33
|
+
declare function route(pageContext: PageContextForRoute, skipOnBeforeRouteHook?: true): Promise<PageContextFromRoute>;
|
|
@@ -13,23 +13,25 @@ import { resolveRouteFunction } from './resolveRouteFunction.js';
|
|
|
13
13
|
import { executeOnBeforeRouteHook } from './executeOnBeforeRouteHook.js';
|
|
14
14
|
import { debug } from './debug.js';
|
|
15
15
|
import pc from '@brillout/picocolors';
|
|
16
|
-
async function route(pageContext) {
|
|
16
|
+
async function route(pageContext, skipOnBeforeRouteHook) {
|
|
17
17
|
debug('Pages routes:', pageContext._pageRoutes);
|
|
18
18
|
assertPageContextUrl(pageContext);
|
|
19
19
|
const pageContextFromRoute = {};
|
|
20
20
|
// onBeforeRoute()
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (pageContextFromOnBeforeRouteHook
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
if (!skipOnBeforeRouteHook) {
|
|
22
|
+
const pageContextFromOnBeforeRouteHook = await executeOnBeforeRouteHook(pageContext);
|
|
23
|
+
if (pageContextFromOnBeforeRouteHook) {
|
|
24
|
+
if (pageContextFromOnBeforeRouteHook._routingProvidedByOnBeforeRouteHook) {
|
|
25
|
+
assert(pageContextFromOnBeforeRouteHook.pageId);
|
|
26
|
+
return pageContextFromOnBeforeRouteHook;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
objectAssign(pageContextFromRoute, pageContextFromOnBeforeRouteHook);
|
|
30
|
+
}
|
|
29
31
|
}
|
|
32
|
+
// We take into account pageContext.urlLogical set by onBeforeRoute()
|
|
33
|
+
objectAssign(pageContext, pageContextFromOnBeforeRouteHook);
|
|
30
34
|
}
|
|
31
|
-
// We take into account pageContext.urlLogical set by onBeforeRoute()
|
|
32
|
-
objectAssign(pageContext, pageContextFromOnBeforeRouteHook);
|
|
33
35
|
// Vike's routing
|
|
34
36
|
const allPageIds = pageContext._allPageIds;
|
|
35
37
|
assertUsage(allPageIds.length > 0, 'No page found. You must create at least one page.');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.227-commit-
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.227-commit-25aa0f8";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.227-commit-
|
|
2
|
+
export const PROJECT_VERSION = '0.4.227-commit-25aa0f8';
|
|
@@ -7,12 +7,12 @@ import { assert } from './assert.js';
|
|
|
7
7
|
// We can't use a RegExp:
|
|
8
8
|
// - Needs to work with Micromatch: https://github.com/micromatch/micromatch because:
|
|
9
9
|
// - Vite's `import.meta.glob()` uses Micromatch
|
|
10
|
-
// - We need this to be a
|
|
10
|
+
// - We need this to be a allowlist because:
|
|
11
11
|
// - A pattern `*([a-zA-Z0-9]` doesn't work.
|
|
12
12
|
// - Because of ReScript: `.res` are ReScript source files which need to be ignored. (The ReScript compiler generates `.js` files alongside `.res` files.)
|
|
13
|
-
// -
|
|
14
|
-
// - We cannot implement a
|
|
15
|
-
// - A post `import.meta.glob()`
|
|
13
|
+
// - Block listing doesn't work.
|
|
14
|
+
// - We cannot implement a blocklist with a glob pattern.
|
|
15
|
+
// - A post `import.meta.glob()` blocklist filtering doesn't work because Vite would still process the files (e.g. including them in the bundle).
|
|
16
16
|
// prettier-ignore
|
|
17
17
|
// biome-ignore format:
|
|
18
18
|
const extJavaScript = [
|
|
@@ -182,14 +182,14 @@ function parseProtocol(uri) {
|
|
|
182
182
|
return { protocol, uriWithoutProtocol };
|
|
183
183
|
}
|
|
184
184
|
function isUrlProtocol(protocol) {
|
|
185
|
-
// Is there an
|
|
186
|
-
// - If the
|
|
187
|
-
const
|
|
185
|
+
// Is there an alternative to having a blocklist?
|
|
186
|
+
// - If the blocklist becomes too big, maybe use a allowlist instead ['tauri://', 'file://', 'capacitor://', 'http://', 'https://']
|
|
187
|
+
const blocklist = [
|
|
188
188
|
// https://docs.ipfs.tech/how-to/address-ipfs-on-web
|
|
189
189
|
'ipfs://',
|
|
190
190
|
'ipns://'
|
|
191
191
|
];
|
|
192
|
-
if (
|
|
192
|
+
if (blocklist.includes(protocol))
|
|
193
193
|
return false;
|
|
194
194
|
return protocol.endsWith('://');
|
|
195
195
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export { preservePropertyGetters };
|
|
2
|
+
import { assert } from './assert.js';
|
|
3
|
+
function preservePropertyGetters(objOriginal) {
|
|
4
|
+
// Store original getter descriptors
|
|
5
|
+
const getters = Object.fromEntries(Object.entries(Object.getOwnPropertyDescriptors(objOriginal)).filter(([_, desc]) => 'get' in desc));
|
|
6
|
+
// Make getters non-enumerable
|
|
7
|
+
for (const [key, desc] of Object.entries(getters)) {
|
|
8
|
+
Object.defineProperty(objOriginal, key, { ...desc, enumerable: false });
|
|
9
|
+
}
|
|
10
|
+
const restorePropertyGetters = function () {
|
|
11
|
+
const objCopy = this;
|
|
12
|
+
delete objOriginal._restorePropertyGetters;
|
|
13
|
+
delete objCopy._restorePropertyGetters;
|
|
14
|
+
for (const [key, desc] of Object.entries(getters)) {
|
|
15
|
+
if (objCopy !== objOriginal) {
|
|
16
|
+
assert(!(key in objCopy));
|
|
17
|
+
Object.defineProperty(objCopy, key, desc); // Add property getters to copy
|
|
18
|
+
}
|
|
19
|
+
assert(key in objOriginal);
|
|
20
|
+
Object.defineProperty(objOriginal, key, desc); // Restore original `enumerable` value
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
Object.defineProperty(objOriginal, '_restorePropertyGetters', {
|
|
24
|
+
value: restorePropertyGetters,
|
|
25
|
+
enumerable: true,
|
|
26
|
+
configurable: true
|
|
27
|
+
});
|
|
28
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { rollupSourceMapRemove };
|
|
2
|
+
export { rollupSourceMapPassthrough };
|
|
3
3
|
/** Remove entire source mapping, to save KBs. */
|
|
4
|
-
declare function
|
|
4
|
+
declare function rollupSourceMapRemove(code: string): {
|
|
5
5
|
code: string;
|
|
6
6
|
map: {
|
|
7
7
|
mappings: '';
|
|
8
8
|
};
|
|
9
9
|
};
|
|
10
10
|
/** Don't provide any source map, pass through current source map instead. */
|
|
11
|
-
declare function
|
|
11
|
+
declare function rollupSourceMapPassthrough(code: string): {
|
|
12
12
|
code: string;
|
|
13
13
|
map: null;
|
|
14
14
|
};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { rollupSourceMapRemove };
|
|
2
|
+
export { rollupSourceMapPassthrough };
|
|
3
3
|
// https://rollupjs.org/guide/en/#source-code-transformations
|
|
4
4
|
/** Remove entire source mapping, to save KBs. */
|
|
5
|
-
function
|
|
5
|
+
function rollupSourceMapRemove(code) {
|
|
6
6
|
return {
|
|
7
7
|
code,
|
|
8
8
|
map: { mappings: '' }
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
11
|
/** Don't provide any source map, pass through current source map instead. */
|
|
12
|
-
function
|
|
12
|
+
function rollupSourceMapPassthrough(code) {
|
|
13
13
|
return {
|
|
14
14
|
code,
|
|
15
15
|
map: null
|
package/package.json
CHANGED