@platformatic/react-router 3.72.0 → 4.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/config.d.ts +764 -830
- package/index.d.ts +8 -1
- package/index.js +9 -9
- package/lib/capability.js +15 -25
- package/lib/factory.js +12 -0
- package/lib/schema.js +8 -3
- package/package.json +17 -11
- package/schema.js +7 -0
- package/schema.json +180 -390
- package/.gitignore +0 -2
- package/.npmignore +0 -1
package/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseCapability, BaseContext, BaseOptions } from '@platformatic/basic'
|
|
1
|
+
import { ApplicationDefinition, BaseCapability, BaseContext, BaseOptions, CapabilityFactoryOptions, ConfigContext, DeferredApplicationDefinition } from '@platformatic/basic'
|
|
2
2
|
import { Configuration, ConfigurationOptions } from '@platformatic/foundation'
|
|
3
3
|
import { JSONSchemaType } from 'ajv'
|
|
4
4
|
import type { PlatformaticReactRouterConfig } from './config.d.ts'
|
|
@@ -42,3 +42,10 @@ export declare const schema: JSONSchemaType<PlatformaticReactRouterConfig>
|
|
|
42
42
|
export declare const schemaComponents: { reactRouter: JSONSchemaType<object> }
|
|
43
43
|
export declare const version: string
|
|
44
44
|
export declare const supportedVersions: string
|
|
45
|
+
|
|
46
|
+
export type ReactRouterConfigOptions = CapabilityFactoryOptions<PlatformaticReactRouterConfig, 'vite' | 'reactRouter', never>
|
|
47
|
+
|
|
48
|
+
export declare function createReactRouterConfig (options?: ReactRouterConfigOptions): ApplicationDefinition
|
|
49
|
+
export declare function createReactRouterConfig (
|
|
50
|
+
callback: (context: ConfigContext) => ReactRouterConfigOptions | Promise<ReactRouterConfigOptions>
|
|
51
|
+
): DeferredApplicationDefinition
|
package/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { transform as basicTransform,
|
|
2
|
-
import { kMetadata
|
|
1
|
+
import { loadCapabilityConfiguration, transform as basicTransform, validationOptions } from '@platformatic/basic'
|
|
2
|
+
import { kMetadata } from '@platformatic/foundation'
|
|
3
3
|
import { ReactRouterCapability } from './lib/capability.js'
|
|
4
4
|
import { schema } from './lib/schema.js'
|
|
5
5
|
|
|
@@ -11,14 +11,12 @@ export async function transform (config, schema, options) {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export async function loadConfiguration (configOrRoot, sourceOrConfig, context) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
return loadCapabilityConfiguration(configOrRoot, sourceOrConfig, context, {
|
|
15
|
+
schema,
|
|
16
|
+
scope: import.meta.filename,
|
|
17
|
+
suffixes: 'application',
|
|
17
18
|
validationOptions,
|
|
18
|
-
transform
|
|
19
|
-
replaceEnv: true,
|
|
20
|
-
root,
|
|
21
|
-
...context
|
|
19
|
+
transform
|
|
22
20
|
})
|
|
23
21
|
}
|
|
24
22
|
|
|
@@ -29,3 +27,5 @@ export async function create (configOrRoot, sourceOrConfig, context) {
|
|
|
29
27
|
|
|
30
28
|
export * from './lib/capability.js'
|
|
31
29
|
export { packageJson, schema, schemaComponents, version } from './lib/schema.js'
|
|
30
|
+
|
|
31
|
+
export * from './lib/factory.js'
|
package/lib/capability.js
CHANGED
|
@@ -55,12 +55,7 @@ export class ReactRouterCapability extends ViteCapability {
|
|
|
55
55
|
this.subprocessTerminationSignal = 'SIGKILL'
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
async
|
|
59
|
-
// Make this idempotent
|
|
60
|
-
if (this.url) {
|
|
61
|
-
return this.url
|
|
62
|
-
}
|
|
63
|
-
|
|
58
|
+
async _start () {
|
|
64
59
|
const config = this.config
|
|
65
60
|
const reactRouterConfig = await this.#getReactRouterConfig()
|
|
66
61
|
|
|
@@ -75,13 +70,11 @@ export class ReactRouterCapability extends ViteCapability {
|
|
|
75
70
|
}
|
|
76
71
|
|
|
77
72
|
if (reactRouterConfig.ssr) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
return this.#startSSRProduction(listen)
|
|
73
|
+
return this.#startSSRProduction()
|
|
81
74
|
}
|
|
82
75
|
}
|
|
83
76
|
|
|
84
|
-
return super.
|
|
77
|
+
return super._start()
|
|
85
78
|
}
|
|
86
79
|
|
|
87
80
|
async build () {
|
|
@@ -122,21 +115,7 @@ export class ReactRouterCapability extends ViteCapability {
|
|
|
122
115
|
return reactRouterConfig ?? {}
|
|
123
116
|
}
|
|
124
117
|
|
|
125
|
-
async #startSSRProduction (
|
|
126
|
-
// Listen if entrypoint
|
|
127
|
-
if (this.#app && listen) {
|
|
128
|
-
const serverOptions = this.serverConfig
|
|
129
|
-
const listenOptions = buildListenOptions(serverOptions)
|
|
130
|
-
|
|
131
|
-
if (typeof serverOptions?.backlog === 'number') {
|
|
132
|
-
createServerListener(false, false, { backlog: serverOptions.backlog })
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
await this.#app.listen(listenOptions)
|
|
136
|
-
this.url = getServerUrl(this.#app.server)
|
|
137
|
-
return this.url
|
|
138
|
-
}
|
|
139
|
-
|
|
118
|
+
async #startSSRProduction () {
|
|
140
119
|
const config = this.config
|
|
141
120
|
|
|
142
121
|
const clientRoot = resolve(this.root, config.reactRouter.outputDirectory, 'client')
|
|
@@ -213,6 +192,17 @@ export class ReactRouterCapability extends ViteCapability {
|
|
|
213
192
|
|
|
214
193
|
await this.#app.ready()
|
|
215
194
|
await this._collectMetrics()
|
|
195
|
+
|
|
196
|
+
if (typeof this.serverConfig?.port === 'undefined') {
|
|
197
|
+
return
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const serverOptions = this.serverConfig
|
|
201
|
+
const listenOptions = buildListenOptions(serverOptions)
|
|
202
|
+
const serverPromise = createServerListener()
|
|
203
|
+
|
|
204
|
+
await Promise.all([this.#app.listen(listenOptions), serverPromise])
|
|
205
|
+
this.url = getServerUrl(this.#app.server)
|
|
216
206
|
}
|
|
217
207
|
|
|
218
208
|
#handleRequest (handle, req) {
|
package/lib/factory.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { defineCapabilityFactory } from '@platformatic/basic'
|
|
2
|
+
import { schema, version } from './schema.js'
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
Vite-derived capabilities flatten the vite block alongside their own; outputDirectory comes
|
|
6
|
+
from the capability's block while application.outputDirectory stays nested, which is why the
|
|
7
|
+
application block is not flattened anywhere.
|
|
8
|
+
*/
|
|
9
|
+
export const createReactRouterConfig = defineCapabilityFactory('@platformatic/react-router', schema, {
|
|
10
|
+
version,
|
|
11
|
+
flatten: ['vite', 'reactRouter']
|
|
12
|
+
})
|
package/lib/schema.js
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
import { schemaComponents as basicSchemaComponents } from '@platformatic/basic'
|
|
2
|
-
import { schemaComponents as utilsSchemaComponents } from '@platformatic/foundation'
|
|
3
|
-
import { schemaComponents as viteSchemaComponents } from '@platformatic/vite'
|
|
1
|
+
import { schemaComponents as basicSchemaComponents } from '@platformatic/basic/schema'
|
|
2
|
+
import { schemaComponents as utilsSchemaComponents } from '@platformatic/foundation/schema'
|
|
3
|
+
import { schemaComponents as viteSchemaComponents } from '@platformatic/vite/schema'
|
|
4
4
|
import { readFileSync } from 'node:fs'
|
|
5
5
|
import { resolve } from 'node:path'
|
|
6
6
|
|
|
7
7
|
export const packageJson = JSON.parse(readFileSync(resolve(import.meta.dirname, '../package.json'), 'utf8'))
|
|
8
8
|
export const version = packageJson.version
|
|
9
9
|
|
|
10
|
+
// Extends ViteCapability and selects its SSR production path at worker startup, so which
|
|
11
|
+
// application it builds is not visible here — but it builds one either way, so that it serves
|
|
12
|
+
// stays decidable even though what it serves is not.
|
|
13
|
+
export const servesWithoutPort = { development: false, production: true }
|
|
14
|
+
|
|
10
15
|
export const reactRouter = {
|
|
11
16
|
type: 'object',
|
|
12
17
|
properties: {
|
package/package.json
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/react-router",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-alpha.1",
|
|
4
4
|
"description": "Platformatic React Router Capability",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./index.js",
|
|
9
|
+
"./schema": "./schema.js",
|
|
10
|
+
"./package.json": "./package.json",
|
|
11
|
+
"./*": "./*"
|
|
12
|
+
},
|
|
7
13
|
"repository": {
|
|
8
14
|
"type": "git",
|
|
9
15
|
"url": "git+https://github.com/platformatic/platformatic.git"
|
|
@@ -16,16 +22,14 @@
|
|
|
16
22
|
"homepage": "https://github.com/platformatic/platformatic#readme",
|
|
17
23
|
"dependencies": {
|
|
18
24
|
"@fastify/static": "^10.0.0",
|
|
19
|
-
"@platformatic/basic": "3.72.0",
|
|
20
|
-
"@platformatic/foundation": "3.72.0",
|
|
21
|
-
"@platformatic/globals": "3.72.0",
|
|
22
|
-
"@platformatic/vite": "3.72.0",
|
|
23
25
|
"fastify": "^5.0.0",
|
|
24
|
-
"semver": "^7.6.3"
|
|
26
|
+
"semver": "^7.6.3",
|
|
27
|
+
"@platformatic/foundation": "4.0.0-alpha.1",
|
|
28
|
+
"@platformatic/globals": "4.0.0-alpha.1",
|
|
29
|
+
"@platformatic/basic": "4.0.0-alpha.1",
|
|
30
|
+
"@platformatic/vite": "4.0.0-alpha.1"
|
|
25
31
|
},
|
|
26
32
|
"devDependencies": {
|
|
27
|
-
"@platformatic/gateway": "3.72.0",
|
|
28
|
-
"@platformatic/service": "3.72.0",
|
|
29
33
|
"@react-router/dev": "^7.10.0",
|
|
30
34
|
"@react-router/node": "^7.10.0",
|
|
31
35
|
"@types/react": "^19.1.11",
|
|
@@ -42,11 +46,13 @@
|
|
|
42
46
|
"react-router": "^7.10.0",
|
|
43
47
|
"react-router-dom": "^7.10.0",
|
|
44
48
|
"typescript": "~6.0.3",
|
|
45
|
-
"vite": "^
|
|
46
|
-
"ws": "^8.18.0"
|
|
49
|
+
"vite": "^7.1.7",
|
|
50
|
+
"ws": "^8.18.0",
|
|
51
|
+
"@platformatic/gateway": "4.0.0-alpha.1",
|
|
52
|
+
"@platformatic/service": "4.0.0-alpha.1"
|
|
47
53
|
},
|
|
48
54
|
"engines": {
|
|
49
|
-
"node": ">=
|
|
55
|
+
"node": ">=24.20.0"
|
|
50
56
|
},
|
|
51
57
|
"scripts": {
|
|
52
58
|
"test": "npm run test:types && node --test --test-reporter=cleaner-spec-reporter --test-concurrency=1 --test-timeout=2000000 test/*.test.js test/**/*.test.js",
|
package/schema.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// The light /schema subpath, part of the capability contract. It carries the schema and the
|
|
2
|
+
// package-level metadata main-side preparation needs, and imports nothing that would pull the
|
|
3
|
+
// capability's implementation in with it — boot resolves this rather than the package entry.
|
|
4
|
+
//
|
|
5
|
+
// Light is a statement about import cost, never about safety: this executes in the main process
|
|
6
|
+
// with full privileges, like any capability code.
|
|
7
|
+
export * from './lib/schema.js'
|