Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@gracile/engine

Package Overview
Dependencies
Maintainers
0
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gracile/engine - npm Package Compare versions

Comparing version 0.2.0-next.2 to 0.2.0-next.3

4

dist/build/static.d.ts
import type { ViteDevServer } from 'vite';
import type { GracileConfig } from '../user-config.js';
export interface RenderedRouteDefinition {

@@ -9,6 +10,7 @@ absoluteId: string;

}
export declare function renderRoutes({ vite, serverMode, root, }: {
export declare function renderRoutes({ vite, serverMode, root, gracileConfig, }: {
vite: ViteDevServer;
serverMode: boolean;
root?: string;
gracileConfig: GracileConfig;
}): Promise<{

@@ -15,0 +17,0 @@ routes: import("../routes/route.js").RoutesManifest;

@@ -20,6 +20,6 @@ import { Buffer } from 'node:buffer';

}
export async function renderRoutes({ vite, serverMode, root = process.cwd(), }) {
export async function renderRoutes({ vite, serverMode, root = process.cwd(), gracileConfig, }) {
logger.info(c.green('Rendering routes…'), { timestamp: true });
// MARK: Collect
const routes = await collectRoutes(root /* vite */);
const routes = await collectRoutes(root, gracileConfig.routes?.exclude);
const renderedRoutes = [];

@@ -56,5 +56,7 @@ // MARK: Iterate modules

: pathnameWithParams.slice(1);
const name = path.join(base, isErrorPage
let name = path.join(base, isErrorPage
? `${pathnameWithParams.split('/').at(-2)?.replace('__', '')}.html`
: 'index.html');
if (name === '404/index.html')
name = '404.html';
const url = new URL(pathnameWithParams, 'http://gracile-static');

@@ -61,0 +63,0 @@ // MARK: Render

import { type ViteDevServer } from 'vite';
import { type GracileAsyncMiddleware } from '../server/request.js';
export declare function createDevHandler({ vite, }: {
import type { GracileConfig } from '../user-config.js';
export declare function createDevHandler({ vite, gracileConfig, }: {
vite: ViteDevServer;
gracileConfig: GracileConfig;
}): Promise<{

@@ -6,0 +8,0 @@ handler: GracileAsyncMiddleware;

@@ -6,6 +6,6 @@ import { logger } from '@gracile/internal-utils/logger';

import { createGracileMiddleware, } from '../server/request.js';
export async function createDevHandler({ vite, }) {
export async function createDevHandler({ vite, gracileConfig, }) {
const root = vite.config.root;
logger.info(c.dim('\nCreating handler…'), { timestamp: true });
const routes = await collectRoutes(root /* vite */);
const routes = await collectRoutes(root, gracileConfig.routes?.exclude);
vite.watcher.on('all', (event, file) => {

@@ -18,3 +18,3 @@ // console.log({ event });

)
collectRoutes(root /* { file, event } */ /* , vite */)
collectRoutes(root, gracileConfig.routes?.exclude)
.then(() => {

@@ -21,0 +21,0 @@ vite.hot.send('vite:invalidate');

@@ -21,2 +21,3 @@ import { readFile } from 'node:fs/promises';

let root = null;
const gracileConfig = config || {};
return [

@@ -39,3 +40,6 @@ {

// ---
const { handler } = await createDevHandler({ vite: server });
const { handler } = await createDevHandler({
vite: server,
gracileConfig,
});
return () => {

@@ -60,3 +64,3 @@ server.middlewares.use((req, res, next) => {

root: viteConfig.root || process.cwd(),
_config: {},
gracileConfig,
serverMode: outputMode === 'server',

@@ -63,0 +67,0 @@ });

import type * as R from './route.js';
export declare function collectRoutes(root: string): Promise<R.RoutesManifest>;
export declare function collectRoutes(root: string, excludePatterns?: string[]): Promise<R.RoutesManifest>;
//# sourceMappingURL=collect.d.ts.map

@@ -52,3 +52,3 @@ import { join } from 'node:path';

const routes = new Map();
export async function collectRoutes(root /* vite: ViteDevServer */) {
export async function collectRoutes(root /* vite: ViteDevServer */, excludePatterns = []) {
routes.clear();

@@ -70,2 +70,3 @@ const routesFolder = 'src/routes';

'**/.*',
...excludePatterns,
]);

@@ -78,6 +79,3 @@ const serverEntrypoints = allFilesInRoutes.filter((f) => serverEntrypointsFilter(f));

.map((r) => r.route);
const serverPageClientAssetsFilter = createFilter([
'**/*.client.{js,ts}',
'**/*.{css,scss,sass,less,styl,stylus}',
]);
const serverPageClientAssetsFilter = createFilter(['**/*.client.{js,ts}', '**/*.{css,scss,sass,less,styl,stylus}'], [...excludePatterns]);
const serverPageClientAssets = allFilesInRoutes.filter((f) => serverPageClientAssetsFilter(f));

@@ -84,0 +82,0 @@ logger.info(`\n${c.underline(`Found ${c.bold('routes')}`)}:\n` +

@@ -15,3 +15,3 @@ import { Readable } from 'node:stream';

errorPageHtml = await vite.transformIndexHtml(urlPath, errorPageHtml);
return errorPageHtml;
return { errorPageHtml, headers: { 'Content-Type': 'text-html' } };
}

@@ -47,4 +47,5 @@ const middleware = async (request, locals) => {

const message = `404 not found!\n\n---\n\nCreate a /src/routes/404.{js,ts} to get a custom page.\n${method} - ${urlPath}`;
const errorPage404 = await createErrorPage(urlPath, new Error(message));
return new Response(errorPage404, {
const { errorPageHtml, headers } = await createErrorPage(urlPath, new Error(message));
return new Response(errorPageHtml, {
headers,
status: 404,

@@ -176,4 +177,5 @@ statusText: '404 not found!',

vite.ssrFixStacktrace(error);
const ultimateErrorPage = await createErrorPage('__gracile_error', error);
const { errorPageHtml: ultimateErrorPage, headers } = await createErrorPage('__gracile_error', error);
return new Response(String(ultimateErrorPage), {
headers,
status: 500,

@@ -180,0 +182,0 @@ statusText: 'Gracile middleware error',

@@ -12,3 +12,6 @@ import type { Connect } from 'vite';

};
routes?: {
exclude?: string[];
};
}
//# sourceMappingURL=user-config.d.ts.map
import { type ViteDevServer } from 'vite';
import type { GracileConfig } from '../../user-config.js';
export declare const buildRoutes: ({ viteServerForBuild, root, _config, serverMode, }: {
export declare const buildRoutes: ({ viteServerForBuild, root, gracileConfig, serverMode, }: {
viteServerForBuild: ViteDevServer;
root: string;
_config: GracileConfig;
gracileConfig: GracileConfig;
serverMode?: boolean;

@@ -8,0 +8,0 @@ }) => Promise<{

import {} from 'vite';
import { renderRoutes } from '../../build/static.js';
import { REGEX_TAG_LINK, REGEX_TAG_SCRIPT, } from '../../render/route-template.js';
export const buildRoutes = async ({ viteServerForBuild, root, _config, serverMode = false, }) => {
export const buildRoutes = async ({ viteServerForBuild, root, gracileConfig, serverMode = false, }) => {
// TODO: extract upstream, return just the plugins

@@ -10,2 +10,3 @@ const { renderedRoutes, routes } = await renderRoutes({

root,
gracileConfig,
});

@@ -12,0 +13,0 @@ const inputList = renderedRoutes

{
"name": "@gracile/engine",
"version": "0.2.0-next.2",
"version": "0.2.0-next.3",
"description": "A thin, full-stack, web framework",

@@ -78,3 +78,3 @@ "keywords": [

},
"gitHead": "6305693cb9f62e3ffef175e26660bf04b493bccc"
"gitHead": "48a2950f61cfb2d0aec50f5539ea90f7905ad6a8"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc