@foxford/den 3.2.5 → 3.4.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/README.mdx +20 -6
- package/adapter.d.cts +1 -1
- package/adapter.d.ts +1 -1
- package/{chunk-SOH2TL2N.js → chunk-LBXA2QIB.js} +62 -6
- package/{chunk-XDM6J4LJ.cjs → chunk-M5CR4TJC.cjs} +63 -7
- package/{define-repository-q_T4hqeP.d.ts → define-repository-AO7JI6Cb.d.ts} +1 -1
- package/{define-repository-CwAXed2X.d.cts → define-repository-C0MI-J32.d.cts} +1 -1
- package/{define-slot-DouHW8RK.d.cts → define-slot-BEeHNEph.d.cts} +1 -1
- package/{define-slot-TkqbLySB.d.ts → define-slot-CdWdFM16.d.ts} +1 -1
- package/define.d.cts +3 -3
- package/define.d.ts +3 -3
- package/{descriptor-tWPa9j-x.d.ts → descriptor-CLIZRmY4.d.ts} +13 -2
- package/{descriptor-w8oxeIAe.d.cts → descriptor-Ced0k1__.d.cts} +13 -2
- package/index.d.cts +6 -6
- package/index.d.ts +6 -6
- package/island/index.cjs +33 -3
- package/island/index.d.cts +94 -6
- package/island/index.d.ts +94 -6
- package/island/index.js +32 -2
- package/package.json +16 -16
- package/{routes-B0hDrkiF.d.cts → routes-BvV405k4.d.cts} +1 -1
- package/{routes-0uXJ0fux.d.ts → routes-Di3K_0uQ.d.ts} +1 -1
- package/serve/index.cjs +48 -41
- package/serve/index.d.cts +4 -4
- package/serve/index.d.ts +4 -4
- package/serve/index.js +46 -39
- package/{types-Dx5qGiwk.d.cts → types-BxMQ-VOd.d.cts} +1 -1
- package/{types-Dx5qGiwk.d.ts → types-BxMQ-VOd.d.ts} +1 -1
- package/{view-adapter-BV62bdhM.d.ts → view-adapter-BTaoZgTQ.d.ts} +2 -2
- package/{view-adapter-DF1me25J.d.cts → view-adapter-D8I06K7s.d.cts} +2 -2
package/serve/index.js
CHANGED
|
@@ -4,8 +4,9 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
matchRoute,
|
|
6
6
|
normalizeRoutes,
|
|
7
|
+
parseCookieHeader,
|
|
7
8
|
renderApp
|
|
8
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-LBXA2QIB.js";
|
|
9
10
|
import "../chunk-E23E2VUC.js";
|
|
10
11
|
import "../chunk-3RX2OSUL.js";
|
|
11
12
|
import {
|
|
@@ -78,20 +79,6 @@ function matchClaim(app, pathname) {
|
|
|
78
79
|
}
|
|
79
80
|
return (_b = (_a = matchRoute(app.routes, pathname)) == null ? void 0 : _a.params) != null ? _b : null;
|
|
80
81
|
}
|
|
81
|
-
function parseCookies(header) {
|
|
82
|
-
const cookies = {};
|
|
83
|
-
for (const part of (header != null ? header : "").split(";")) {
|
|
84
|
-
const eq = part.indexOf("=");
|
|
85
|
-
if (eq < 1) {
|
|
86
|
-
continue;
|
|
87
|
-
}
|
|
88
|
-
const name = part.slice(0, eq).trim();
|
|
89
|
-
if (name && !(name in cookies)) {
|
|
90
|
-
cookies[name] = part.slice(eq + 1).trim();
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
return cookies;
|
|
94
|
-
}
|
|
95
82
|
function browserContext(req) {
|
|
96
83
|
const headers = {};
|
|
97
84
|
const forwarded = {
|
|
@@ -107,7 +94,7 @@ function browserContext(req) {
|
|
|
107
94
|
if (typeof cookie === "string" && cookie !== "") {
|
|
108
95
|
headers.cookie = cookie;
|
|
109
96
|
}
|
|
110
|
-
return { cookies:
|
|
97
|
+
return { cookies: parseCookieHeader(cookie), headers };
|
|
111
98
|
}
|
|
112
99
|
var appPlugin = (instance, options) => {
|
|
113
100
|
var _a, _b;
|
|
@@ -119,30 +106,50 @@ var appPlugin = (instance, options) => {
|
|
|
119
106
|
void reply.header("cache-control", "no-store");
|
|
120
107
|
return claim(app);
|
|
121
108
|
});
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
const { pathname, search } = new URL(target, "http://localhost");
|
|
128
|
-
const params = matchClaim(app, pathname);
|
|
129
|
-
if (params === null) {
|
|
130
|
-
serveLog.error(`\u043F\u0443\u0442\u044C \xAB${pathname}\xBB \u0432\u043D\u0435 \u0437\u0430\u044F\u0432\u043A\u0438 \u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u044F`);
|
|
131
|
-
return reply.code(404).send({ error: `\u043F\u0443\u0442\u044C \xAB${pathname}\xBB \u0432\u043D\u0435 \u0437\u0430\u044F\u0432\u043A\u0438 \u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u044F` });
|
|
132
|
-
}
|
|
133
|
-
const startedAt = Date.now();
|
|
134
|
-
try {
|
|
135
|
-
const result = yield renderApp(app, { context: browserContext(req), params, pathname, search });
|
|
136
|
-
const elapsed = Date.now() - startedAt;
|
|
137
|
-
if (elapsed >= slowRenderMs) {
|
|
138
|
-
serveLog.warn(`\u043C\u0435\u0434\u043B\u0435\u043D\u043D\u044B\u0439 \u0440\u0435\u043D\u0434\u0435\u0440 \xAB${pathname}\xBB: ${String(elapsed)}\u043C\u0441`);
|
|
109
|
+
function handleRender(req, reply, target, inputs) {
|
|
110
|
+
return __async(this, null, function* () {
|
|
111
|
+
if (typeof target !== "string" || !target.startsWith("/")) {
|
|
112
|
+
return reply.code(400).send({ error: "\u043D\u0435 \u043F\u0435\u0440\u0435\u0434\u0430\u043D \u0438\u043B\u0438 \u043D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043F\u0430\u0440\u0430\u043C\u0435\u0442\u0440 url" });
|
|
139
113
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
114
|
+
if (inputs !== void 0 && (typeof inputs !== "object" || inputs === null || Array.isArray(inputs))) {
|
|
115
|
+
return reply.code(400).send({ error: "inputs \u0434\u043E\u043B\u0436\u043D\u044B \u0431\u044B\u0442\u044C \u043E\u0431\u044A\u0435\u043A\u0442\u043E\u043C \u043F\u043E \u043A\u043B\u044E\u0447\u0443 token.description" });
|
|
116
|
+
}
|
|
117
|
+
const { pathname, search } = new URL(target, "http://localhost");
|
|
118
|
+
const params = matchClaim(app, pathname);
|
|
119
|
+
if (params === null) {
|
|
120
|
+
serveLog.error(`\u043F\u0443\u0442\u044C \xAB${pathname}\xBB \u0432\u043D\u0435 \u0437\u0430\u044F\u0432\u043A\u0438 \u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u044F`);
|
|
121
|
+
return reply.code(404).send({ error: `\u043F\u0443\u0442\u044C \xAB${pathname}\xBB \u0432\u043D\u0435 \u0437\u0430\u044F\u0432\u043A\u0438 \u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u044F` });
|
|
122
|
+
}
|
|
123
|
+
const startedAt = Date.now();
|
|
124
|
+
try {
|
|
125
|
+
const result = yield renderApp(app, {
|
|
126
|
+
context: browserContext(req),
|
|
127
|
+
inputs,
|
|
128
|
+
params,
|
|
129
|
+
pathname,
|
|
130
|
+
search
|
|
131
|
+
});
|
|
132
|
+
const elapsed = Date.now() - startedAt;
|
|
133
|
+
if (elapsed >= slowRenderMs) {
|
|
134
|
+
serveLog.warn(`\u043C\u0435\u0434\u043B\u0435\u043D\u043D\u044B\u0439 \u0440\u0435\u043D\u0434\u0435\u0440 \xAB${pathname}\xBB: ${String(elapsed)}\u043C\u0441`);
|
|
135
|
+
}
|
|
136
|
+
return result;
|
|
137
|
+
} catch (error) {
|
|
138
|
+
serveLog.error(`\u0440\u0435\u043D\u0434\u0435\u0440 \xAB${pathname}\xBB \u0443\u043F\u0430\u043B \u0437\u0430 ${String(Date.now() - startedAt)}\u043C\u0441`, error);
|
|
139
|
+
return reply.send(error instanceof Error ? error : new Error(String(error)));
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
instance.get("/_render", (req, reply) => handleRender(req, reply, req.query.url, void 0));
|
|
144
|
+
instance.route({
|
|
145
|
+
handler: (req, reply) => {
|
|
146
|
+
var _a2;
|
|
147
|
+
const body = (_a2 = req.body) != null ? _a2 : {};
|
|
148
|
+
return handleRender(req, reply, body.url, body.inputs);
|
|
149
|
+
},
|
|
150
|
+
method: "QUERY",
|
|
151
|
+
url: "/_render"
|
|
152
|
+
});
|
|
146
153
|
return Promise.resolve();
|
|
147
154
|
};
|
|
148
155
|
|
|
@@ -774,4 +774,4 @@ declare const ActivatableToken: Token<Activatable>;
|
|
|
774
774
|
*/
|
|
775
775
|
declare const RequestContextToken: Token<RequestContext>;
|
|
776
776
|
|
|
777
|
-
export { type ActionGuard as A, type
|
|
777
|
+
export { type ActionGuard as A, type DefineLayerOptions as B, type Core as C, type DefineRepositoryOptions as D, type ExtensionConfig as E, type Activatable as F, type GuardDefinition as G, ActivatableToken as H, ContainerManagerToken as I, GuardRunnerToken as J, NavigationManagerToken as K, type LayerDefinition as L, StateCache as M, type NavigationManager as N, type StateParticipant as O, StateRegistry as P, StateRegistryToken as Q, type RequestContext as R, type ServiceDefinition as S, StateSerializerToken as T, type ViewModelDefinition as V, type DefineServiceOptions as a, type DefineViewModelOptions as b, type Definition as c, type RepositoryDefinition as d, type SlotEntry as e, SlotRegistry as f, SlotRegistryToken as g, type LayerConfig as h, RequestContextToken as i, type ContainerManager as j, type GuardRunner as k, type Guard as l, type GuardResult as m, type NavigationEntry as n, type NavigationInterceptor as o, type Disposable as p, type LeaveGuardResult as q, type StateSerializer as r, type DefineGuardOptions as s, type DefineExtensionOptions as t, type ExtensionDefinition as u, type DefineActionGuardOptions as v, type ActionGuardDefinition as w, type LayoutConfig as x, type DefineLayoutOptions as y, type LayoutDefinition as z };
|
|
@@ -774,4 +774,4 @@ declare const ActivatableToken: Token<Activatable>;
|
|
|
774
774
|
*/
|
|
775
775
|
declare const RequestContextToken: Token<RequestContext>;
|
|
776
776
|
|
|
777
|
-
export { type ActionGuard as A, type
|
|
777
|
+
export { type ActionGuard as A, type DefineLayerOptions as B, type Core as C, type DefineRepositoryOptions as D, type ExtensionConfig as E, type Activatable as F, type GuardDefinition as G, ActivatableToken as H, ContainerManagerToken as I, GuardRunnerToken as J, NavigationManagerToken as K, type LayerDefinition as L, StateCache as M, type NavigationManager as N, type StateParticipant as O, StateRegistry as P, StateRegistryToken as Q, type RequestContext as R, type ServiceDefinition as S, StateSerializerToken as T, type ViewModelDefinition as V, type DefineServiceOptions as a, type DefineViewModelOptions as b, type Definition as c, type RepositoryDefinition as d, type SlotEntry as e, SlotRegistry as f, SlotRegistryToken as g, type LayerConfig as h, RequestContextToken as i, type ContainerManager as j, type GuardRunner as k, type Guard as l, type GuardResult as m, type NavigationEntry as n, type NavigationInterceptor as o, type Disposable as p, type LeaveGuardResult as q, type StateSerializer as r, type DefineGuardOptions as s, type DefineExtensionOptions as t, type ExtensionDefinition as u, type DefineActionGuardOptions as v, type ActionGuardDefinition as w, type LayoutConfig as x, type DefineLayoutOptions as y, type LayoutDefinition as z };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { I as IslandDescriptor } from './descriptor-
|
|
1
|
+
import { I as IslandDescriptor } from './descriptor-CLIZRmY4.js';
|
|
2
2
|
import { S as ServerRenderResult } from './server-render-CocWXQKC.js';
|
|
3
|
-
import { L as LayerDefinition, h as LayerConfig } from './types-
|
|
3
|
+
import { L as LayerDefinition, h as LayerConfig } from './types-BxMQ-VOd.js';
|
|
4
4
|
import { Container, Token } from '@foxford/ioc';
|
|
5
5
|
|
|
6
6
|
/** Что нужно адаптеру, чтобы отрисовать остров на сервере. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { I as IslandDescriptor } from './descriptor-
|
|
1
|
+
import { I as IslandDescriptor } from './descriptor-Ced0k1__.cjs';
|
|
2
2
|
import { S as ServerRenderResult } from './server-render-CocWXQKC.cjs';
|
|
3
|
-
import { L as LayerDefinition, h as LayerConfig } from './types-
|
|
3
|
+
import { L as LayerDefinition, h as LayerConfig } from './types-BxMQ-VOd.cjs';
|
|
4
4
|
import { Container, Token } from '@foxford/ioc';
|
|
5
5
|
|
|
6
6
|
/** Что нужно адаптеру, чтобы отрисовать остров на сервере. */
|