@qwik.dev/router 0.0.0 → 2.0.0-alpha.1
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/LICENSE +22 -0
- package/README.md +15 -0
- package/adapters/azure-swa/vite.d.ts +2 -0
- package/adapters/bun-server/vite.d.ts +2 -0
- package/adapters/cloud-run/vite.d.ts +2 -0
- package/adapters/cloudflare-pages/vite.d.ts +2 -0
- package/adapters/deno-server/vite.d.ts +2 -0
- package/adapters/netlify-edge/vite.d.ts +2 -0
- package/adapters/node-server/vite.d.ts +2 -0
- package/adapters/shared/vite.d.ts +2 -0
- package/adapters/static/vite.d.ts +2 -0
- package/adapters/vercel-edge/vite.d.ts +2 -0
- package/index.d.ts +2 -0
- package/lib/adapters/azure-swa/vite/index.cjs +96 -0
- package/lib/adapters/azure-swa/vite/index.d.ts +13 -0
- package/lib/adapters/azure-swa/vite/index.mjs +61 -0
- package/lib/adapters/bun-server/vite/index.cjs +50 -0
- package/lib/adapters/bun-server/vite/index.d.ts +14 -0
- package/lib/adapters/bun-server/vite/index.mjs +25 -0
- package/lib/adapters/cloud-run/vite/index.cjs +47 -0
- package/lib/adapters/cloud-run/vite/index.d.ts +13 -0
- package/lib/adapters/cloud-run/vite/index.mjs +22 -0
- package/lib/adapters/cloudflare-pages/vite/index.cjs +115 -0
- package/lib/adapters/cloudflare-pages/vite/index.d.ts +27 -0
- package/lib/adapters/cloudflare-pages/vite/index.mjs +80 -0
- package/lib/adapters/deno-server/vite/index.cjs +62 -0
- package/lib/adapters/deno-server/vite/index.d.ts +14 -0
- package/lib/adapters/deno-server/vite/index.mjs +37 -0
- package/lib/adapters/netlify-edge/vite/index.cjs +129 -0
- package/lib/adapters/netlify-edge/vite/index.d.ts +44 -0
- package/lib/adapters/netlify-edge/vite/index.mjs +92 -0
- package/lib/adapters/node-server/vite/index.cjs +50 -0
- package/lib/adapters/node-server/vite/index.d.ts +14 -0
- package/lib/adapters/node-server/vite/index.mjs +25 -0
- package/lib/adapters/shared/vite/index.cjs +371 -0
- package/lib/adapters/shared/vite/index.d.ts +114 -0
- package/lib/adapters/shared/vite/index.mjs +331 -0
- package/lib/adapters/static/vite/index.cjs +361 -0
- package/lib/adapters/static/vite/index.d.ts +10 -0
- package/lib/adapters/static/vite/index.mjs +324 -0
- package/lib/adapters/vercel-edge/vite/index.cjs +118 -0
- package/lib/adapters/vercel-edge/vite/index.d.ts +45 -0
- package/lib/adapters/vercel-edge/vite/index.mjs +83 -0
- package/lib/index.d.ts +803 -0
- package/lib/index.qwik.cjs +1876 -0
- package/lib/index.qwik.mjs +1857 -0
- package/lib/middleware/aws-lambda/index.d.ts +50 -0
- package/lib/middleware/aws-lambda/index.mjs +55 -0
- package/lib/middleware/azure-swa/index.d.ts +28 -0
- package/lib/middleware/azure-swa/index.mjs +297 -0
- package/lib/middleware/bun/index.d.ts +35 -0
- package/lib/middleware/bun/index.mjs +208 -0
- package/lib/middleware/cloudflare-pages/index.d.ts +35 -0
- package/lib/middleware/cloudflare-pages/index.mjs +107 -0
- package/lib/middleware/deno/index.d.ts +47 -0
- package/lib/middleware/deno/index.mjs +195 -0
- package/lib/middleware/firebase/index.d.ts +26 -0
- package/lib/middleware/firebase/index.mjs +36 -0
- package/lib/middleware/netlify-edge/index.d.ts +27 -0
- package/lib/middleware/netlify-edge/index.mjs +83 -0
- package/lib/middleware/node/index.cjs +314 -0
- package/lib/middleware/node/index.d.ts +66 -0
- package/lib/middleware/node/index.mjs +287 -0
- package/lib/middleware/request-handler/index.cjs +1544 -0
- package/lib/middleware/request-handler/index.d.ts +681 -0
- package/lib/middleware/request-handler/index.mjs +1501 -0
- package/lib/middleware/vercel-edge/index.d.ts +26 -0
- package/lib/middleware/vercel-edge/index.mjs +109 -0
- package/lib/modules.d.ts +38 -0
- package/lib/service-worker.cjs +267 -0
- package/lib/service-worker.d.ts +4 -0
- package/lib/service-worker.mjs +265 -0
- package/lib/static/deno.mjs +8 -0
- package/lib/static/index.cjs +67 -0
- package/lib/static/index.d.ts +98 -0
- package/lib/static/index.mjs +48 -0
- package/lib/static/node.cjs +1124 -0
- package/lib/static/node.mjs +1086 -0
- package/lib/vite/index.cjs +27496 -0
- package/lib/vite/index.d.ts +154 -0
- package/lib/vite/index.mjs +27484 -0
- package/middleware/aws-lambda.d.ts +2 -0
- package/middleware/azure-swa.d.ts +2 -0
- package/middleware/bun.d.ts +2 -0
- package/middleware/cloudflare-pages.d.ts +2 -0
- package/middleware/deno.d.ts +2 -0
- package/middleware/firebase.d.ts +2 -0
- package/middleware/netlify-edge.d.ts +2 -0
- package/middleware/node.d.ts +2 -0
- package/middleware/request-handler/generated/not-found-paths.ts +7 -0
- package/middleware/request-handler/generated/static-paths.ts +35 -0
- package/middleware/request-handler.d.ts +2 -0
- package/middleware/vercel-edge.d.ts +2 -0
- package/modules.d.ts +38 -0
- package/package.json +171 -165
- package/service-worker.d.ts +2 -0
- package/static.d.ts +2 -0
- package/vite.d.ts +2 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 QwikDev
|
|
4
|
+
Copyright (c) 2021 BuilderIO
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Qwik Router 🛣
|
|
2
|
+
|
|
3
|
+
The router for [Qwik](https://qwik.dev/).
|
|
4
|
+
|
|
5
|
+
## Community
|
|
6
|
+
|
|
7
|
+
- Ping us at [@QwikDev](https://twitter.com/QwikDev)
|
|
8
|
+
- Join our [Discord](https://qwik.dev/chat) community
|
|
9
|
+
|
|
10
|
+
## Related
|
|
11
|
+
|
|
12
|
+
- [Qwik](https://qwik.dev/): An open-source framework designed for best possible time to interactive, by focusing on resumability of server-side-rendering of HTML, and fine-grained lazy-loading of code.
|
|
13
|
+
- [Partytown](https://partytown.builder.io/): Relocate resource intensive third-party scripts off of the main thread and into a web worker 🎉.
|
|
14
|
+
- [Mitosis](https://github.com/BuilderIO/mitosis): Write components once, run everywhere. Compiles to Vue, React, Solid, Angular, Svelte, and more.
|
|
15
|
+
- [Builder](https://github.com/BuilderIO/builder): Drag and drop page builder and CMS for React, Vue, Angular, and more.
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// packages/qwik-router/src/adapters/azure-swa/vite/index.ts
|
|
31
|
+
var vite_exports = {};
|
|
32
|
+
__export(vite_exports, {
|
|
33
|
+
azureSwaAdapter: () => azureSwaAdapter
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(vite_exports);
|
|
36
|
+
var import_node_fs = __toESM(require("node:fs"), 1);
|
|
37
|
+
var import_node_path = require("node:path");
|
|
38
|
+
var import_vite = require("../../shared/vite/index.cjs");
|
|
39
|
+
function azureSwaAdapter(opts = {}) {
|
|
40
|
+
const env = process == null ? void 0 : process.env;
|
|
41
|
+
return (0, import_vite.viteAdapter)({
|
|
42
|
+
name: "azure-swa",
|
|
43
|
+
origin: (env == null ? void 0 : env.ORIGIN) ?? (env == null ? void 0 : env.URL) ?? "https://yoursitename.region.2.azurestaticapps.net",
|
|
44
|
+
ssg: opts.ssg,
|
|
45
|
+
cleanStaticGenerated: true,
|
|
46
|
+
async generate({ outputEntries, serverOutDir, clientPublicOutDir }) {
|
|
47
|
+
const serverPackageJsonPath = (0, import_node_path.join)(serverOutDir, "package.json");
|
|
48
|
+
const serverPackageJsonCode = `{"type":"module"}`;
|
|
49
|
+
await import_node_fs.default.promises.mkdir(serverOutDir, { recursive: true });
|
|
50
|
+
await import_node_fs.default.promises.writeFile(serverPackageJsonPath, serverPackageJsonCode);
|
|
51
|
+
const azureSwaModulePath = outputEntries.find(
|
|
52
|
+
(entryName) => entryName.indexOf("entry.azure-swa") === 0
|
|
53
|
+
);
|
|
54
|
+
const funcJsonPath = (0, import_node_path.join)(serverOutDir, "function.json");
|
|
55
|
+
const funcJson = JSON.stringify(
|
|
56
|
+
{
|
|
57
|
+
bindings: [
|
|
58
|
+
{
|
|
59
|
+
authLevel: "anonymous",
|
|
60
|
+
type: "httpTrigger",
|
|
61
|
+
direction: "in",
|
|
62
|
+
name: "req",
|
|
63
|
+
methods: [
|
|
64
|
+
"get",
|
|
65
|
+
"head",
|
|
66
|
+
"post",
|
|
67
|
+
"put",
|
|
68
|
+
"delete",
|
|
69
|
+
"connect",
|
|
70
|
+
"options",
|
|
71
|
+
"trace",
|
|
72
|
+
"patch"
|
|
73
|
+
]
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
type: "http",
|
|
77
|
+
direction: "out",
|
|
78
|
+
name: "$return"
|
|
79
|
+
}
|
|
80
|
+
],
|
|
81
|
+
scriptFile: azureSwaModulePath
|
|
82
|
+
},
|
|
83
|
+
null,
|
|
84
|
+
2
|
|
85
|
+
);
|
|
86
|
+
await import_node_fs.default.promises.writeFile(funcJsonPath, funcJson);
|
|
87
|
+
if (!import_node_fs.default.existsSync((0, import_node_path.join)(clientPublicOutDir, "index.html"))) {
|
|
88
|
+
await import_node_fs.default.promises.writeFile((0, import_node_path.join)(clientPublicOutDir, "index.html"), "");
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
94
|
+
0 && (module.exports = {
|
|
95
|
+
azureSwaAdapter
|
|
96
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ServerAdapterOptions } from '../../shared/vite';
|
|
2
|
+
import type { StaticGenerateRenderOptions } from '@qwik.dev/router/static';
|
|
3
|
+
|
|
4
|
+
/** @public */
|
|
5
|
+
export declare function azureSwaAdapter(opts?: AzureSwaAdapterOptions): any;
|
|
6
|
+
|
|
7
|
+
/** @public */
|
|
8
|
+
export declare interface AzureSwaAdapterOptions extends ServerAdapterOptions {
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { StaticGenerateRenderOptions }
|
|
12
|
+
|
|
13
|
+
export { }
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// packages/qwik-router/src/adapters/azure-swa/vite/index.ts
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { viteAdapter } from "../../shared/vite/index.mjs";
|
|
5
|
+
function azureSwaAdapter(opts = {}) {
|
|
6
|
+
const env = process == null ? void 0 : process.env;
|
|
7
|
+
return viteAdapter({
|
|
8
|
+
name: "azure-swa",
|
|
9
|
+
origin: (env == null ? void 0 : env.ORIGIN) ?? (env == null ? void 0 : env.URL) ?? "https://yoursitename.region.2.azurestaticapps.net",
|
|
10
|
+
ssg: opts.ssg,
|
|
11
|
+
cleanStaticGenerated: true,
|
|
12
|
+
async generate({ outputEntries, serverOutDir, clientPublicOutDir }) {
|
|
13
|
+
const serverPackageJsonPath = join(serverOutDir, "package.json");
|
|
14
|
+
const serverPackageJsonCode = `{"type":"module"}`;
|
|
15
|
+
await fs.promises.mkdir(serverOutDir, { recursive: true });
|
|
16
|
+
await fs.promises.writeFile(serverPackageJsonPath, serverPackageJsonCode);
|
|
17
|
+
const azureSwaModulePath = outputEntries.find(
|
|
18
|
+
(entryName) => entryName.indexOf("entry.azure-swa") === 0
|
|
19
|
+
);
|
|
20
|
+
const funcJsonPath = join(serverOutDir, "function.json");
|
|
21
|
+
const funcJson = JSON.stringify(
|
|
22
|
+
{
|
|
23
|
+
bindings: [
|
|
24
|
+
{
|
|
25
|
+
authLevel: "anonymous",
|
|
26
|
+
type: "httpTrigger",
|
|
27
|
+
direction: "in",
|
|
28
|
+
name: "req",
|
|
29
|
+
methods: [
|
|
30
|
+
"get",
|
|
31
|
+
"head",
|
|
32
|
+
"post",
|
|
33
|
+
"put",
|
|
34
|
+
"delete",
|
|
35
|
+
"connect",
|
|
36
|
+
"options",
|
|
37
|
+
"trace",
|
|
38
|
+
"patch"
|
|
39
|
+
]
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
type: "http",
|
|
43
|
+
direction: "out",
|
|
44
|
+
name: "$return"
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
scriptFile: azureSwaModulePath
|
|
48
|
+
},
|
|
49
|
+
null,
|
|
50
|
+
2
|
|
51
|
+
);
|
|
52
|
+
await fs.promises.writeFile(funcJsonPath, funcJson);
|
|
53
|
+
if (!fs.existsSync(join(clientPublicOutDir, "index.html"))) {
|
|
54
|
+
await fs.promises.writeFile(join(clientPublicOutDir, "index.html"), "");
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
export {
|
|
60
|
+
azureSwaAdapter
|
|
61
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// packages/qwik-router/src/adapters/bun-server/vite/index.ts
|
|
21
|
+
var vite_exports = {};
|
|
22
|
+
__export(vite_exports, {
|
|
23
|
+
bunServerAdapter: () => bunServerAdapter
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(vite_exports);
|
|
26
|
+
var import_vite = require("../../shared/vite/index.cjs");
|
|
27
|
+
function bunServerAdapter(opts = {}) {
|
|
28
|
+
const env = process == null ? void 0 : process.env;
|
|
29
|
+
return (0, import_vite.viteAdapter)({
|
|
30
|
+
name: opts.name || "bun-server",
|
|
31
|
+
origin: (env == null ? void 0 : env.ORIGIN) ?? (env == null ? void 0 : env.URL) ?? "https://yoursitename.qwik.dev",
|
|
32
|
+
ssg: opts.ssg,
|
|
33
|
+
cleanStaticGenerated: true,
|
|
34
|
+
config() {
|
|
35
|
+
return {
|
|
36
|
+
ssr: {
|
|
37
|
+
target: "node"
|
|
38
|
+
},
|
|
39
|
+
build: {
|
|
40
|
+
ssr: true
|
|
41
|
+
},
|
|
42
|
+
publicDir: false
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
48
|
+
0 && (module.exports = {
|
|
49
|
+
bunServerAdapter
|
|
50
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ServerAdapterOptions } from '../../shared/vite';
|
|
2
|
+
import type { StaticGenerateRenderOptions } from '@qwik.dev/router/static';
|
|
3
|
+
|
|
4
|
+
/** @beta */
|
|
5
|
+
export declare function bunServerAdapter(opts?: bunServerAdapterOptions): any;
|
|
6
|
+
|
|
7
|
+
/** @beta */
|
|
8
|
+
export declare interface bunServerAdapterOptions extends ServerAdapterOptions {
|
|
9
|
+
name?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { StaticGenerateRenderOptions }
|
|
13
|
+
|
|
14
|
+
export { }
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// packages/qwik-router/src/adapters/bun-server/vite/index.ts
|
|
2
|
+
import { viteAdapter } from "../../shared/vite/index.mjs";
|
|
3
|
+
function bunServerAdapter(opts = {}) {
|
|
4
|
+
const env = process == null ? void 0 : process.env;
|
|
5
|
+
return viteAdapter({
|
|
6
|
+
name: opts.name || "bun-server",
|
|
7
|
+
origin: (env == null ? void 0 : env.ORIGIN) ?? (env == null ? void 0 : env.URL) ?? "https://yoursitename.qwik.dev",
|
|
8
|
+
ssg: opts.ssg,
|
|
9
|
+
cleanStaticGenerated: true,
|
|
10
|
+
config() {
|
|
11
|
+
return {
|
|
12
|
+
ssr: {
|
|
13
|
+
target: "node"
|
|
14
|
+
},
|
|
15
|
+
build: {
|
|
16
|
+
ssr: true
|
|
17
|
+
},
|
|
18
|
+
publicDir: false
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
bunServerAdapter
|
|
25
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// packages/qwik-router/src/adapters/cloud-run/vite/index.ts
|
|
21
|
+
var vite_exports = {};
|
|
22
|
+
__export(vite_exports, {
|
|
23
|
+
cloudRunAdapter: () => cloudRunAdapter
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(vite_exports);
|
|
26
|
+
var import_vite = require("../../shared/vite/index.cjs");
|
|
27
|
+
function cloudRunAdapter(opts = {}) {
|
|
28
|
+
const env = process == null ? void 0 : process.env;
|
|
29
|
+
return (0, import_vite.viteAdapter)({
|
|
30
|
+
name: "cloud-run",
|
|
31
|
+
origin: (env == null ? void 0 : env.ORIGIN) ?? (env == null ? void 0 : env.URL) ?? "https://your-app-name.run.app",
|
|
32
|
+
ssg: opts.ssg,
|
|
33
|
+
cleanStaticGenerated: true,
|
|
34
|
+
config() {
|
|
35
|
+
return {
|
|
36
|
+
build: {
|
|
37
|
+
ssr: true
|
|
38
|
+
},
|
|
39
|
+
publicDir: false
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
45
|
+
0 && (module.exports = {
|
|
46
|
+
cloudRunAdapter
|
|
47
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ServerAdapterOptions } from '../../shared/vite';
|
|
2
|
+
import type { StaticGenerateRenderOptions } from '@qwik.dev/router/static';
|
|
3
|
+
|
|
4
|
+
/** @public */
|
|
5
|
+
export declare function cloudRunAdapter(opts?: CloudRunAdapterOptions): any;
|
|
6
|
+
|
|
7
|
+
/** @public */
|
|
8
|
+
export declare interface CloudRunAdapterOptions extends ServerAdapterOptions {
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { StaticGenerateRenderOptions }
|
|
12
|
+
|
|
13
|
+
export { }
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// packages/qwik-router/src/adapters/cloud-run/vite/index.ts
|
|
2
|
+
import { viteAdapter } from "../../shared/vite/index.mjs";
|
|
3
|
+
function cloudRunAdapter(opts = {}) {
|
|
4
|
+
const env = process == null ? void 0 : process.env;
|
|
5
|
+
return viteAdapter({
|
|
6
|
+
name: "cloud-run",
|
|
7
|
+
origin: (env == null ? void 0 : env.ORIGIN) ?? (env == null ? void 0 : env.URL) ?? "https://your-app-name.run.app",
|
|
8
|
+
ssg: opts.ssg,
|
|
9
|
+
cleanStaticGenerated: true,
|
|
10
|
+
config() {
|
|
11
|
+
return {
|
|
12
|
+
build: {
|
|
13
|
+
ssr: true
|
|
14
|
+
},
|
|
15
|
+
publicDir: false
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
cloudRunAdapter
|
|
22
|
+
};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// packages/qwik-router/src/adapters/cloudflare-pages/vite/index.ts
|
|
31
|
+
var vite_exports = {};
|
|
32
|
+
__export(vite_exports, {
|
|
33
|
+
cloudflarePagesAdapter: () => cloudflarePagesAdapter
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(vite_exports);
|
|
36
|
+
var import_node_fs = __toESM(require("node:fs"), 1);
|
|
37
|
+
var import_node_path = require("node:path");
|
|
38
|
+
|
|
39
|
+
// packages/qwik-router/src/utils/fs.ts
|
|
40
|
+
function normalizePathSlash(path) {
|
|
41
|
+
const isExtendedLengthPath = /^\\\\\?\\/.test(path);
|
|
42
|
+
const hasNonAscii = /[^\u0000-\u0080]+/.test(path);
|
|
43
|
+
if (isExtendedLengthPath || hasNonAscii) {
|
|
44
|
+
return path;
|
|
45
|
+
}
|
|
46
|
+
path = path.replace(/\\/g, "/");
|
|
47
|
+
if (path.endsWith("/")) {
|
|
48
|
+
path = path.slice(0, path.length - 1);
|
|
49
|
+
}
|
|
50
|
+
return path;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// packages/qwik-router/src/adapters/cloudflare-pages/vite/index.ts
|
|
54
|
+
var import_vite = require("../../shared/vite/index.cjs");
|
|
55
|
+
function cloudflarePagesAdapter(opts = {}) {
|
|
56
|
+
const env = process == null ? void 0 : process.env;
|
|
57
|
+
return (0, import_vite.viteAdapter)({
|
|
58
|
+
name: "cloudflare-pages",
|
|
59
|
+
origin: (env == null ? void 0 : env.CF_PAGES_URL) ?? (env == null ? void 0 : env.ORIGIN) ?? "https://your.cloudflare.pages.dev",
|
|
60
|
+
ssg: opts.ssg,
|
|
61
|
+
staticPaths: opts.staticPaths,
|
|
62
|
+
cleanStaticGenerated: true,
|
|
63
|
+
config() {
|
|
64
|
+
return {
|
|
65
|
+
resolve: {
|
|
66
|
+
conditions: ["webworker", "worker"]
|
|
67
|
+
},
|
|
68
|
+
ssr: {
|
|
69
|
+
target: "webworker",
|
|
70
|
+
noExternal: true,
|
|
71
|
+
external: ["node:async_hooks"]
|
|
72
|
+
},
|
|
73
|
+
build: {
|
|
74
|
+
ssr: true,
|
|
75
|
+
rollupOptions: {
|
|
76
|
+
output: {
|
|
77
|
+
format: "es",
|
|
78
|
+
hoistTransitiveImports: false
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
publicDir: false
|
|
83
|
+
};
|
|
84
|
+
},
|
|
85
|
+
async generate({ clientOutDir, serverOutDir, basePathname, assetsDir }) {
|
|
86
|
+
const routesJsonPath = (0, import_node_path.join)(clientOutDir, "_routes.json");
|
|
87
|
+
const hasRoutesJson = import_node_fs.default.existsSync(routesJsonPath);
|
|
88
|
+
if (!hasRoutesJson && opts.functionRoutes !== false) {
|
|
89
|
+
let pathName = assetsDir ? (0, import_node_path.join)(basePathname, assetsDir) : basePathname;
|
|
90
|
+
if (!pathName.endsWith("/")) {
|
|
91
|
+
pathName += "/";
|
|
92
|
+
}
|
|
93
|
+
const routesJson = {
|
|
94
|
+
version: 1,
|
|
95
|
+
include: [basePathname + "*"],
|
|
96
|
+
exclude: [pathName + "build/*", pathName + "assets/*"]
|
|
97
|
+
};
|
|
98
|
+
await import_node_fs.default.promises.writeFile(routesJsonPath, JSON.stringify(routesJson, void 0, 2));
|
|
99
|
+
}
|
|
100
|
+
const workerJsPath = (0, import_node_path.join)(clientOutDir, "_worker.js");
|
|
101
|
+
const hasWorkerJs = import_node_fs.default.existsSync(workerJsPath);
|
|
102
|
+
if (!hasWorkerJs) {
|
|
103
|
+
const importPath = (0, import_node_path.relative)(clientOutDir, (0, import_node_path.join)(serverOutDir, "entry.cloudflare-pages"));
|
|
104
|
+
await import_node_fs.default.promises.writeFile(
|
|
105
|
+
workerJsPath,
|
|
106
|
+
`import { fetch } from "${normalizePathSlash(importPath)}"; export default { fetch };`
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
113
|
+
0 && (module.exports = {
|
|
114
|
+
cloudflarePagesAdapter
|
|
115
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ServerAdapterOptions } from '../../shared/vite';
|
|
2
|
+
import type { StaticGenerateRenderOptions } from '@qwik.dev/router/static';
|
|
3
|
+
|
|
4
|
+
/** @public */
|
|
5
|
+
export declare function cloudflarePagesAdapter(opts?: CloudflarePagesAdapterOptions): any;
|
|
6
|
+
|
|
7
|
+
/** @public */
|
|
8
|
+
export declare interface CloudflarePagesAdapterOptions extends ServerAdapterOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Determines if the build should generate the function invocation routes `_routes.json` file.
|
|
11
|
+
*
|
|
12
|
+
* https://developers.cloudflare.com/pages/platform/functions/routing/#functions-invocation-routes
|
|
13
|
+
*
|
|
14
|
+
* Defaults to `true`.
|
|
15
|
+
*/
|
|
16
|
+
functionRoutes?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Manually add pathnames that should be treated as static paths and not SSR. For example, when
|
|
19
|
+
* these pathnames are requested, their response should come from a static file, rather than a
|
|
20
|
+
* server-side rendered response.
|
|
21
|
+
*/
|
|
22
|
+
staticPaths?: string[];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { StaticGenerateRenderOptions }
|
|
26
|
+
|
|
27
|
+
export { }
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// packages/qwik-router/src/adapters/cloudflare-pages/vite/index.ts
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import { join, relative } from "node:path";
|
|
4
|
+
|
|
5
|
+
// packages/qwik-router/src/utils/fs.ts
|
|
6
|
+
function normalizePathSlash(path) {
|
|
7
|
+
const isExtendedLengthPath = /^\\\\\?\\/.test(path);
|
|
8
|
+
const hasNonAscii = /[^\u0000-\u0080]+/.test(path);
|
|
9
|
+
if (isExtendedLengthPath || hasNonAscii) {
|
|
10
|
+
return path;
|
|
11
|
+
}
|
|
12
|
+
path = path.replace(/\\/g, "/");
|
|
13
|
+
if (path.endsWith("/")) {
|
|
14
|
+
path = path.slice(0, path.length - 1);
|
|
15
|
+
}
|
|
16
|
+
return path;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// packages/qwik-router/src/adapters/cloudflare-pages/vite/index.ts
|
|
20
|
+
import { viteAdapter } from "../../shared/vite/index.mjs";
|
|
21
|
+
function cloudflarePagesAdapter(opts = {}) {
|
|
22
|
+
const env = process == null ? void 0 : process.env;
|
|
23
|
+
return viteAdapter({
|
|
24
|
+
name: "cloudflare-pages",
|
|
25
|
+
origin: (env == null ? void 0 : env.CF_PAGES_URL) ?? (env == null ? void 0 : env.ORIGIN) ?? "https://your.cloudflare.pages.dev",
|
|
26
|
+
ssg: opts.ssg,
|
|
27
|
+
staticPaths: opts.staticPaths,
|
|
28
|
+
cleanStaticGenerated: true,
|
|
29
|
+
config() {
|
|
30
|
+
return {
|
|
31
|
+
resolve: {
|
|
32
|
+
conditions: ["webworker", "worker"]
|
|
33
|
+
},
|
|
34
|
+
ssr: {
|
|
35
|
+
target: "webworker",
|
|
36
|
+
noExternal: true,
|
|
37
|
+
external: ["node:async_hooks"]
|
|
38
|
+
},
|
|
39
|
+
build: {
|
|
40
|
+
ssr: true,
|
|
41
|
+
rollupOptions: {
|
|
42
|
+
output: {
|
|
43
|
+
format: "es",
|
|
44
|
+
hoistTransitiveImports: false
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
publicDir: false
|
|
49
|
+
};
|
|
50
|
+
},
|
|
51
|
+
async generate({ clientOutDir, serverOutDir, basePathname, assetsDir }) {
|
|
52
|
+
const routesJsonPath = join(clientOutDir, "_routes.json");
|
|
53
|
+
const hasRoutesJson = fs.existsSync(routesJsonPath);
|
|
54
|
+
if (!hasRoutesJson && opts.functionRoutes !== false) {
|
|
55
|
+
let pathName = assetsDir ? join(basePathname, assetsDir) : basePathname;
|
|
56
|
+
if (!pathName.endsWith("/")) {
|
|
57
|
+
pathName += "/";
|
|
58
|
+
}
|
|
59
|
+
const routesJson = {
|
|
60
|
+
version: 1,
|
|
61
|
+
include: [basePathname + "*"],
|
|
62
|
+
exclude: [pathName + "build/*", pathName + "assets/*"]
|
|
63
|
+
};
|
|
64
|
+
await fs.promises.writeFile(routesJsonPath, JSON.stringify(routesJson, void 0, 2));
|
|
65
|
+
}
|
|
66
|
+
const workerJsPath = join(clientOutDir, "_worker.js");
|
|
67
|
+
const hasWorkerJs = fs.existsSync(workerJsPath);
|
|
68
|
+
if (!hasWorkerJs) {
|
|
69
|
+
const importPath = relative(clientOutDir, join(serverOutDir, "entry.cloudflare-pages"));
|
|
70
|
+
await fs.promises.writeFile(
|
|
71
|
+
workerJsPath,
|
|
72
|
+
`import { fetch } from "${normalizePathSlash(importPath)}"; export default { fetch };`
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
export {
|
|
79
|
+
cloudflarePagesAdapter
|
|
80
|
+
};
|