@domino-sdk/relay 0.14.1 → 0.15.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/dist/authoring.d.ts +2 -2
- package/dist/browser.d.ts +39 -39
- package/dist/browser.js +4 -55
- package/dist/chunk-CQ5YSQQE.js +61 -0
- package/dist/index.d.ts +102 -102
- package/dist/portal-proxy.d.ts +26 -1
- package/dist/portal-proxy.js +43 -0
- package/dist/react/index.d.ts +3847 -0
- package/dist/react/index.js +833 -0
- package/dist/{settings-CU2y-wUM.d.ts → settings-e0nHA0JA.d.ts} +1 -1
- package/dist/vite.d.ts +32 -0
- package/dist/vite.js +42 -0
- package/package.json +22 -2
package/dist/portal-proxy.d.ts
CHANGED
|
@@ -24,5 +24,30 @@ declare function createParticipantBackend(options: {
|
|
|
24
24
|
} | null>;
|
|
25
25
|
fetch?: typeof fetch;
|
|
26
26
|
}): (request: Request) => Promise<Response>;
|
|
27
|
+
/**
|
|
28
|
+
* The Worker variables `domino dev` sets for a locally running hosted app.
|
|
29
|
+
* Domino hosting sets none of them, so a deployed app uses `apiUrl` directly.
|
|
30
|
+
*/
|
|
31
|
+
type HostedAppEnv = {
|
|
32
|
+
DOMINO_PARTICIPANT_API?: string;
|
|
33
|
+
DOMINO_PREVIEW_ORIGIN?: string;
|
|
34
|
+
DOMINO_LOCAL_API?: string;
|
|
35
|
+
DOMINO_DEV_CONTROL?: string;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* The request as the participant sent it. The `domino dev` tunnel terminates
|
|
39
|
+
* HTTPS before the local Worker, so its URL is rebuilt on the preview origin.
|
|
40
|
+
* Call it first, before any routing, so every handler sees the public URL.
|
|
41
|
+
*/
|
|
42
|
+
declare function hostedAppRequest(request: Request, env: HostedAppEnv): Request;
|
|
43
|
+
/**
|
|
44
|
+
* Answers the routes Domino owns in a hosted app: the participant proxy under
|
|
45
|
+
* `/relay/*`, and `domino dev` control routes under `/__domino/*`. Returns null
|
|
46
|
+
* for everything else, which belongs to the app.
|
|
47
|
+
*/
|
|
48
|
+
declare function handleHostedApp(request: Request, env: HostedAppEnv, options: {
|
|
49
|
+
apiUrl: string;
|
|
50
|
+
fetch?: typeof fetch;
|
|
51
|
+
}): Promise<Response | null>;
|
|
27
52
|
|
|
28
|
-
export { createParticipantBackend, proxyParticipant };
|
|
53
|
+
export { type HostedAppEnv, createParticipantBackend, handleHostedApp, hostedAppRequest, proxyParticipant };
|
package/dist/portal-proxy.js
CHANGED
|
@@ -133,7 +133,50 @@ function createParticipantBackend(options) {
|
|
|
133
133
|
return new Response(response.body, { status: response.status, headers });
|
|
134
134
|
};
|
|
135
135
|
}
|
|
136
|
+
function hostedAppRequest(request, env) {
|
|
137
|
+
if (!env.DOMINO_PREVIEW_ORIGIN) {
|
|
138
|
+
return request;
|
|
139
|
+
}
|
|
140
|
+
const url = new URL(request.url);
|
|
141
|
+
return new Request(
|
|
142
|
+
new URL(url.pathname + url.search, env.DOMINO_PREVIEW_ORIGIN),
|
|
143
|
+
request
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
async function handleHostedApp(request, env, options) {
|
|
147
|
+
const url = new URL(request.url);
|
|
148
|
+
const send = options.fetch ?? fetch;
|
|
149
|
+
if (env.DOMINO_DEV_CONTROL && url.pathname.startsWith("/__domino/")) {
|
|
150
|
+
return send(
|
|
151
|
+
new Request(
|
|
152
|
+
new URL(url.pathname + url.search, env.DOMINO_DEV_CONTROL),
|
|
153
|
+
request
|
|
154
|
+
)
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
if (!url.pathname.startsWith("/relay/")) {
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
if (env.DOMINO_LOCAL_API) {
|
|
161
|
+
return send(
|
|
162
|
+
new Request(
|
|
163
|
+
new URL(
|
|
164
|
+
url.pathname.slice("/relay".length) + url.search,
|
|
165
|
+
env.DOMINO_LOCAL_API
|
|
166
|
+
),
|
|
167
|
+
request
|
|
168
|
+
)
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
return proxyParticipant(request, {
|
|
172
|
+
baseUrl: env.DOMINO_PARTICIPANT_API || options.apiUrl,
|
|
173
|
+
fetch: send,
|
|
174
|
+
hosted: true
|
|
175
|
+
});
|
|
176
|
+
}
|
|
136
177
|
export {
|
|
137
178
|
createParticipantBackend,
|
|
179
|
+
handleHostedApp,
|
|
180
|
+
hostedAppRequest,
|
|
138
181
|
proxyParticipant
|
|
139
182
|
};
|