inertjs-core 1.0.0-beta.2 → 1.0.0-beta.4

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/package.json CHANGED
@@ -1,12 +1,19 @@
1
1
  {
2
2
  "name": "inertjs-core",
3
- "version": "1.0.0-beta.2",
3
+ "version": "1.0.0-beta.4",
4
4
  "type": "module",
5
5
  "main": "src/index.js",
6
6
  "dependencies": {
7
- "inertjs-optimizer": "^1.0.0-beta.2"
7
+ "inertjs-optimizer": "^1.0.0-beta.4",
8
+ "inertjs-vector": "^1.0.0-beta.4",
9
+ "inertjs-shield": "^1.0.0-beta.4",
10
+ "inertjs-router": "^1.0.0-beta.4"
8
11
  },
9
12
  "engines": {
10
13
  "node": ">=22.0.0"
14
+ },
15
+ "exports": {
16
+ ".": "./src/index.js",
17
+ "./*": "./*"
11
18
  }
12
19
  }
package/src/pipeline.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { Readable } from 'node:stream';
2
2
  import { pathToFileURL } from 'node:url';
3
3
  import { getScope } from './scope.js';
4
- import { renderToStream } from '../../vector/src/stream.js';
5
- import { raw } from '../../vector/src/index.js';
6
- import { getCspHeader, validateCsrfToken } from '../../shield/src/index.js';
4
+ import { renderToStream } from 'inertjs-vector/src/stream.js';
5
+ import { raw } from 'inertjs-vector/src/index.js';
6
+ import { getCspHeader, validateCsrfToken } from 'inertjs-shield/src/index.js';
7
7
  import { serveStatic } from './static.js';
8
8
  import path from 'node:path';
9
9
  import fs from 'node:fs/promises';
@@ -224,6 +224,11 @@ export async function handleRequest(req, res, config, trie) {
224
224
  if (fluxModule.flux) {
225
225
  data = await fluxModule.flux({ req, params, scope });
226
226
  }
227
+ } else if (route.view) {
228
+ const viewModule = await import(pathToFileURL(route.view).href);
229
+ if (viewModule.flux) {
230
+ data = await viewModule.flux({ req, params, scope });
231
+ }
227
232
  }
228
233
 
229
234
  const isPulse = req.headers['accept']?.includes('application/vnd.inert.pulse+json');
@@ -253,7 +258,7 @@ export async function handleRequest(req, res, config, trie) {
253
258
  let finalResult = viewResult;
254
259
 
255
260
  if (isPulse) {
256
- const { resolveToString } = await import('../../vector/src/index.js');
261
+ const { resolveToString } = await import('inertjs-vector/src/index.js');
257
262
  const viewHtml = await resolveToString(viewResult);
258
263
 
259
264
  res.writeHead(200, {
@@ -285,7 +290,7 @@ export async function handleRequest(req, res, config, trie) {
285
290
 
286
291
  // 6. Stream to response
287
292
  if (isFlashMode && !isPulse && req.method === 'GET') {
288
- const { resolveToString } = await import('../../vector/src/index.js');
293
+ const { resolveToString } = await import('inertjs-vector/src/index.js');
289
294
  const finalHtml = await resolveToString(finalResult);
290
295
  // Cache it for the next request
291
296
  flashCache.set(url.pathname, finalHtml);
package/src/server.js CHANGED
@@ -3,7 +3,7 @@ import http2 from 'node:http2';
3
3
  import crypto from 'node:crypto';
4
4
  import { requestScope } from './scope.js';
5
5
  import { handleRequest } from './pipeline.js';
6
- import { RateLimiter } from '../../shield/src/index.js';
6
+ import { RateLimiter } from 'inertjs-shield/src/index.js';
7
7
 
8
8
  export class CoreServer {
9
9
  /**
@@ -6,7 +6,7 @@ import path from 'node:path';
6
6
  import os from 'node:os';
7
7
  import { pathToFileURL } from 'node:url';
8
8
  import { CoreServer } from '../src/server.js';
9
- import { RouterTrie } from '../../router/src/trie.js';
9
+ import { RouterTrie } from 'inertjs-router/src/trie.js';
10
10
 
11
11
  function fetchH2C(url) {
12
12
  return new Promise((resolve, reject) => {
@@ -3,7 +3,7 @@ import assert from 'node:assert';
3
3
  import http2 from 'node:http2';
4
4
  import crypto from 'node:crypto';
5
5
  import { CoreServer } from '../src/server.js';
6
- import { RouterTrie } from '../../router/src/index.js';
6
+ import { RouterTrie } from 'inertjs-router/src/index.js';
7
7
 
8
8
  test('CoreServer Rate Limiter E2E (100 reqs/sec limit)', async (t) => {
9
9
  const trie = new RouterTrie();