@blinkk/root 3.5.2 → 3.5.3
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/functions.js +19 -7
- package/dist/functions.js.map +2 -2
- package/package.json +1 -1
package/dist/functions.js
CHANGED
|
@@ -15,15 +15,27 @@ import "./chunk-WX62JK5E.js";
|
|
|
15
15
|
import path from "node:path";
|
|
16
16
|
import { onRequest } from "firebase-functions/v2/https";
|
|
17
17
|
function server(options) {
|
|
18
|
-
let
|
|
18
|
+
let rootServerPromise = null;
|
|
19
19
|
const rootDir = path.resolve(options?.rootDir || process.cwd());
|
|
20
|
+
function getRootServer() {
|
|
21
|
+
if (!rootServerPromise) {
|
|
22
|
+
const createServer = options?.mode === "preview" ? createPreviewServer : createProdServer;
|
|
23
|
+
rootServerPromise = createServer({ rootDir }).catch((err) => {
|
|
24
|
+
rootServerPromise = null;
|
|
25
|
+
throw err;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return rootServerPromise;
|
|
29
|
+
}
|
|
20
30
|
return onRequest(options?.httpsOptions || {}, async (req, res) => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
31
|
+
let rootServer;
|
|
32
|
+
try {
|
|
33
|
+
rootServer = await getRootServer();
|
|
34
|
+
} catch (err) {
|
|
35
|
+
console.error("failed to start the root.js server:");
|
|
36
|
+
console.error(err);
|
|
37
|
+
res.status(500).set({ "Content-Type": "text/plain" }).end("500");
|
|
38
|
+
return;
|
|
27
39
|
}
|
|
28
40
|
await rootServer(req, res);
|
|
29
41
|
});
|
package/dist/functions.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/functions/server.ts"],
|
|
4
|
-
"sourcesContent": ["import path from 'node:path';\nimport {HttpsOptions, onRequest} from 'firebase-functions/v2/https';\nimport {createPreviewServer, createProdServer} from '../cli/cli.js';\nimport {Server} from '../core/types.js';\n\nexport interface ProdServerOptions {\n rootDir?: string;\n mode?: 'preview' | 'production';\n httpsOptions?: HttpsOptions;\n}\n\n/**\n * Firebase Function that runs a Root.js server running in SSR mode.\n */\nexport function server(options?: ProdServerOptions) {\n let
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;AAAA,OAAO,UAAU;AACjB,SAAsB,iBAAgB;AAa/B,SAAS,OAAO,SAA6B;AAClD,MAAI;
|
|
4
|
+
"sourcesContent": ["import path from 'node:path';\nimport {HttpsOptions, onRequest} from 'firebase-functions/v2/https';\nimport {createPreviewServer, createProdServer} from '../cli/cli.js';\nimport {Server} from '../core/types.js';\n\nexport interface ProdServerOptions {\n rootDir?: string;\n mode?: 'preview' | 'production';\n httpsOptions?: HttpsOptions;\n}\n\n/**\n * Firebase Function that runs a Root.js server running in SSR mode.\n */\nexport function server(options?: ProdServerOptions) {\n let rootServerPromise: Promise<Server> | null = null;\n const rootDir = path.resolve(options?.rootDir || process.cwd());\n\n // Instances serve many concurrent requests, so the server is created once\n // and shared by every request that arrives while it is still starting up.\n // A failed startup is cleared so that the next request retries it.\n function getRootServer(): Promise<Server> {\n if (!rootServerPromise) {\n const createServer =\n options?.mode === 'preview' ? createPreviewServer : createProdServer;\n rootServerPromise = createServer({rootDir}).catch((err) => {\n rootServerPromise = null;\n throw err;\n });\n }\n return rootServerPromise;\n }\n\n return onRequest(options?.httpsOptions || {}, async (req, res) => {\n let rootServer: Server;\n try {\n rootServer = await getRootServer();\n } catch (err) {\n console.error('failed to start the root.js server:');\n console.error(err);\n res.status(500).set({'Content-Type': 'text/plain'}).end('500');\n return;\n }\n await rootServer(req, res);\n });\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;AAAA,OAAO,UAAU;AACjB,SAAsB,iBAAgB;AAa/B,SAAS,OAAO,SAA6B;AAClD,MAAI,oBAA4C;AAChD,QAAM,UAAU,KAAK,QAAQ,SAAS,WAAW,QAAQ,IAAI,CAAC;AAK9D,WAAS,gBAAiC;AACxC,QAAI,CAAC,mBAAmB;AACtB,YAAM,eACJ,SAAS,SAAS,YAAY,sBAAsB;AACtD,0BAAoB,aAAa,EAAC,QAAO,CAAC,EAAE,MAAM,CAAC,QAAQ;AACzD,4BAAoB;AACpB,cAAM;AAAA,MACR,CAAC;AAAA,IACH;AACA,WAAO;AAAA,EACT;AAEA,SAAO,UAAU,SAAS,gBAAgB,CAAC,GAAG,OAAO,KAAK,QAAQ;AAChE,QAAI;AACJ,QAAI;AACF,mBAAa,MAAM,cAAc;AAAA,IACnC,SAAS,KAAK;AACZ,cAAQ,MAAM,qCAAqC;AACnD,cAAQ,MAAM,GAAG;AACjB,UAAI,OAAO,GAAG,EAAE,IAAI,EAAC,gBAAgB,aAAY,CAAC,EAAE,IAAI,KAAK;AAC7D;AAAA,IACF;AACA,UAAM,WAAW,KAAK,GAAG;AAAA,EAC3B,CAAC;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|