@emulators/adapter-nuxt 0.0.0 → 0.9.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/LICENSE +202 -0
- package/README.md +119 -1
- package/dist/index.d.ts +47 -0
- package/dist/index.js +320 -0
- package/dist/index.js.map +1 -0
- package/package.json +38 -6
- package/index.js +0 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding any notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. Please also get an informed
|
|
186
|
+
understanding of your current status in the "Work made for hire"
|
|
187
|
+
or other employer IP clauses in your jurisdiction and contracts
|
|
188
|
+
before applying.
|
|
189
|
+
|
|
190
|
+
Copyright 2025 Chris Tate
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,121 @@
|
|
|
1
1
|
# @emulators/adapter-nuxt
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Nuxt server route integration for emulate. Embed emulators directly into your Nuxt app so they run on the same origin, which keeps OAuth callbacks stable for preview deployments.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @emulators/adapter-nuxt
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Only install the emulators you need alongside the adapter:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @emulators/adapter-nuxt @emulators/github @emulators/google
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Server Route
|
|
18
|
+
|
|
19
|
+
Create a named catch-all route that serves emulator traffic:
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
// server/routes/emulate/[...path].ts
|
|
23
|
+
import { createEmulateHandler } from '@emulators/adapter-nuxt'
|
|
24
|
+
import * as github from '@emulators/github'
|
|
25
|
+
import * as google from '@emulators/google'
|
|
26
|
+
|
|
27
|
+
export default defineEventHandler(createEmulateHandler({
|
|
28
|
+
services: {
|
|
29
|
+
github: {
|
|
30
|
+
emulator: github,
|
|
31
|
+
seed: {
|
|
32
|
+
users: [{ login: 'octocat', name: 'The Octocat' }],
|
|
33
|
+
repos: [{ owner: 'octocat', name: 'hello-world', auto_init: true }],
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
google: {
|
|
37
|
+
emulator: google,
|
|
38
|
+
seed: {
|
|
39
|
+
users: [{ email: 'test@example.com', name: 'Test User' }],
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
}))
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
This creates these routes:
|
|
47
|
+
|
|
48
|
+
- `/emulate/github/**` serves the GitHub emulator
|
|
49
|
+
- `/emulate/google/**` serves the Google emulator
|
|
50
|
+
|
|
51
|
+
## Nuxt Config
|
|
52
|
+
|
|
53
|
+
Emulator UI pages use bundled fonts. Wrap your Nuxt config so Nitro traces the core package assets into production builds:
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
// nuxt.config.ts
|
|
57
|
+
import { withEmulate } from '@emulators/adapter-nuxt'
|
|
58
|
+
|
|
59
|
+
export default defineNuxtConfig(withEmulate({
|
|
60
|
+
// your normal Nuxt config
|
|
61
|
+
}))
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## OAuth Configuration
|
|
65
|
+
|
|
66
|
+
Point your OAuth provider at the emulator paths on the same origin:
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
const baseUrl = process.env.NUXT_PUBLIC_SITE_URL ?? 'http://localhost:3000'
|
|
70
|
+
|
|
71
|
+
export const githubOAuth = {
|
|
72
|
+
clientId: 'any-value',
|
|
73
|
+
clientSecret: 'any-value',
|
|
74
|
+
authorizationUrl: `${baseUrl}/emulate/github/login/oauth/authorize`,
|
|
75
|
+
tokenUrl: `${baseUrl}/emulate/github/login/oauth/access_token`,
|
|
76
|
+
userInfoUrl: `${baseUrl}/emulate/github/user`,
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
No `oauth_apps` need to be seeded. When none are configured, the emulator skips `client_id`, `client_secret`, and `redirect_uri` validation.
|
|
81
|
+
|
|
82
|
+
## Persistence
|
|
83
|
+
|
|
84
|
+
By default, emulator state is in-memory and resets on every cold start. To persist state across restarts, pass a `persistence` adapter.
|
|
85
|
+
|
|
86
|
+
```typescript
|
|
87
|
+
import { createEmulateHandler } from '@emulators/adapter-nuxt'
|
|
88
|
+
import * as github from '@emulators/github'
|
|
89
|
+
|
|
90
|
+
const storageAdapter = {
|
|
91
|
+
async load() { return await useStorage('emulate').getItem<string>('state') },
|
|
92
|
+
async save(data: string) { await useStorage('emulate').setItem('state', data) },
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export default defineEventHandler(createEmulateHandler({
|
|
96
|
+
services: { github: { emulator: github } },
|
|
97
|
+
persistence: storageAdapter,
|
|
98
|
+
}))
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
For local development, `@emulators/core` ships a file-based adapter:
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
import { filePersistence } from '@emulators/core'
|
|
105
|
+
|
|
106
|
+
persistence: filePersistence('.emulate/state.json'),
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Custom Route Param
|
|
110
|
+
|
|
111
|
+
The adapter reads the `path` param from `server/routes/emulate/[...path].ts`. If you use a different catch-all name, pass it as the second argument:
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
export default defineEventHandler(createEmulateHandler(config, { param: 'slug' }))
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
If the mount path cannot be detected from the URL, pass `routePrefix`:
|
|
118
|
+
|
|
119
|
+
```typescript
|
|
120
|
+
export default defineEventHandler(createEmulateHandler(config, { routePrefix: '/api/emulate' }))
|
|
121
|
+
```
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ServicePlugin, Store, WebhookDispatcher, AppKeyResolver, PersistenceAdapter } from '@emulators/core';
|
|
2
|
+
export { PersistenceAdapter } from '@emulators/core';
|
|
3
|
+
|
|
4
|
+
interface EmulatorModule {
|
|
5
|
+
plugin?: ServicePlugin;
|
|
6
|
+
default?: ServicePlugin;
|
|
7
|
+
seedFromConfig?(store: Store, baseUrl: string, config: unknown, webhooks?: WebhookDispatcher): void;
|
|
8
|
+
createAppKeyResolver?(store: Store): AppKeyResolver;
|
|
9
|
+
}
|
|
10
|
+
interface EmulatorEntry {
|
|
11
|
+
emulator: EmulatorModule;
|
|
12
|
+
seed?: Record<string, unknown>;
|
|
13
|
+
}
|
|
14
|
+
interface EmulateHandlerConfig {
|
|
15
|
+
services: Record<string, EmulatorEntry>;
|
|
16
|
+
persistence?: PersistenceAdapter;
|
|
17
|
+
}
|
|
18
|
+
interface NuxtAdapterOptions {
|
|
19
|
+
/**
|
|
20
|
+
* Named catch-all route param from `server/routes/emulate/[...path].ts`.
|
|
21
|
+
*/
|
|
22
|
+
param?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Explicit mount path. Usually detected from the request URL.
|
|
25
|
+
*/
|
|
26
|
+
routePrefix?: string;
|
|
27
|
+
}
|
|
28
|
+
type HeaderValue = string | string[] | number | undefined;
|
|
29
|
+
interface NodeRequestLike {
|
|
30
|
+
method?: string;
|
|
31
|
+
url?: string;
|
|
32
|
+
headers?: Record<string, HeaderValue>;
|
|
33
|
+
}
|
|
34
|
+
interface NuxtEventLike {
|
|
35
|
+
req?: Request;
|
|
36
|
+
node?: {
|
|
37
|
+
req?: NodeRequestLike;
|
|
38
|
+
};
|
|
39
|
+
context?: {
|
|
40
|
+
params?: Record<string, unknown>;
|
|
41
|
+
path?: string;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
declare function createEmulateHandler(config: EmulateHandlerConfig, options?: NuxtAdapterOptions): (event: NuxtEventLike) => Promise<Response>;
|
|
45
|
+
declare function withEmulate<T>(nuxtConfig: T): T;
|
|
46
|
+
|
|
47
|
+
export { type EmulateHandlerConfig, type EmulatorModule, type NuxtAdapterOptions, type NuxtEventLike, createEmulateHandler, withEmulate };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import { createRequire } from "module";
|
|
3
|
+
import { cpSync } from "fs";
|
|
4
|
+
import { dirname, join } from "path";
|
|
5
|
+
import {
|
|
6
|
+
createServer,
|
|
7
|
+
debug,
|
|
8
|
+
serializeTokenMap,
|
|
9
|
+
restoreTokenMap
|
|
10
|
+
} from "@emulators/core";
|
|
11
|
+
var MUTATING_METHODS = /* @__PURE__ */ new Set(["POST", "PUT", "PATCH", "DELETE"]);
|
|
12
|
+
function resolvePlugin(mod) {
|
|
13
|
+
const plugin = mod.plugin ?? mod.default;
|
|
14
|
+
if (!plugin) {
|
|
15
|
+
throw new Error("Emulator module must export `plugin` or a default export implementing ServicePlugin");
|
|
16
|
+
}
|
|
17
|
+
return plugin;
|
|
18
|
+
}
|
|
19
|
+
function takeSnapshot(apps) {
|
|
20
|
+
const mergedStore = { collections: {}, data: {} };
|
|
21
|
+
const tokens = {};
|
|
22
|
+
for (const [name, sa] of apps) {
|
|
23
|
+
const snap = sa.store.snapshot();
|
|
24
|
+
for (const [colName, colSnap] of Object.entries(snap.collections)) {
|
|
25
|
+
mergedStore.collections[`${name}:${colName}`] = colSnap;
|
|
26
|
+
}
|
|
27
|
+
for (const [key, val] of Object.entries(snap.data)) {
|
|
28
|
+
mergedStore.data[`${name}:${key}`] = val;
|
|
29
|
+
}
|
|
30
|
+
tokens[name] = serializeTokenMap(sa.tokenMap);
|
|
31
|
+
}
|
|
32
|
+
return { store: mergedStore, tokens };
|
|
33
|
+
}
|
|
34
|
+
function restoreFromSnapshot(apps, snapshot) {
|
|
35
|
+
const storesByName = /* @__PURE__ */ new Map();
|
|
36
|
+
for (const [qualifiedName, colSnap] of Object.entries(snapshot.store.collections)) {
|
|
37
|
+
const sepIdx = qualifiedName.indexOf(":");
|
|
38
|
+
const name = qualifiedName.slice(0, sepIdx);
|
|
39
|
+
const colName = qualifiedName.slice(sepIdx + 1);
|
|
40
|
+
if (!storesByName.has(name)) {
|
|
41
|
+
storesByName.set(name, { collections: {}, data: {} });
|
|
42
|
+
}
|
|
43
|
+
storesByName.get(name).collections[colName] = colSnap;
|
|
44
|
+
}
|
|
45
|
+
for (const [qualifiedKey, val] of Object.entries(snapshot.store.data)) {
|
|
46
|
+
const sepIdx = qualifiedKey.indexOf(":");
|
|
47
|
+
const name = qualifiedKey.slice(0, sepIdx);
|
|
48
|
+
const dataKey = qualifiedKey.slice(sepIdx + 1);
|
|
49
|
+
if (!storesByName.has(name)) {
|
|
50
|
+
storesByName.set(name, { collections: {}, data: {} });
|
|
51
|
+
}
|
|
52
|
+
storesByName.get(name).data[dataKey] = val;
|
|
53
|
+
}
|
|
54
|
+
for (const [name, sa] of apps) {
|
|
55
|
+
const snap = storesByName.get(name);
|
|
56
|
+
if (snap) {
|
|
57
|
+
sa.store.restore(snap);
|
|
58
|
+
}
|
|
59
|
+
restoreTokenMap(sa.tokenMap, snapshot.tokens[name] ?? []);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function normalizeRoutePrefix(prefix) {
|
|
63
|
+
const withLeadingSlash = prefix.startsWith("/") ? prefix : `/${prefix}`;
|
|
64
|
+
return withLeadingSlash.replace(/\/+$/, "") || "/";
|
|
65
|
+
}
|
|
66
|
+
function joinPath(base, segment) {
|
|
67
|
+
return base === "/" ? `/${segment}` : `${base}/${segment}`;
|
|
68
|
+
}
|
|
69
|
+
function detectPrefix(url, pathSegments) {
|
|
70
|
+
const parsed = new URL(url);
|
|
71
|
+
const fullPath = parsed.pathname;
|
|
72
|
+
const restPath = "/" + pathSegments.join("/");
|
|
73
|
+
const idx = fullPath.lastIndexOf(restPath);
|
|
74
|
+
if (idx >= 0) {
|
|
75
|
+
return fullPath.slice(0, idx) || "/";
|
|
76
|
+
}
|
|
77
|
+
throw new Error(`Could not detect mount path from URL: ${url}`);
|
|
78
|
+
}
|
|
79
|
+
function splitPath(path) {
|
|
80
|
+
return path.split("/").filter(Boolean);
|
|
81
|
+
}
|
|
82
|
+
function getPathSegments(event, paramName, routePrefix) {
|
|
83
|
+
const params = event.context?.params ?? {};
|
|
84
|
+
const value = params[paramName] ?? params._ ?? params.path;
|
|
85
|
+
if (Array.isArray(value)) {
|
|
86
|
+
return value.flatMap((part) => splitPath(String(part)));
|
|
87
|
+
}
|
|
88
|
+
if (typeof value === "string" && value.length > 0) {
|
|
89
|
+
return splitPath(value);
|
|
90
|
+
}
|
|
91
|
+
if (routePrefix && event.context?.path) {
|
|
92
|
+
const prefix = normalizeRoutePrefix(routePrefix);
|
|
93
|
+
const path = event.context.path.startsWith(prefix) ? event.context.path.slice(prefix.length) : event.context.path;
|
|
94
|
+
return splitPath(path);
|
|
95
|
+
}
|
|
96
|
+
return [];
|
|
97
|
+
}
|
|
98
|
+
function firstHeader(value) {
|
|
99
|
+
const raw = Array.isArray(value) ? value[0] : value;
|
|
100
|
+
if (raw === void 0) return void 0;
|
|
101
|
+
return String(raw).split(",")[0]?.trim();
|
|
102
|
+
}
|
|
103
|
+
function headersFromNode(headers) {
|
|
104
|
+
const result = new Headers();
|
|
105
|
+
for (const [key, value] of Object.entries(headers ?? {})) {
|
|
106
|
+
if (value === void 0) continue;
|
|
107
|
+
if (Array.isArray(value)) {
|
|
108
|
+
for (const item of value) {
|
|
109
|
+
result.append(key, item);
|
|
110
|
+
}
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
result.set(key, String(value));
|
|
114
|
+
}
|
|
115
|
+
return result;
|
|
116
|
+
}
|
|
117
|
+
function isWebRequest(value) {
|
|
118
|
+
if (typeof value !== "object" || value === null) return false;
|
|
119
|
+
const candidate = value;
|
|
120
|
+
return typeof candidate.url === "string" && typeof candidate.method === "string" && typeof candidate.headers?.get === "function";
|
|
121
|
+
}
|
|
122
|
+
function requestFromEvent(event) {
|
|
123
|
+
if (isWebRequest(event.req)) {
|
|
124
|
+
return event.req;
|
|
125
|
+
}
|
|
126
|
+
const nodeReq = event.node?.req;
|
|
127
|
+
if (!nodeReq) {
|
|
128
|
+
throw new Error("Nuxt event must provide `req` or `node.req`");
|
|
129
|
+
}
|
|
130
|
+
const headers = nodeReq.headers ?? {};
|
|
131
|
+
const proto = firstHeader(headers["x-forwarded-proto"]) ?? "http";
|
|
132
|
+
const host = firstHeader(headers["x-forwarded-host"]) ?? firstHeader(headers.host) ?? "localhost";
|
|
133
|
+
const url = new URL(nodeReq.url ?? "/", `${proto}://${host}`);
|
|
134
|
+
const method = nodeReq.method ?? "GET";
|
|
135
|
+
const init = {
|
|
136
|
+
method,
|
|
137
|
+
headers: headersFromNode(headers)
|
|
138
|
+
};
|
|
139
|
+
if (method !== "GET" && method !== "HEAD") {
|
|
140
|
+
init.body = nodeReq;
|
|
141
|
+
init.duplex = "half";
|
|
142
|
+
}
|
|
143
|
+
return new Request(url, init);
|
|
144
|
+
}
|
|
145
|
+
async function rewriteResponse(response, servicePrefix) {
|
|
146
|
+
const contentType = response.headers.get("Content-Type") ?? "";
|
|
147
|
+
const location = response.headers.get("Location");
|
|
148
|
+
const isHtml = contentType.includes("text/html");
|
|
149
|
+
const locationChanged = location != null && location.startsWith("/");
|
|
150
|
+
if (!isHtml) {
|
|
151
|
+
if (!locationChanged) return response;
|
|
152
|
+
const headers2 = new Headers(response.headers);
|
|
153
|
+
headers2.set("Location", servicePrefix + location);
|
|
154
|
+
return new Response(response.body, {
|
|
155
|
+
status: response.status,
|
|
156
|
+
statusText: response.statusText,
|
|
157
|
+
headers: headers2
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
let html = await response.text();
|
|
161
|
+
html = html.replace(/(action|href)="(\/[^"]*?)"/g, (_match, attr, path) => {
|
|
162
|
+
if (path.startsWith(servicePrefix)) return `${attr}="${path}"`;
|
|
163
|
+
return `${attr}="${servicePrefix}${path}"`;
|
|
164
|
+
});
|
|
165
|
+
html = html.replace(/url\('(\/[^']*?)'\)/g, (_match, path) => {
|
|
166
|
+
if (path.startsWith(servicePrefix)) return `url('${path}')`;
|
|
167
|
+
return `url('${servicePrefix}${path}')`;
|
|
168
|
+
});
|
|
169
|
+
const headers = new Headers(response.headers);
|
|
170
|
+
if (locationChanged) {
|
|
171
|
+
headers.set("Location", servicePrefix + location);
|
|
172
|
+
}
|
|
173
|
+
headers.delete("Content-Length");
|
|
174
|
+
return new Response(html, {
|
|
175
|
+
status: response.status,
|
|
176
|
+
statusText: response.statusText,
|
|
177
|
+
headers
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
function createEmulateHandler(config, options = {}) {
|
|
181
|
+
const { services: serviceEntries, persistence } = config;
|
|
182
|
+
const paramName = options.param ?? "path";
|
|
183
|
+
const configuredMountPath = options.routePrefix ? normalizeRoutePrefix(options.routePrefix) : null;
|
|
184
|
+
let apps = null;
|
|
185
|
+
let mountPath = configuredMountPath;
|
|
186
|
+
let initPromise = null;
|
|
187
|
+
let pendingSave = Promise.resolve();
|
|
188
|
+
function enqueueSave(targetApps = apps) {
|
|
189
|
+
if (!persistence || !targetApps) return;
|
|
190
|
+
pendingSave = pendingSave.then(async () => {
|
|
191
|
+
const snapshot = takeSnapshot(targetApps);
|
|
192
|
+
const json = JSON.stringify(snapshot);
|
|
193
|
+
try {
|
|
194
|
+
await persistence.save(json);
|
|
195
|
+
} catch (err) {
|
|
196
|
+
debug("persistence", "save failed: %o", err);
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
async function initApps(origin, mountPath2) {
|
|
201
|
+
const serviceApps = /* @__PURE__ */ new Map();
|
|
202
|
+
for (const [name, entry] of Object.entries(serviceEntries)) {
|
|
203
|
+
const plugin = resolvePlugin(entry.emulator);
|
|
204
|
+
const servicePrefix = joinPath(mountPath2, name);
|
|
205
|
+
const baseUrl = `${origin}${servicePrefix}`;
|
|
206
|
+
let appKeyResolver;
|
|
207
|
+
const { app, store, tokenMap, webhooks } = createServer(plugin, {
|
|
208
|
+
baseUrl,
|
|
209
|
+
appKeyResolver: entry.emulator.createAppKeyResolver ? (appId) => appKeyResolver(appId) : void 0
|
|
210
|
+
});
|
|
211
|
+
if (entry.emulator.createAppKeyResolver) {
|
|
212
|
+
appKeyResolver = entry.emulator.createAppKeyResolver(store);
|
|
213
|
+
}
|
|
214
|
+
serviceApps.set(name, { app, store, tokenMap, plugin, webhooks });
|
|
215
|
+
}
|
|
216
|
+
let restored = false;
|
|
217
|
+
if (persistence) {
|
|
218
|
+
const raw = await persistence.load();
|
|
219
|
+
if (raw) {
|
|
220
|
+
try {
|
|
221
|
+
const snapshot = JSON.parse(raw);
|
|
222
|
+
restoreFromSnapshot(serviceApps, snapshot);
|
|
223
|
+
restored = true;
|
|
224
|
+
} catch {
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
if (!restored) {
|
|
229
|
+
for (const [name, entry] of Object.entries(serviceEntries)) {
|
|
230
|
+
const sa = serviceApps.get(name);
|
|
231
|
+
const servicePrefix = joinPath(mountPath2, name);
|
|
232
|
+
const baseUrl = `${origin}${servicePrefix}`;
|
|
233
|
+
sa.plugin.seed?.(sa.store, baseUrl);
|
|
234
|
+
if (entry.seed && entry.emulator.seedFromConfig) {
|
|
235
|
+
entry.emulator.seedFromConfig(sa.store, baseUrl, entry.seed, sa.webhooks);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
if (persistence) {
|
|
239
|
+
enqueueSave(serviceApps);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
return serviceApps;
|
|
243
|
+
}
|
|
244
|
+
async function ensureInit(req, pathSegments) {
|
|
245
|
+
if (apps) return apps;
|
|
246
|
+
if (!initPromise) {
|
|
247
|
+
const url = new URL(req.url);
|
|
248
|
+
const origin = url.origin;
|
|
249
|
+
mountPath = configuredMountPath ?? detectPrefix(req.url, pathSegments);
|
|
250
|
+
initPromise = initApps(origin, mountPath).then((result) => {
|
|
251
|
+
apps = result;
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
await initPromise;
|
|
255
|
+
return apps;
|
|
256
|
+
}
|
|
257
|
+
return async function emulateNuxtHandler(event) {
|
|
258
|
+
const req = requestFromEvent(event);
|
|
259
|
+
const pathSegments = getPathSegments(event, paramName, configuredMountPath ?? void 0);
|
|
260
|
+
if (pathSegments.length === 0) {
|
|
261
|
+
return new Response("Not found", { status: 404 });
|
|
262
|
+
}
|
|
263
|
+
const serviceApps = await ensureInit(req, pathSegments);
|
|
264
|
+
const serviceName = pathSegments[0];
|
|
265
|
+
const sa = serviceApps.get(serviceName);
|
|
266
|
+
if (!sa) {
|
|
267
|
+
return new Response(`Unknown service: ${serviceName}`, { status: 404 });
|
|
268
|
+
}
|
|
269
|
+
const restPath = "/" + pathSegments.slice(1).join("/");
|
|
270
|
+
const url = new URL(req.url);
|
|
271
|
+
const strippedUrl = new URL(restPath + url.search, url.origin);
|
|
272
|
+
const strippedReq = new Request(strippedUrl.toString(), {
|
|
273
|
+
method: req.method,
|
|
274
|
+
headers: req.headers,
|
|
275
|
+
body: req.body,
|
|
276
|
+
duplex: "half"
|
|
277
|
+
});
|
|
278
|
+
let response = await sa.app.fetch(strippedReq);
|
|
279
|
+
const servicePrefix = joinPath(mountPath, serviceName);
|
|
280
|
+
response = await rewriteResponse(response, servicePrefix);
|
|
281
|
+
if (persistence && MUTATING_METHODS.has(req.method)) {
|
|
282
|
+
enqueueSave();
|
|
283
|
+
}
|
|
284
|
+
return response;
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
function copyCoreFonts(nitro) {
|
|
288
|
+
const serverDir = nitro.options?.output?.serverDir;
|
|
289
|
+
if (!serverDir) return;
|
|
290
|
+
try {
|
|
291
|
+
const require2 = createRequire(import.meta.url);
|
|
292
|
+
const corePkg = require2.resolve("@emulators/core/package.json");
|
|
293
|
+
const fontsDir = join(dirname(corePkg), "dist", "fonts");
|
|
294
|
+
cpSync(fontsDir, join(serverDir, "fonts"), { recursive: true });
|
|
295
|
+
} catch (err) {
|
|
296
|
+
debug("nuxt", "font copy failed: %o", err);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
function withEmulate(nuxtConfig) {
|
|
300
|
+
const config = nuxtConfig;
|
|
301
|
+
const nitro = { ...config.nitro ?? {} };
|
|
302
|
+
const existingHooks = nitro.hooks ?? {};
|
|
303
|
+
const prevCompiled = existingHooks.compiled;
|
|
304
|
+
const compiled = async (nitroInstance) => {
|
|
305
|
+
if (prevCompiled) await prevCompiled(nitroInstance);
|
|
306
|
+
copyCoreFonts(nitroInstance);
|
|
307
|
+
};
|
|
308
|
+
return {
|
|
309
|
+
...config,
|
|
310
|
+
nitro: {
|
|
311
|
+
...nitro,
|
|
312
|
+
hooks: { ...existingHooks, compiled }
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
export {
|
|
317
|
+
createEmulateHandler,
|
|
318
|
+
withEmulate
|
|
319
|
+
};
|
|
320
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\nimport { cpSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport {\n createServer,\n debug,\n serializeTokenMap,\n restoreTokenMap,\n type ServicePlugin,\n type Store,\n type TokenMap,\n type TokenEntry,\n type StoreSnapshot,\n type PersistenceAdapter,\n type AppKeyResolver,\n type WebhookDispatcher,\n} from \"@emulators/core\";\n\nexport type { PersistenceAdapter } from \"@emulators/core\";\n\nexport interface EmulatorModule {\n plugin?: ServicePlugin;\n default?: ServicePlugin;\n seedFromConfig?(store: Store, baseUrl: string, config: unknown, webhooks?: WebhookDispatcher): void;\n createAppKeyResolver?(store: Store): AppKeyResolver;\n}\n\ninterface EmulatorEntry {\n emulator: EmulatorModule;\n seed?: Record<string, unknown>;\n}\n\nexport interface EmulateHandlerConfig {\n services: Record<string, EmulatorEntry>;\n persistence?: PersistenceAdapter;\n}\n\nexport interface NuxtAdapterOptions {\n /**\n * Named catch-all route param from `server/routes/emulate/[...path].ts`.\n */\n param?: string;\n /**\n * Explicit mount path. Usually detected from the request URL.\n */\n routePrefix?: string;\n}\n\ntype HeaderValue = string | string[] | number | undefined;\n\ninterface NodeRequestLike {\n method?: string;\n url?: string;\n headers?: Record<string, HeaderValue>;\n}\n\nexport interface NuxtEventLike {\n req?: Request;\n node?: {\n req?: NodeRequestLike;\n };\n context?: {\n params?: Record<string, unknown>;\n path?: string;\n };\n}\n\ninterface Fetchable {\n fetch(request: Request, ...rest: unknown[]): Response | Promise<Response>;\n}\n\ninterface ServiceApp {\n app: Fetchable;\n store: Store;\n tokenMap: TokenMap;\n plugin: ServicePlugin;\n webhooks: WebhookDispatcher;\n}\n\ninterface FullSnapshot {\n store: StoreSnapshot;\n tokens: Record<string, TokenEntry[]>;\n}\n\nconst MUTATING_METHODS = new Set([\"POST\", \"PUT\", \"PATCH\", \"DELETE\"]);\n\nfunction resolvePlugin(mod: EmulatorModule): ServicePlugin {\n const plugin = mod.plugin ?? mod.default;\n if (!plugin) {\n throw new Error(\"Emulator module must export `plugin` or a default export implementing ServicePlugin\");\n }\n return plugin;\n}\n\nfunction takeSnapshot(apps: Map<string, ServiceApp>): FullSnapshot {\n const mergedStore: StoreSnapshot = { collections: {}, data: {} };\n const tokens: Record<string, TokenEntry[]> = {};\n\n for (const [name, sa] of apps) {\n const snap = sa.store.snapshot();\n for (const [colName, colSnap] of Object.entries(snap.collections)) {\n mergedStore.collections[`${name}:${colName}`] = colSnap;\n }\n for (const [key, val] of Object.entries(snap.data)) {\n mergedStore.data[`${name}:${key}`] = val;\n }\n tokens[name] = serializeTokenMap(sa.tokenMap);\n }\n\n return { store: mergedStore, tokens };\n}\n\nfunction restoreFromSnapshot(apps: Map<string, ServiceApp>, snapshot: FullSnapshot): void {\n const storesByName = new Map<string, StoreSnapshot>();\n for (const [qualifiedName, colSnap] of Object.entries(snapshot.store.collections)) {\n const sepIdx = qualifiedName.indexOf(\":\");\n const name = qualifiedName.slice(0, sepIdx);\n const colName = qualifiedName.slice(sepIdx + 1);\n if (!storesByName.has(name)) {\n storesByName.set(name, { collections: {}, data: {} });\n }\n storesByName.get(name)!.collections[colName] = colSnap;\n }\n for (const [qualifiedKey, val] of Object.entries(snapshot.store.data)) {\n const sepIdx = qualifiedKey.indexOf(\":\");\n const name = qualifiedKey.slice(0, sepIdx);\n const dataKey = qualifiedKey.slice(sepIdx + 1);\n if (!storesByName.has(name)) {\n storesByName.set(name, { collections: {}, data: {} });\n }\n storesByName.get(name)!.data[dataKey] = val;\n }\n\n for (const [name, sa] of apps) {\n const snap = storesByName.get(name);\n if (snap) {\n sa.store.restore(snap);\n }\n restoreTokenMap(sa.tokenMap, snapshot.tokens[name] ?? []);\n }\n}\n\nfunction normalizeRoutePrefix(prefix: string): string {\n const withLeadingSlash = prefix.startsWith(\"/\") ? prefix : `/${prefix}`;\n return withLeadingSlash.replace(/\\/+$/, \"\") || \"/\";\n}\n\nfunction joinPath(base: string, segment: string): string {\n return base === \"/\" ? `/${segment}` : `${base}/${segment}`;\n}\n\nfunction detectPrefix(url: string, pathSegments: string[]): string {\n const parsed = new URL(url);\n const fullPath = parsed.pathname;\n const restPath = \"/\" + pathSegments.join(\"/\");\n const idx = fullPath.lastIndexOf(restPath);\n if (idx >= 0) {\n return fullPath.slice(0, idx) || \"/\";\n }\n throw new Error(`Could not detect mount path from URL: ${url}`);\n}\n\nfunction splitPath(path: string): string[] {\n return path.split(\"/\").filter(Boolean);\n}\n\nfunction getPathSegments(event: NuxtEventLike, paramName: string, routePrefix?: string): string[] {\n const params = event.context?.params ?? {};\n const value = params[paramName] ?? params._ ?? params.path;\n\n if (Array.isArray(value)) {\n return value.flatMap((part) => splitPath(String(part)));\n }\n if (typeof value === \"string\" && value.length > 0) {\n return splitPath(value);\n }\n\n if (routePrefix && event.context?.path) {\n const prefix = normalizeRoutePrefix(routePrefix);\n const path = event.context.path.startsWith(prefix) ? event.context.path.slice(prefix.length) : event.context.path;\n return splitPath(path);\n }\n\n return [];\n}\n\nfunction firstHeader(value: HeaderValue): string | undefined {\n const raw = Array.isArray(value) ? value[0] : value;\n if (raw === undefined) return undefined;\n return String(raw).split(\",\")[0]?.trim();\n}\n\nfunction headersFromNode(headers: Record<string, HeaderValue> | undefined): Headers {\n const result = new Headers();\n for (const [key, value] of Object.entries(headers ?? {})) {\n if (value === undefined) continue;\n if (Array.isArray(value)) {\n for (const item of value) {\n result.append(key, item);\n }\n continue;\n }\n result.set(key, String(value));\n }\n return result;\n}\n\nfunction isWebRequest(value: unknown): value is Request {\n if (typeof value !== \"object\" || value === null) return false;\n const candidate = value as Request;\n return (\n typeof candidate.url === \"string\" &&\n typeof candidate.method === \"string\" &&\n typeof candidate.headers?.get === \"function\"\n );\n}\n\nfunction requestFromEvent(event: NuxtEventLike): Request {\n if (isWebRequest(event.req)) {\n return event.req;\n }\n\n const nodeReq = event.node?.req;\n if (!nodeReq) {\n throw new Error(\"Nuxt event must provide `req` or `node.req`\");\n }\n\n const headers = nodeReq.headers ?? {};\n const proto = firstHeader(headers[\"x-forwarded-proto\"]) ?? \"http\";\n const host = firstHeader(headers[\"x-forwarded-host\"]) ?? firstHeader(headers.host) ?? \"localhost\";\n const url = new URL(nodeReq.url ?? \"/\", `${proto}://${host}`);\n const method = nodeReq.method ?? \"GET\";\n const init: RequestInit & { duplex?: string } = {\n method,\n headers: headersFromNode(headers),\n };\n\n if (method !== \"GET\" && method !== \"HEAD\") {\n init.body = nodeReq as unknown as RequestInit[\"body\"];\n init.duplex = \"half\";\n }\n\n return new Request(url, init);\n}\n\nasync function rewriteResponse(response: Response, servicePrefix: string): Promise<Response> {\n const contentType = response.headers.get(\"Content-Type\") ?? \"\";\n const location = response.headers.get(\"Location\");\n const isHtml = contentType.includes(\"text/html\");\n const locationChanged = location != null && location.startsWith(\"/\");\n\n if (!isHtml) {\n if (!locationChanged) return response;\n const headers = new Headers(response.headers);\n headers.set(\"Location\", servicePrefix + location);\n return new Response(response.body, {\n status: response.status,\n statusText: response.statusText,\n headers,\n });\n }\n\n let html = await response.text();\n\n html = html.replace(/(action|href)=\"(\\/[^\"]*?)\"/g, (_match, attr, path) => {\n if (path.startsWith(servicePrefix)) return `${attr}=\"${path}\"`;\n return `${attr}=\"${servicePrefix}${path}\"`;\n });\n\n html = html.replace(/url\\('(\\/[^']*?)'\\)/g, (_match, path) => {\n if (path.startsWith(servicePrefix)) return `url('${path}')`;\n return `url('${servicePrefix}${path}')`;\n });\n\n const headers = new Headers(response.headers);\n if (locationChanged) {\n headers.set(\"Location\", servicePrefix + location);\n }\n headers.delete(\"Content-Length\");\n\n return new Response(html, {\n status: response.status,\n statusText: response.statusText,\n headers,\n });\n}\n\nexport function createEmulateHandler(config: EmulateHandlerConfig, options: NuxtAdapterOptions = {}) {\n const { services: serviceEntries, persistence } = config;\n const paramName = options.param ?? \"path\";\n const configuredMountPath = options.routePrefix ? normalizeRoutePrefix(options.routePrefix) : null;\n\n let apps: Map<string, ServiceApp> | null = null;\n let mountPath: string | null = configuredMountPath;\n let initPromise: Promise<void> | null = null;\n let pendingSave: Promise<void> = Promise.resolve();\n\n function enqueueSave(targetApps: Map<string, ServiceApp> | null = apps): void {\n if (!persistence || !targetApps) return;\n pendingSave = pendingSave.then(async () => {\n const snapshot = takeSnapshot(targetApps);\n const json = JSON.stringify(snapshot);\n try {\n await persistence.save(json);\n } catch (err) {\n debug(\"persistence\", \"save failed: %o\", err);\n }\n });\n }\n\n async function initApps(origin: string, mountPath: string): Promise<Map<string, ServiceApp>> {\n const serviceApps = new Map<string, ServiceApp>();\n\n for (const [name, entry] of Object.entries(serviceEntries)) {\n const plugin = resolvePlugin(entry.emulator);\n const servicePrefix = joinPath(mountPath, name);\n const baseUrl = `${origin}${servicePrefix}`;\n\n let appKeyResolver: AppKeyResolver | undefined;\n const { app, store, tokenMap, webhooks } = createServer(plugin, {\n baseUrl,\n appKeyResolver: entry.emulator.createAppKeyResolver ? (appId) => appKeyResolver!(appId) : undefined,\n });\n\n if (entry.emulator.createAppKeyResolver) {\n appKeyResolver = entry.emulator.createAppKeyResolver(store);\n }\n\n serviceApps.set(name, { app, store, tokenMap, plugin, webhooks });\n }\n\n let restored = false;\n if (persistence) {\n const raw = await persistence.load();\n if (raw) {\n try {\n const snapshot = JSON.parse(raw) as FullSnapshot;\n restoreFromSnapshot(serviceApps, snapshot);\n restored = true;\n } catch {\n // Corrupted data, fall through to seeding.\n }\n }\n }\n\n if (!restored) {\n for (const [name, entry] of Object.entries(serviceEntries)) {\n const sa = serviceApps.get(name)!;\n const servicePrefix = joinPath(mountPath, name);\n const baseUrl = `${origin}${servicePrefix}`;\n sa.plugin.seed?.(sa.store, baseUrl);\n if (entry.seed && entry.emulator.seedFromConfig) {\n entry.emulator.seedFromConfig(sa.store, baseUrl, entry.seed, sa.webhooks);\n }\n }\n if (persistence) {\n enqueueSave(serviceApps);\n }\n }\n\n return serviceApps;\n }\n\n async function ensureInit(req: Request, pathSegments: string[]): Promise<Map<string, ServiceApp>> {\n if (apps) return apps;\n if (!initPromise) {\n const url = new URL(req.url);\n const origin = url.origin;\n mountPath = configuredMountPath ?? detectPrefix(req.url, pathSegments);\n initPromise = initApps(origin, mountPath).then((result) => {\n apps = result;\n });\n }\n await initPromise;\n return apps!;\n }\n\n return async function emulateNuxtHandler(event: NuxtEventLike): Promise<Response> {\n const req = requestFromEvent(event);\n const pathSegments = getPathSegments(event, paramName, configuredMountPath ?? undefined);\n\n if (pathSegments.length === 0) {\n return new Response(\"Not found\", { status: 404 });\n }\n\n const serviceApps = await ensureInit(req, pathSegments);\n\n const serviceName = pathSegments[0];\n const sa = serviceApps.get(serviceName);\n if (!sa) {\n return new Response(`Unknown service: ${serviceName}`, { status: 404 });\n }\n\n const restPath = \"/\" + pathSegments.slice(1).join(\"/\");\n const url = new URL(req.url);\n const strippedUrl = new URL(restPath + url.search, url.origin);\n\n const strippedReq = new Request(strippedUrl.toString(), {\n method: req.method,\n headers: req.headers,\n body: req.body,\n duplex: \"half\",\n } as RequestInit & { duplex: string });\n\n let response = await sa.app.fetch(strippedReq);\n\n const servicePrefix = joinPath(mountPath!, serviceName);\n response = await rewriteResponse(response, servicePrefix);\n\n if (persistence && MUTATING_METHODS.has(req.method)) {\n enqueueSave();\n }\n\n return response;\n };\n}\n\ninterface NitroInstanceLike {\n options?: { output?: { serverDir?: string } };\n}\n\n/**\n * Copy the `@emulators/core` UI fonts into the built server output.\n *\n * The emulator UI reads its fonts with `readFileSync(join(__dirname, \"fonts\", …))`.\n * In a Nitro build `__dirname` resolves to the server output root, so the font\n * files must exist at `<serverDir>/fonts/`. Nitro's tracing does not place them\n * there, so we copy them explicitly once the build is written.\n */\nfunction copyCoreFonts(nitro: NitroInstanceLike): void {\n const serverDir = nitro.options?.output?.serverDir;\n if (!serverDir) return;\n try {\n const require = createRequire(import.meta.url);\n const corePkg = require.resolve(\"@emulators/core/package.json\");\n const fontsDir = join(dirname(corePkg), \"dist\", \"fonts\");\n cpSync(fontsDir, join(serverDir, \"fonts\"), { recursive: true });\n } catch (err) {\n debug(\"nuxt\", \"font copy failed: %o\", err);\n }\n}\n\nexport function withEmulate<T>(nuxtConfig: T): T {\n const config = nuxtConfig as Record<string, unknown>;\n const nitro = { ...((config.nitro as Record<string, unknown> | undefined) ?? {}) };\n const existingHooks = (nitro.hooks as Record<string, unknown> | undefined) ?? {};\n const prevCompiled = existingHooks.compiled as ((nitro: NitroInstanceLike) => unknown) | undefined;\n\n const compiled = async (nitroInstance: NitroInstanceLike) => {\n if (prevCompiled) await prevCompiled(nitroInstance);\n copyCoreFonts(nitroInstance);\n };\n\n return {\n ...config,\n nitro: {\n ...nitro,\n hooks: { ...existingHooks, compiled },\n },\n } as T;\n}\n"],"mappings":";AAAA,SAAS,qBAAqB;AAC9B,SAAS,cAAc;AACvB,SAAS,SAAS,YAAY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|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"homepage": "https://emulate.dev",
|
|
8
16
|
"repository": {
|
|
9
17
|
"type": "git",
|
|
10
|
-
"url": ""
|
|
18
|
+
"url": "https://github.com/vercel-labs/emulate.git",
|
|
19
|
+
"directory": "packages/@emulators/adapter-nuxt"
|
|
20
|
+
},
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://github.com/vercel-labs/emulate/issues"
|
|
23
|
+
},
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist"
|
|
29
|
+
],
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@emulators/core": "0.9.0"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"tsup": "^8",
|
|
35
|
+
"typescript": "^5.7"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "tsup --clean",
|
|
39
|
+
"dev": "tsup --watch",
|
|
40
|
+
"clean": "rm -rf dist .turbo",
|
|
41
|
+
"type-check": "tsc --noEmit",
|
|
42
|
+
"lint": "eslint src"
|
|
11
43
|
}
|
|
12
44
|
}
|
package/index.js
DELETED