@fedify/nuxt 2.2.0-dev.885 → 2.2.0-dev.918

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.
@@ -0,0 +1,37 @@
1
+ //#region src/runtime/server/lib.ts
2
+ const NOT_ACCEPTABLE_BODY = "Not acceptable";
3
+ const DEFERRED_NOT_ACCEPTABLE_CONTEXT_KEY = "__fedify_deferred_not_acceptable__";
4
+ //#endregion
5
+ //#region src/runtime/server/logic.ts
6
+ const DUMMY_NOT_FOUND_RESPONSE = new Response("", { status: 404 });
7
+ const createNotAcceptableResponse = () => new Response(NOT_ACCEPTABLE_BODY, {
8
+ status: 406,
9
+ headers: {
10
+ "Content-Type": "text/plain",
11
+ Vary: "Accept"
12
+ }
13
+ });
14
+ async function fetchWithFedify(fetcher, request, contextData) {
15
+ let notAcceptableResponse = null;
16
+ const response = await fetcher(request, {
17
+ contextData,
18
+ onNotFound: () => DUMMY_NOT_FOUND_RESPONSE,
19
+ onNotAcceptable: () => {
20
+ notAcceptableResponse = createNotAcceptableResponse();
21
+ return notAcceptableResponse;
22
+ }
23
+ });
24
+ if (response === DUMMY_NOT_FOUND_RESPONSE) return { kind: "not-found" };
25
+ if (notAcceptableResponse != null && response === notAcceptableResponse) return { kind: "not-acceptable" };
26
+ return {
27
+ kind: "handled",
28
+ response
29
+ };
30
+ }
31
+ function resolveDeferredNotAcceptable(isDeferred, frameworkStatus, routeHandled) {
32
+ if (!isDeferred || frameworkStatus !== 404) return void 0;
33
+ if (routeHandled) return void 0;
34
+ return createNotAcceptableResponse();
35
+ }
36
+ //#endregion
37
+ export { NOT_ACCEPTABLE_BODY as i, resolveDeferredNotAcceptable as n, DEFERRED_NOT_ACCEPTABLE_CONTEXT_KEY as r, fetchWithFedify as t };
@@ -0,0 +1,60 @@
1
+ //#region src/runtime/server/lib.ts
2
+ const NOT_ACCEPTABLE_BODY = "Not acceptable";
3
+ const DEFERRED_NOT_ACCEPTABLE_CONTEXT_KEY = "__fedify_deferred_not_acceptable__";
4
+ //#endregion
5
+ //#region src/runtime/server/logic.ts
6
+ const DUMMY_NOT_FOUND_RESPONSE = new Response("", { status: 404 });
7
+ const createNotAcceptableResponse = () => new Response(NOT_ACCEPTABLE_BODY, {
8
+ status: 406,
9
+ headers: {
10
+ "Content-Type": "text/plain",
11
+ Vary: "Accept"
12
+ }
13
+ });
14
+ async function fetchWithFedify(fetcher, request, contextData) {
15
+ let notAcceptableResponse = null;
16
+ const response = await fetcher(request, {
17
+ contextData,
18
+ onNotFound: () => DUMMY_NOT_FOUND_RESPONSE,
19
+ onNotAcceptable: () => {
20
+ notAcceptableResponse = createNotAcceptableResponse();
21
+ return notAcceptableResponse;
22
+ }
23
+ });
24
+ if (response === DUMMY_NOT_FOUND_RESPONSE) return { kind: "not-found" };
25
+ if (notAcceptableResponse != null && response === notAcceptableResponse) return { kind: "not-acceptable" };
26
+ return {
27
+ kind: "handled",
28
+ response
29
+ };
30
+ }
31
+ function resolveDeferredNotAcceptable(isDeferred, frameworkStatus, routeHandled) {
32
+ if (!isDeferred || frameworkStatus !== 404) return void 0;
33
+ if (routeHandled) return void 0;
34
+ return createNotAcceptableResponse();
35
+ }
36
+ //#endregion
37
+ Object.defineProperty(exports, "DEFERRED_NOT_ACCEPTABLE_CONTEXT_KEY", {
38
+ enumerable: true,
39
+ get: function() {
40
+ return DEFERRED_NOT_ACCEPTABLE_CONTEXT_KEY;
41
+ }
42
+ });
43
+ Object.defineProperty(exports, "NOT_ACCEPTABLE_BODY", {
44
+ enumerable: true,
45
+ get: function() {
46
+ return NOT_ACCEPTABLE_BODY;
47
+ }
48
+ });
49
+ Object.defineProperty(exports, "fetchWithFedify", {
50
+ enumerable: true,
51
+ get: function() {
52
+ return fetchWithFedify;
53
+ }
54
+ });
55
+ Object.defineProperty(exports, "resolveDeferredNotAcceptable", {
56
+ enumerable: true,
57
+ get: function() {
58
+ return resolveDeferredNotAcceptable;
59
+ }
60
+ });
package/dist/mod.cjs CHANGED
@@ -7,6 +7,9 @@ function resolveModulePath(modulePath, aliases, rootDir) {
7
7
  if (resolved.startsWith("./") || resolved.startsWith("../")) return (0, node_path.resolve)(rootDir, resolved);
8
8
  return resolved;
9
9
  }
10
+ function resolveRuntimeServerPath(resolver, fileName) {
11
+ return resolver.resolve(`../dist/runtime/server/${fileName}`);
12
+ }
10
13
  function buildContextFactoryResolver(contextDataFactoryModule) {
11
14
  if (contextDataFactoryModule == null) return "const contextDataFactory = undefined;";
12
15
  return `
@@ -42,10 +45,12 @@ const fedifyNuxtModule = (0, _nuxt_kit.defineNuxtModule)({
42
45
  const federationModule = resolveModulePath(options.federationModule, nuxt.options.alias, rootDir);
43
46
  const contextDataFactoryModule = options.contextDataFactoryModule == null ? void 0 : resolveModulePath(options.contextDataFactoryModule, nuxt.options.alias, rootDir);
44
47
  const middlewareFilename = "fedify-nuxt-options.mjs";
48
+ const middlewareModule = resolveRuntimeServerPath(resolver, "middleware.js");
49
+ const pluginModule = resolveRuntimeServerPath(resolver, "plugin.js");
45
50
  (0, _nuxt_kit.addServerTemplate)({
46
51
  filename: middlewareFilename,
47
52
  getContents: () => {
48
- const imports = [`import * as federationModule from ${JSON.stringify(federationModule)};`, `import { createFedifyMiddleware } from ${JSON.stringify(resolver.resolve("../src/runtime/server/middleware.ts"))};`];
53
+ const imports = [`import * as federationModule from ${JSON.stringify(federationModule)};`, `import { createFedifyMiddleware } from ${JSON.stringify(middlewareModule)};`];
49
54
  if (contextDataFactoryModule != null) imports.push(`import * as contextFactoryModule from ${JSON.stringify(contextDataFactoryModule)};`);
50
55
  return [
51
56
  ...imports,
@@ -61,7 +66,7 @@ const fedifyNuxtModule = (0, _nuxt_kit.defineNuxtModule)({
61
66
  middleware: true,
62
67
  handler: middlewareFilename
63
68
  });
64
- (0, _nuxt_kit.addServerPlugin)(resolver.resolve("../src/runtime/server/plugin.ts"));
69
+ (0, _nuxt_kit.addServerPlugin)(pluginModule);
65
70
  }
66
71
  });
67
72
  //#endregion