oidc-spa 8.3.5 → 8.3.7
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/core/StateDataCookie.d.ts +34 -0
- package/core/StateDataCookie.js +142 -0
- package/core/StateDataCookie.js.map +1 -0
- package/core/createOidc.js +23 -5
- package/core/createOidc.js.map +1 -1
- package/core/earlyInit.d.ts +0 -1
- package/core/earlyInit.js +4 -13
- package/core/earlyInit.js.map +1 -1
- package/core/loginOrGoToAuthServer.d.ts +1 -0
- package/core/loginOrGoToAuthServer.js +20 -9
- package/core/loginOrGoToAuthServer.js.map +1 -1
- package/entrypoint.d.ts +0 -1
- package/entrypoint.js +1 -3
- package/entrypoint.js.map +1 -1
- package/esm/core/StateDataCookie.d.ts +34 -0
- package/esm/core/StateDataCookie.js +135 -0
- package/esm/core/StateDataCookie.js.map +1 -0
- package/esm/core/createOidc.js +23 -5
- package/esm/core/createOidc.js.map +1 -1
- package/esm/core/earlyInit.d.ts +0 -1
- package/esm/core/earlyInit.js +4 -13
- package/esm/core/earlyInit.js.map +1 -1
- package/esm/core/loginOrGoToAuthServer.d.ts +1 -0
- package/esm/core/loginOrGoToAuthServer.js +20 -9
- package/esm/core/loginOrGoToAuthServer.js.map +1 -1
- package/esm/entrypoint.d.ts +0 -1
- package/esm/entrypoint.js +0 -1
- package/esm/entrypoint.js.map +1 -1
- package/esm/tanstack-start/react/createOidcSpaApi.js +2 -0
- package/esm/tanstack-start/react/createOidcSpaApi.js.map +1 -1
- package/esm/tanstack-start/react/index.d.ts +1 -1
- package/esm/tanstack-start/react/index.js +1 -1
- package/esm/tanstack-start/react/index.js.map +1 -1
- package/esm/tanstack-start/react/withOidcSpaServerEntry.d.ts +5 -0
- package/esm/tanstack-start/react/withOidcSpaServerEntry.js +38 -0
- package/esm/tanstack-start/react/withOidcSpaServerEntry.js.map +1 -0
- package/package.json +1 -1
- package/src/core/StateDataCookie.ts +217 -0
- package/src/core/createOidc.ts +32 -4
- package/src/core/earlyInit.ts +3 -17
- package/src/core/loginOrGoToAuthServer.ts +25 -9
- package/src/entrypoint.ts +0 -1
- package/src/tanstack-start/react/createOidcSpaApi.tsx +3 -0
- package/src/tanstack-start/react/index.ts +1 -1
- package/src/tanstack-start/react/withOidcSpaServerEntry.ts +60 -0
- package/src/vite-plugin/handleClientEntrypoint.ts +10 -67
- package/src/vite-plugin/handleServerEntrypoint.ts +129 -0
- package/src/vite-plugin/transformTanstackRouterCreateFileRoute.ts +0 -64
- package/src/vite-plugin/utils.ts +64 -0
- package/src/vite-plugin/vite-plugin.ts +31 -10
- package/vite-plugin/handleClientEntrypoint.d.ts +7 -5
- package/vite-plugin/handleClientEntrypoint.js +16 -62
- package/vite-plugin/handleClientEntrypoint.js.map +1 -1
- package/vite-plugin/handleServerEntrypoint.d.ts +12 -0
- package/vite-plugin/handleServerEntrypoint.js +113 -0
- package/vite-plugin/handleServerEntrypoint.js.map +1 -0
- package/vite-plugin/transformTanstackRouterCreateFileRoute.js +0 -39
- package/vite-plugin/transformTanstackRouterCreateFileRoute.js.map +1 -1
- package/vite-plugin/utils.d.ts +12 -0
- package/vite-plugin/utils.js +88 -0
- package/vite-plugin/utils.js.map +1 -0
- package/vite-plugin/vite-plugin.d.ts +1 -1
- package/vite-plugin/vite-plugin.js +21 -5
- package/vite-plugin/vite-plugin.js.map +1 -1
- package/core/requiredPostHydrationReplaceNavigationUrl.d.ts +0 -6
- package/core/requiredPostHydrationReplaceNavigationUrl.js +0 -12
- package/core/requiredPostHydrationReplaceNavigationUrl.js.map +0 -1
- package/esm/core/requiredPostHydrationReplaceNavigationUrl.d.ts +0 -6
- package/esm/core/requiredPostHydrationReplaceNavigationUrl.js +0 -8
- package/esm/core/requiredPostHydrationReplaceNavigationUrl.js.map +0 -1
- package/esm/tanstack-start/react/withHandlingOidcPostLoginNavigation.d.ts +0 -2
- package/esm/tanstack-start/react/withHandlingOidcPostLoginNavigation.js +0 -36
- package/esm/tanstack-start/react/withHandlingOidcPostLoginNavigation.js.map +0 -1
- package/src/core/requiredPostHydrationReplaceNavigationUrl.ts +0 -11
- package/src/tanstack-start/react/withHandlingOidcPostLoginNavigation.tsx +0 -46
|
@@ -2,15 +2,13 @@ import type { Plugin, TransformResult } from "vite";
|
|
|
2
2
|
import { assert } from "../tools/tsafe/assert";
|
|
3
3
|
import type { Param0 } from "../tools/tsafe/Param0";
|
|
4
4
|
import type { oidcEarlyInit } from "../entrypoint";
|
|
5
|
-
import {
|
|
5
|
+
import { createHandleClientEntrypoint } from "./handleClientEntrypoint";
|
|
6
|
+
import { createHandleServerEntrypoint } from "./handleServerEntrypoint";
|
|
6
7
|
import { manageOptimizedDeps } from "./manageOptimizedDeps";
|
|
7
8
|
import { transformCreateFileRoute } from "./transformTanstackRouterCreateFileRoute";
|
|
8
9
|
import { getProjectType, type ProjectType } from "./projectType";
|
|
9
10
|
|
|
10
|
-
export type OidcSpaVitePluginParams = Omit<
|
|
11
|
-
Param0<typeof oidcEarlyInit>,
|
|
12
|
-
"isPostLoginRedirectManual" | "BASE_URL"
|
|
13
|
-
>;
|
|
11
|
+
export type OidcSpaVitePluginParams = Omit<Param0<typeof oidcEarlyInit>, "BASE_URL">;
|
|
14
12
|
|
|
15
13
|
export function oidcSpa(
|
|
16
14
|
params: OidcSpaVitePluginParams = {
|
|
@@ -19,7 +17,12 @@ export function oidcSpa(
|
|
|
19
17
|
freezeWebSocket: true
|
|
20
18
|
}
|
|
21
19
|
) {
|
|
22
|
-
let
|
|
20
|
+
let load_handleClientEntrypoint:
|
|
21
|
+
| ReturnType<typeof createHandleClientEntrypoint>["load_handleClientEntrypoint"]
|
|
22
|
+
| undefined = undefined;
|
|
23
|
+
let load_handleServerEntrypoint:
|
|
24
|
+
| ReturnType<typeof createHandleServerEntrypoint>["load_handleServerEntrypoint"]
|
|
25
|
+
| undefined = undefined;
|
|
23
26
|
|
|
24
27
|
let projectType: ProjectType | undefined = undefined;
|
|
25
28
|
|
|
@@ -44,11 +47,16 @@ export function oidcSpa(
|
|
|
44
47
|
pluginNames: resolvedConfig.plugins.map(({ name }) => name)
|
|
45
48
|
});
|
|
46
49
|
|
|
47
|
-
|
|
50
|
+
load_handleClientEntrypoint = createHandleClientEntrypoint({
|
|
48
51
|
oidcSpaVitePluginParams: params,
|
|
49
52
|
resolvedConfig,
|
|
50
53
|
projectType
|
|
51
|
-
});
|
|
54
|
+
}).load_handleClientEntrypoint;
|
|
55
|
+
|
|
56
|
+
load_handleServerEntrypoint = createHandleServerEntrypoint({
|
|
57
|
+
resolvedConfig,
|
|
58
|
+
projectType
|
|
59
|
+
}).load_handleServerEntrypoint;
|
|
52
60
|
},
|
|
53
61
|
transform(code, id) {
|
|
54
62
|
let transformed: TransformResult | null = null;
|
|
@@ -69,10 +77,23 @@ export function oidcSpa(
|
|
|
69
77
|
return transformed;
|
|
70
78
|
},
|
|
71
79
|
async load(id) {
|
|
72
|
-
|
|
80
|
+
{
|
|
81
|
+
assert(load_handleClientEntrypoint !== undefined);
|
|
82
|
+
|
|
83
|
+
const r = await load_handleClientEntrypoint({
|
|
84
|
+
id,
|
|
85
|
+
pluginContext: this
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
if (r !== null) {
|
|
89
|
+
return r;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
73
92
|
|
|
74
93
|
{
|
|
75
|
-
|
|
94
|
+
assert(load_handleServerEntrypoint !== undefined);
|
|
95
|
+
|
|
96
|
+
const r = await load_handleServerEntrypoint({
|
|
76
97
|
id,
|
|
77
98
|
pluginContext: this
|
|
78
99
|
});
|
|
@@ -2,11 +2,13 @@ import type { OidcSpaVitePluginParams } from "./vite-plugin";
|
|
|
2
2
|
import type { ResolvedConfig } from "vite";
|
|
3
3
|
import type { PluginContext } from "rollup";
|
|
4
4
|
import type { ProjectType } from "./projectType";
|
|
5
|
-
export declare function
|
|
5
|
+
export declare function createHandleClientEntrypoint(params: {
|
|
6
6
|
oidcSpaVitePluginParams: OidcSpaVitePluginParams;
|
|
7
7
|
resolvedConfig: ResolvedConfig;
|
|
8
8
|
projectType: ProjectType;
|
|
9
|
-
}):
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
}): {
|
|
10
|
+
load_handleClientEntrypoint: (params: {
|
|
11
|
+
id: string;
|
|
12
|
+
pluginContext: PluginContext;
|
|
13
|
+
}) => Promise<null | string>;
|
|
14
|
+
};
|
|
@@ -33,13 +33,11 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.
|
|
36
|
+
exports.createHandleClientEntrypoint = createHandleClientEntrypoint;
|
|
37
37
|
const node_fs_1 = require("node:fs");
|
|
38
|
-
const node_fs_2 = require("node:fs");
|
|
39
38
|
const path = __importStar(require("node:path"));
|
|
40
|
-
const node_url_1 = require("node:url");
|
|
41
|
-
const vite_1 = require("vite");
|
|
42
39
|
const assert_1 = require("../tools/tsafe/assert");
|
|
40
|
+
const utils_1 = require("./utils");
|
|
43
41
|
const ORIGINAL_QUERY_PARAM = "oidc-spa-original";
|
|
44
42
|
const GENERIC_ENTRY_CANDIDATES = ["src/main.tsx", "src/main.ts", "src/main.jsx", "src/main.js"];
|
|
45
43
|
const REACT_ROUTER_ENTRY_CANDIDATES = [
|
|
@@ -49,16 +47,16 @@ const REACT_ROUTER_ENTRY_CANDIDATES = [
|
|
|
49
47
|
"entry.client.js"
|
|
50
48
|
];
|
|
51
49
|
const TANSTACK_ENTRY_CANDIDATES = ["client.tsx", "client.ts", "client.jsx", "client.js"];
|
|
52
|
-
function
|
|
50
|
+
function createHandleClientEntrypoint(params) {
|
|
53
51
|
const { oidcSpaVitePluginParams, resolvedConfig, projectType } = params;
|
|
54
52
|
const entryResolution = resolveEntryForProject({
|
|
55
53
|
config: resolvedConfig,
|
|
56
54
|
projectType
|
|
57
55
|
});
|
|
58
|
-
async function
|
|
56
|
+
async function load_handleClientEntrypoint(params) {
|
|
59
57
|
const { id, pluginContext } = params;
|
|
60
|
-
const { path: rawPath, queryParams } = splitId(id);
|
|
61
|
-
const normalizedRequestPath = normalizeRequestPath(rawPath);
|
|
58
|
+
const { path: rawPath, queryParams } = (0, utils_1.splitId)(id);
|
|
59
|
+
const normalizedRequestPath = (0, utils_1.normalizeRequestPath)(rawPath);
|
|
62
60
|
if (!normalizedRequestPath) {
|
|
63
61
|
return null;
|
|
64
62
|
}
|
|
@@ -80,7 +78,6 @@ function createLoadHandleEntrypoint(params) {
|
|
|
80
78
|
` freezeWebSocket: ${freezeWebSocket},`,
|
|
81
79
|
` freezePromise: ${freezePromise},`,
|
|
82
80
|
` safeMode: ${safeMode},`,
|
|
83
|
-
` isPostLoginRedirectManual: ${projectType === "tanstack-start"},`,
|
|
84
81
|
` BASE_URL: "${resolvedConfig.base}"`,
|
|
85
82
|
`});`,
|
|
86
83
|
``,
|
|
@@ -92,25 +89,25 @@ function createLoadHandleEntrypoint(params) {
|
|
|
92
89
|
.join("\n");
|
|
93
90
|
return stubSourceCache;
|
|
94
91
|
}
|
|
95
|
-
return
|
|
92
|
+
return { load_handleClientEntrypoint };
|
|
96
93
|
}
|
|
97
94
|
function resolveEntryForProject({ config, projectType }) {
|
|
98
95
|
const root = config.root;
|
|
99
96
|
switch (projectType) {
|
|
100
97
|
case "tanstack-start": {
|
|
101
|
-
const candidate = resolveCandidate({
|
|
98
|
+
const candidate = (0, utils_1.resolveCandidate)({
|
|
102
99
|
root,
|
|
103
100
|
subDirectories: ["src"],
|
|
104
101
|
filenames: TANSTACK_ENTRY_CANDIDATES
|
|
105
102
|
});
|
|
106
103
|
const entryPath = candidate ??
|
|
107
|
-
resolvePackageFile("@tanstack/react-start", [
|
|
104
|
+
(0, utils_1.resolvePackageFile)("@tanstack/react-start", [
|
|
108
105
|
"dist",
|
|
109
106
|
"plugin",
|
|
110
107
|
"default-entry",
|
|
111
108
|
"client.tsx"
|
|
112
109
|
]);
|
|
113
|
-
const normalized = normalizeAbsolute(entryPath);
|
|
110
|
+
const normalized = (0, utils_1.normalizeAbsolute)(entryPath);
|
|
114
111
|
const resolution = {
|
|
115
112
|
absolutePath: entryPath,
|
|
116
113
|
normalizedPath: normalized,
|
|
@@ -119,19 +116,19 @@ function resolveEntryForProject({ config, projectType }) {
|
|
|
119
116
|
return resolution;
|
|
120
117
|
}
|
|
121
118
|
case "react-router-framework": {
|
|
122
|
-
const candidate = resolveCandidate({
|
|
119
|
+
const candidate = (0, utils_1.resolveCandidate)({
|
|
123
120
|
root,
|
|
124
121
|
subDirectories: ["app"],
|
|
125
122
|
filenames: REACT_ROUTER_ENTRY_CANDIDATES
|
|
126
123
|
});
|
|
127
124
|
const entryPath = candidate ??
|
|
128
|
-
resolvePackageFile("@react-router/dev", [
|
|
125
|
+
(0, utils_1.resolvePackageFile)("@react-router/dev", [
|
|
129
126
|
"dist",
|
|
130
127
|
"config",
|
|
131
128
|
"defaults",
|
|
132
129
|
"entry.client.tsx"
|
|
133
130
|
]);
|
|
134
|
-
const normalized = normalizeAbsolute(entryPath);
|
|
131
|
+
const normalized = (0, utils_1.normalizeAbsolute)(entryPath);
|
|
135
132
|
const resolution = {
|
|
136
133
|
absolutePath: entryPath,
|
|
137
134
|
normalizedPath: normalized,
|
|
@@ -140,13 +137,13 @@ function resolveEntryForProject({ config, projectType }) {
|
|
|
140
137
|
return resolution;
|
|
141
138
|
}
|
|
142
139
|
case "other": {
|
|
143
|
-
const candidate = resolveCandidate({
|
|
140
|
+
const candidate = (0, utils_1.resolveCandidate)({
|
|
144
141
|
root,
|
|
145
142
|
subDirectories: ["."],
|
|
146
143
|
filenames: GENERIC_ENTRY_CANDIDATES
|
|
147
144
|
});
|
|
148
145
|
(0, assert_1.assert)(candidate !== undefined);
|
|
149
|
-
const normalized = normalizeAbsolute(candidate);
|
|
146
|
+
const normalized = (0, utils_1.normalizeAbsolute)(candidate);
|
|
150
147
|
const resolution = {
|
|
151
148
|
absolutePath: candidate,
|
|
152
149
|
normalizedPath: normalized,
|
|
@@ -160,49 +157,6 @@ function resolveEntryForProject({ config, projectType }) {
|
|
|
160
157
|
}
|
|
161
158
|
function loadOriginalModule(entry, context) {
|
|
162
159
|
entry.watchFiles.forEach(file => context.addWatchFile(file));
|
|
163
|
-
return
|
|
164
|
-
}
|
|
165
|
-
function resolveCandidate({ root, subDirectories, filenames }) {
|
|
166
|
-
for (const subDirectory of subDirectories) {
|
|
167
|
-
for (const filename of filenames) {
|
|
168
|
-
const candidate = path.resolve(root, subDirectory, filename);
|
|
169
|
-
if ((0, node_fs_1.existsSync)(candidate)) {
|
|
170
|
-
return candidate;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
return undefined;
|
|
175
|
-
}
|
|
176
|
-
function resolvePackageFile(packageName, segments) {
|
|
177
|
-
const pkgPath = require.resolve(`${packageName}/package.json`);
|
|
178
|
-
return path.resolve(path.dirname(pkgPath), ...segments);
|
|
179
|
-
}
|
|
180
|
-
function normalizeAbsolute(filePath) {
|
|
181
|
-
return (0, vite_1.normalizePath)(filePath);
|
|
182
|
-
}
|
|
183
|
-
function splitId(id) {
|
|
184
|
-
const queryIndex = id.indexOf("?");
|
|
185
|
-
if (queryIndex === -1) {
|
|
186
|
-
return { path: id, queryParams: new URLSearchParams() };
|
|
187
|
-
}
|
|
188
|
-
const pathPart = id.slice(0, queryIndex);
|
|
189
|
-
const queryString = id.slice(queryIndex + 1);
|
|
190
|
-
return { path: pathPart, queryParams: new URLSearchParams(queryString) };
|
|
191
|
-
}
|
|
192
|
-
function normalizeRequestPath(id) {
|
|
193
|
-
let requestPath = id;
|
|
194
|
-
if (requestPath.startsWith("\0")) {
|
|
195
|
-
requestPath = requestPath.slice(1);
|
|
196
|
-
}
|
|
197
|
-
if (requestPath.startsWith("/@fs/")) {
|
|
198
|
-
requestPath = requestPath.slice("/@fs/".length);
|
|
199
|
-
}
|
|
200
|
-
else if (requestPath.startsWith("file://")) {
|
|
201
|
-
requestPath = (0, node_url_1.fileURLToPath)(requestPath);
|
|
202
|
-
}
|
|
203
|
-
if (path.isAbsolute(requestPath) || requestPath.startsWith(".")) {
|
|
204
|
-
return (0, vite_1.normalizePath)(requestPath);
|
|
205
|
-
}
|
|
206
|
-
return (0, vite_1.normalizePath)(requestPath);
|
|
160
|
+
return node_fs_1.promises.readFile(entry.absolutePath, "utf8");
|
|
207
161
|
}
|
|
208
162
|
//# sourceMappingURL=handleClientEntrypoint.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleClientEntrypoint.js","sourceRoot":"","sources":["../src/vite-plugin/handleClientEntrypoint.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"handleClientEntrypoint.js","sourceRoot":"","sources":["../src/vite-plugin/handleClientEntrypoint.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,oEAgEC;AAhGD,qCAAyC;AACzC,gDAAkC;AAClC,kDAA+C;AAG/C,mCAMiB;AAQjB,MAAM,oBAAoB,GAAG,mBAAmB,CAAC;AAEjD,MAAM,wBAAwB,GAAG,CAAC,cAAc,EAAE,aAAa,EAAE,cAAc,EAAE,aAAa,CAAC,CAAC;AAEhG,MAAM,6BAA6B,GAAG;IAClC,kBAAkB;IAClB,iBAAiB;IACjB,kBAAkB;IAClB,iBAAiB;CACpB,CAAC;AAEF,MAAM,yBAAyB,GAAG,CAAC,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,CAAC,CAAC;AAEzF,SAAgB,4BAA4B,CAAC,MAI5C;IACG,MAAM,EAAE,uBAAuB,EAAE,cAAc,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC;IAExE,MAAM,eAAe,GAAG,sBAAsB,CAAC;QAC3C,MAAM,EAAE,cAAc;QACtB,WAAW;KACd,CAAC,CAAC;IAEH,KAAK,UAAU,2BAA2B,CAAC,MAG1C;QACG,MAA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C,CAAC;YAEP,MAAM,UAAU,GAAG,IAAA,yBAAiB,EAAC,SAAS,CAAC,CAAC;YAEhD,MAAM,UAAU,GAAoB;gBAChC,YAAY,EAAE,SAAS;gBACvB,cAAc,EAAE,UAAU;gBAC1B,UAAU,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE;aAC3C,CAAC;YAEF,OAAO,UAAU,CAAC;QACtB,CAAC;QAED,KAAK,OAAO,CAAC,CAAC,CAAC;YACX,MAAM,SAAS,GAAG,IAAA,wBAAgB,EAAC;gBAC/B,IAAI;gBACJ,cAAc,EAAE,CAAC,GAAG,CAAC;gBACrB,SAAS,EAAE,wBAAwB;aACtC,CAAC,CAAC;YAEH,IAAA,eAAM,EAAC,SAAS,KAAK,SAAS,CAAC,CAAC;YAEhC,MAAM,UAAU,GAAG,IAAA,yBAAiB,EAAC,SAAS,CAAC,CAAC;YAEhD,MAAM,UAAU,GAAoB;gBAChC,YAAY,EAAE,SAAS;gBACvB,cAAc,EAAE,UAAU;gBAC1B,UAAU,EAAE,CAAC,SAAS,CAAC;aAC1B,CAAC;YAEF,OAAO,UAAU,CAAC;QACtB,CAAC;QAED;YACI,IAAA,eAAM,EAAoC,KAAK,CAAC,CAAC;IACzD,CAAC;AACL,CAAC;AAED,SAAS,kBAAkB,CACvB,KAAsB,EACtB,OAA2C;IAE3C,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;IAC7D,OAAO,kBAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;AACnD,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ResolvedConfig } from "vite";
|
|
2
|
+
import type { PluginContext } from "rollup";
|
|
3
|
+
import type { ProjectType } from "./projectType";
|
|
4
|
+
export declare function createHandleServerEntrypoint(params: {
|
|
5
|
+
resolvedConfig: ResolvedConfig;
|
|
6
|
+
projectType: ProjectType;
|
|
7
|
+
}): {
|
|
8
|
+
load_handleServerEntrypoint: (params: {
|
|
9
|
+
id: string;
|
|
10
|
+
pluginContext: PluginContext;
|
|
11
|
+
}) => Promise<null | string>;
|
|
12
|
+
};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.createHandleServerEntrypoint = createHandleServerEntrypoint;
|
|
37
|
+
const node_fs_1 = require("node:fs");
|
|
38
|
+
const path = __importStar(require("node:path"));
|
|
39
|
+
const assert_1 = require("../tools/tsafe/assert");
|
|
40
|
+
const utils_1 = require("./utils");
|
|
41
|
+
const ORIGINAL_QUERY_PARAM = "oidc-spa-original";
|
|
42
|
+
function createHandleServerEntrypoint(params) {
|
|
43
|
+
const { resolvedConfig, projectType } = params;
|
|
44
|
+
const entryResolution = resolveEntryForProject({
|
|
45
|
+
config: resolvedConfig,
|
|
46
|
+
projectType
|
|
47
|
+
});
|
|
48
|
+
async function load_handleServerEntrypoint(params) {
|
|
49
|
+
if (entryResolution === undefined) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
const { id, pluginContext } = params;
|
|
53
|
+
const { path: rawPath, queryParams } = (0, utils_1.splitId)(id);
|
|
54
|
+
const normalizedRequestPath = (0, utils_1.normalizeRequestPath)(rawPath);
|
|
55
|
+
if (!normalizedRequestPath) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
if (normalizedRequestPath !== entryResolution.normalizedPath) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
const isOriginalRequest = queryParams.getAll(ORIGINAL_QUERY_PARAM).includes("true");
|
|
62
|
+
if (isOriginalRequest) {
|
|
63
|
+
return loadOriginalModule(entryResolution, pluginContext);
|
|
64
|
+
}
|
|
65
|
+
entryResolution.watchFiles.forEach(file => pluginContext.addWatchFile(file));
|
|
66
|
+
const stubSourceCache = [
|
|
67
|
+
`import serverEntry_original from "./${path.basename(entryResolution.absolutePath)}?${ORIGINAL_QUERY_PARAM}=true";`,
|
|
68
|
+
`import { __withOidcSpaServerEntry } from "oidc-spa/react-tanstack-start";`,
|
|
69
|
+
``,
|
|
70
|
+
`const serverEntry = __withOidcSpaServerEntry(serverEntry_original);`,
|
|
71
|
+
``,
|
|
72
|
+
`export default serverEntry;`
|
|
73
|
+
].join("\n");
|
|
74
|
+
return stubSourceCache;
|
|
75
|
+
}
|
|
76
|
+
return { load_handleServerEntrypoint };
|
|
77
|
+
}
|
|
78
|
+
function resolveEntryForProject({ config, projectType }) {
|
|
79
|
+
const root = config.root;
|
|
80
|
+
switch (projectType) {
|
|
81
|
+
case "tanstack-start": {
|
|
82
|
+
const candidate = (0, utils_1.resolveCandidate)({
|
|
83
|
+
root,
|
|
84
|
+
subDirectories: ["src"],
|
|
85
|
+
filenames: ["server.ts", "server.js", "server.tsx", "server.jsx"]
|
|
86
|
+
});
|
|
87
|
+
const entryPath = candidate ??
|
|
88
|
+
(0, utils_1.resolvePackageFile)("@tanstack/react-start", [
|
|
89
|
+
"dist",
|
|
90
|
+
"plugin",
|
|
91
|
+
"default-entry",
|
|
92
|
+
"server.ts"
|
|
93
|
+
]);
|
|
94
|
+
const normalized = (0, utils_1.normalizeAbsolute)(entryPath);
|
|
95
|
+
const resolution = {
|
|
96
|
+
absolutePath: entryPath,
|
|
97
|
+
normalizedPath: normalized,
|
|
98
|
+
watchFiles: [entryPath]
|
|
99
|
+
};
|
|
100
|
+
return resolution;
|
|
101
|
+
}
|
|
102
|
+
case "react-router-framework":
|
|
103
|
+
case "other":
|
|
104
|
+
return undefined;
|
|
105
|
+
default:
|
|
106
|
+
(0, assert_1.assert)(false);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function loadOriginalModule(entry, context) {
|
|
110
|
+
entry.watchFiles.forEach(file => context.addWatchFile(file));
|
|
111
|
+
return node_fs_1.promises.readFile(entry.absolutePath, "utf8");
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=handleServerEntrypoint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handleServerEntrypoint.js","sourceRoot":"","sources":["../src/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CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;IAC7D,OAAO,kBAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;AACnD,CAAC"}
|
|
@@ -6,8 +6,6 @@ const babel_1 = require("../vendor/build-runtime/babel");
|
|
|
6
6
|
const DISABLE_SSR_SPECIFIER = "__disableSsrIfLoginEnforced";
|
|
7
7
|
const DISABLE_SSR_SOURCE = "oidc-spa/react-tanstack-start";
|
|
8
8
|
const CREATE_FILE_ROUTE_IDENTIFIER = "createFileRoute";
|
|
9
|
-
const POST_LOGIN_IMPORT_SPECIFIER = "withHandlingOidcPostLoginNavigation";
|
|
10
|
-
const POST_LOGIN_IMPORT_SOURCE = "oidc-spa/react-tanstack-start";
|
|
11
9
|
function transformCreateFileRoute(params) {
|
|
12
10
|
const { code, id } = params;
|
|
13
11
|
const cleanId = sanitizeId(id);
|
|
@@ -27,9 +25,7 @@ function transformCreateFileRoute(params) {
|
|
|
27
25
|
const magicString = new magic_string_1.MagicString(code);
|
|
28
26
|
let hasCreateFileRouteImport = false;
|
|
29
27
|
let hasEnableImport = false;
|
|
30
|
-
let hasPostLoginImport = false;
|
|
31
28
|
let requiresEnableImport = false;
|
|
32
|
-
let requiresPostLoginImport = false;
|
|
33
29
|
let lastImportEnd;
|
|
34
30
|
let mutated = false;
|
|
35
31
|
(0, babel_1.babelTraverse)(ast, {
|
|
@@ -54,12 +50,6 @@ function transformCreateFileRoute(params) {
|
|
|
54
50
|
hasEnableImport = true;
|
|
55
51
|
}
|
|
56
52
|
}
|
|
57
|
-
if (sourceValue === POST_LOGIN_IMPORT_SOURCE) {
|
|
58
|
-
if (path.node.specifiers.some(specifier => babel_1.babelTypes.isImportSpecifier(specifier) &&
|
|
59
|
-
babel_1.babelTypes.isIdentifier(specifier.imported, { name: POST_LOGIN_IMPORT_SPECIFIER }))) {
|
|
60
|
-
hasPostLoginImport = true;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
53
|
},
|
|
64
54
|
CallExpression(path) {
|
|
65
55
|
const callee = path.get("callee");
|
|
@@ -90,24 +80,6 @@ function transformCreateFileRoute(params) {
|
|
|
90
80
|
localMutated = true;
|
|
91
81
|
}
|
|
92
82
|
}
|
|
93
|
-
const innerArgs = callee.node.arguments ?? [];
|
|
94
|
-
const isRootRoute = innerArgs.length > 0 && babel_1.babelTypes.isStringLiteral(innerArgs[0]) && innerArgs[0].value === "/";
|
|
95
|
-
if (isRootRoute) {
|
|
96
|
-
const componentProp = findComponentProperty(configNode);
|
|
97
|
-
if (componentProp) {
|
|
98
|
-
const valueNode = componentProp.value;
|
|
99
|
-
if (!isWrappedWithHandling(valueNode)) {
|
|
100
|
-
const start = valueNode.start ?? undefined;
|
|
101
|
-
const end = valueNode.end ?? undefined;
|
|
102
|
-
if (typeof start === "number" && typeof end === "number") {
|
|
103
|
-
const original = code.slice(start, end);
|
|
104
|
-
magicString.overwrite(start, end, `${POST_LOGIN_IMPORT_SPECIFIER}(${original})`);
|
|
105
|
-
requiresPostLoginImport = true;
|
|
106
|
-
localMutated = true;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
83
|
if (localMutated) {
|
|
112
84
|
mutated = true;
|
|
113
85
|
}
|
|
@@ -120,9 +92,6 @@ function transformCreateFileRoute(params) {
|
|
|
120
92
|
if (requiresEnableImport && !hasEnableImport) {
|
|
121
93
|
importStatements.push(`import { ${DISABLE_SSR_SPECIFIER} } from "${DISABLE_SSR_SOURCE}";`);
|
|
122
94
|
}
|
|
123
|
-
if (requiresPostLoginImport && !hasPostLoginImport) {
|
|
124
|
-
importStatements.push(`import { ${POST_LOGIN_IMPORT_SPECIFIER} } from "${POST_LOGIN_IMPORT_SOURCE}";`);
|
|
125
|
-
}
|
|
126
95
|
if (importStatements.length > 0) {
|
|
127
96
|
const insertionPoint = lastImportEnd ?? 0;
|
|
128
97
|
const prefix = insertionPoint === 0 ? "" : "\n";
|
|
@@ -134,11 +103,6 @@ function transformCreateFileRoute(params) {
|
|
|
134
103
|
map: magicString.generateMap({ hires: true, source: cleanId })
|
|
135
104
|
};
|
|
136
105
|
}
|
|
137
|
-
function findComponentProperty(node) {
|
|
138
|
-
return node.properties.find(prop => babel_1.babelTypes.isObjectProperty(prop) &&
|
|
139
|
-
((babel_1.babelTypes.isIdentifier(prop.key) && prop.key.name === "component") ||
|
|
140
|
-
(babel_1.babelTypes.isStringLiteral(prop.key) && prop.key.value === "component")));
|
|
141
|
-
}
|
|
142
106
|
function objectContainsLoaderOrBeforeLoad(node) {
|
|
143
107
|
return node.properties.some(prop => {
|
|
144
108
|
if (!babel_1.babelTypes.isObjectProperty(prop)) {
|
|
@@ -154,9 +118,6 @@ function objectContainsLoaderOrBeforeLoad(node) {
|
|
|
154
118
|
return false;
|
|
155
119
|
});
|
|
156
120
|
}
|
|
157
|
-
function isWrappedWithHandling(node) {
|
|
158
|
-
return (babel_1.babelTypes.isCallExpression(node) && babel_1.babelTypes.isIdentifier(node.callee, { name: POST_LOGIN_IMPORT_SPECIFIER }));
|
|
159
|
-
}
|
|
160
121
|
function isCandidateFile(id) {
|
|
161
122
|
if (id.includes("node_modules")) {
|
|
162
123
|
return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transformTanstackRouterCreateFileRoute.js","sourceRoot":"","sources":["../src/vite-plugin/transformTanstackRouterCreateFileRoute.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"transformTanstackRouterCreateFileRoute.js","sourceRoot":"","sources":["../src/vite-plugin/transformTanstackRouterCreateFileRoute.ts"],"names":[],"mappings":";;AAiBA,4DA4HC;AA7ID,uEAAmE;AACnE,yDAA4F;AAE5F,MAAM,qBAAqB,GAAG,6BAA6B,CAAC;AAC5D,MAAM,kBAAkB,GAAG,+BAA+B,CAAC;AAC3D,MAAM,4BAA4B,GAAG,iBAAiB,CAAC;AAYv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AO,CAAC,GAAG,CAAC,CAAC;IACnC,IAAI,UAAU,KAAK,CAAC,CAAC,EAAE,CAAC;QACpB,OAAO,EAAE,CAAC;IACd,CAAC;IACD,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare function resolveCandidate({ root, subDirectories, filenames }: {
|
|
2
|
+
root: string;
|
|
3
|
+
subDirectories: string[];
|
|
4
|
+
filenames: string[];
|
|
5
|
+
}): string | undefined;
|
|
6
|
+
export declare function resolvePackageFile(packageName: string, segments: string[]): string;
|
|
7
|
+
export declare function normalizeAbsolute(filePath: string): string;
|
|
8
|
+
export declare function splitId(id: string): {
|
|
9
|
+
path: string;
|
|
10
|
+
queryParams: URLSearchParams;
|
|
11
|
+
};
|
|
12
|
+
export declare function normalizeRequestPath(id: string): string;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.resolveCandidate = resolveCandidate;
|
|
37
|
+
exports.resolvePackageFile = resolvePackageFile;
|
|
38
|
+
exports.normalizeAbsolute = normalizeAbsolute;
|
|
39
|
+
exports.splitId = splitId;
|
|
40
|
+
exports.normalizeRequestPath = normalizeRequestPath;
|
|
41
|
+
const node_fs_1 = require("node:fs");
|
|
42
|
+
const path = __importStar(require("node:path"));
|
|
43
|
+
const node_url_1 = require("node:url");
|
|
44
|
+
const vite_1 = require("vite");
|
|
45
|
+
function resolveCandidate({ root, subDirectories, filenames }) {
|
|
46
|
+
for (const subDirectory of subDirectories) {
|
|
47
|
+
for (const filename of filenames) {
|
|
48
|
+
const candidate = path.resolve(root, subDirectory, filename);
|
|
49
|
+
if ((0, node_fs_1.existsSync)(candidate)) {
|
|
50
|
+
return candidate;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
function resolvePackageFile(packageName, segments) {
|
|
57
|
+
const pkgPath = require.resolve(`${packageName}/package.json`);
|
|
58
|
+
return path.resolve(path.dirname(pkgPath), ...segments);
|
|
59
|
+
}
|
|
60
|
+
function normalizeAbsolute(filePath) {
|
|
61
|
+
return (0, vite_1.normalizePath)(filePath);
|
|
62
|
+
}
|
|
63
|
+
function splitId(id) {
|
|
64
|
+
const queryIndex = id.indexOf("?");
|
|
65
|
+
if (queryIndex === -1) {
|
|
66
|
+
return { path: id, queryParams: new URLSearchParams() };
|
|
67
|
+
}
|
|
68
|
+
const pathPart = id.slice(0, queryIndex);
|
|
69
|
+
const queryString = id.slice(queryIndex + 1);
|
|
70
|
+
return { path: pathPart, queryParams: new URLSearchParams(queryString) };
|
|
71
|
+
}
|
|
72
|
+
function normalizeRequestPath(id) {
|
|
73
|
+
let requestPath = id;
|
|
74
|
+
if (requestPath.startsWith("\0")) {
|
|
75
|
+
requestPath = requestPath.slice(1);
|
|
76
|
+
}
|
|
77
|
+
if (requestPath.startsWith("/@fs/")) {
|
|
78
|
+
requestPath = requestPath.slice("/@fs/".length);
|
|
79
|
+
}
|
|
80
|
+
else if (requestPath.startsWith("file://")) {
|
|
81
|
+
requestPath = (0, node_url_1.fileURLToPath)(requestPath);
|
|
82
|
+
}
|
|
83
|
+
if (path.isAbsolute(requestPath) || requestPath.startsWith(".")) {
|
|
84
|
+
return (0, vite_1.normalizePath)(requestPath);
|
|
85
|
+
}
|
|
86
|
+
return (0, vite_1.normalizePath)(requestPath);
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/vite-plugin/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,4CAkBC;AAED,gDAGC;AAED,8CAEC;AAED,0BASC;AAED,oDAkBC;AA/DD,qCAAqC;AACrC,gDAAkC;AAClC,uCAAyC;AACzC,+BAAqC;AAErC,SAAgB,gBAAgB,CAAC,EAC7B,IAAI,EACJ,cAAc,EACd,SAAS,EAKZ;IACG,KAAK,MAAM,YAAY,IAAI,cAAc,EAAE,CAAC;QACxC,KAAK,MAAM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,IAAI,CAAC,EAAE,CAAC;QAC/B,WAAW,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACvC,CAAC;IAED,IAAI,WAAW,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QAClC,WAAW,GAAG,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACpD,CAAC;SAAM,IAAI,WAAW,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QAC3C,WAAW,GAAG,IAAA,wBAAa,EAAC,WAAW,CAAC,CAAC;IAC7C,CAAC;IAED,IAAI,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,WAAW,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC9D,OAAO,IAAA,oBAAa,EAAC,WAAW,CAAC,CAAC;IACtC,CAAC;IAED,OAAO,IAAA,oBAAa,EAAC,WAAW,CAAC,CAAC;AACtC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Plugin } from "vite";
|
|
2
2
|
import type { Param0 } from "../tools/tsafe/Param0";
|
|
3
3
|
import type { oidcEarlyInit } from "../entrypoint";
|
|
4
|
-
export type OidcSpaVitePluginParams = Omit<Param0<typeof oidcEarlyInit>, "
|
|
4
|
+
export type OidcSpaVitePluginParams = Omit<Param0<typeof oidcEarlyInit>, "BASE_URL">;
|
|
5
5
|
export declare function oidcSpa(params?: OidcSpaVitePluginParams): Plugin<any>;
|