@platformatic/tanstack 3.67.0 → 4.0.0-new-config.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/config.d.ts CHANGED
@@ -66,7 +66,7 @@ export interface PlatformaticTanStackConfig {
66
66
  hostname?: string;
67
67
  port?: number | string;
68
68
  /**
69
- * Configures how entrypoint server worker ports are assigned. When set to shared, all workers listen on the same port. When set to perWorkerIncrement, each worker will use its own port, starting from port (worker 0).
69
+ * Configures how the port is assigned when the application runs multiple workers. When set to shared (the default), all workers listen on the same port (which requires SO_REUSEPORT support). When set to perWorkerIncrement, each worker listens on its own port, starting from port (worker 0) and incrementing by one for each additional worker.
70
70
  */
71
71
  portAssignment?: "shared" | "perWorkerIncrement";
72
72
  /**
@@ -224,46 +224,6 @@ export interface PlatformaticTanStackConfig {
224
224
  };
225
225
  [k: string]: unknown;
226
226
  };
227
- server?: {
228
- hostname?: string;
229
- port?: number | string;
230
- /**
231
- * Configures how entrypoint server worker ports are assigned. When set to shared, all workers listen on the same port. When set to perWorkerIncrement, each worker will use its own port, starting from port (worker 0).
232
- */
233
- portAssignment?: "shared" | "perWorkerIncrement";
234
- /**
235
- * The maximum length of the queue of pending connections
236
- */
237
- backlog?: number;
238
- http2?: boolean;
239
- https?: {
240
- allowHTTP1?: boolean;
241
- key:
242
- | string
243
- | {
244
- path?: string;
245
- }
246
- | (
247
- | string
248
- | {
249
- path?: string;
250
- }
251
- )[];
252
- cert:
253
- | string
254
- | {
255
- path?: string;
256
- }
257
- | (
258
- | string
259
- | {
260
- path?: string;
261
- }
262
- )[];
263
- requestCert?: boolean;
264
- rejectUnauthorized?: boolean;
265
- };
266
- };
267
227
  reuseTcpPorts?: boolean;
268
228
  startTimeout?: number;
269
229
  restartOnError?: boolean | number;
package/index.js CHANGED
@@ -29,3 +29,5 @@ export async function create (configOrRoot, sourceOrConfig, context) {
29
29
 
30
30
  export * from './lib/capability.js'
31
31
  export { packageJson, schema, schemaComponents, version } from './lib/schema.js'
32
+
33
+ export * from './lib/factory.js'
package/lib/capability.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import {
2
- buildAdditionalServerOptions,
3
2
  cleanBasePath,
4
3
  createServerListener,
5
4
  ensureTrailingSlash,
@@ -53,25 +52,23 @@ export class TanstackCapability extends ViteCapability {
53
52
  this.subprocessTerminationSignal = 'SIGKILL'
54
53
  }
55
54
 
56
- async start ({ listen }) {
57
- // Make this idempotent
58
- /* c8 ignore next 3 */
59
- if (this.url) {
60
- return this.url
61
- }
62
-
63
- await super._start({ listen })
64
-
55
+ async _start () {
65
56
  const config = this.config
66
57
  const command = config.application.commands[this.isProduction ? 'production' : 'development']
67
58
 
68
59
  if (command) {
69
60
  return this.startWithCommand(command)
70
- } else if (!this.isProduction) {
71
- return super.start({ listen })
72
61
  }
73
62
 
74
- await this.#startProduction({ listen })
63
+ if (typeof this.serverConfig?.port === 'undefined') {
64
+ return
65
+ }
66
+
67
+ if (!this.isProduction) {
68
+ return super._start()
69
+ }
70
+
71
+ await this.#startProduction()
75
72
  }
76
73
 
77
74
  async #startProduction () {
@@ -81,28 +78,31 @@ export class TanstackCapability extends ViteCapability {
81
78
  this.#basePath = await this._getBasePathFromBuildInfo()
82
79
 
83
80
  const serverOptions = this.serverConfig
84
- const serverPromise = createServerListener(
85
- serverOptions?.port ?? true,
86
- serverOptions?.hostname ?? true,
87
- await buildAdditionalServerOptions(serverOptions)
88
- )
81
+ const serverPromise = createServerListener()
89
82
 
90
83
  const httpsOptions = await sanitizeHTTPSOptions(serverOptions?.https)
84
+ const environment = {
85
+ NITRO_HOST: serverOptions?.hostname ?? '127.0.0.1',
86
+ NITRO_PORT: serverOptions?.port ?? 0,
87
+ NITRO_SSL_CERT: httpsOptions?.cert && this.#serializeCertificateValue(httpsOptions.cert),
88
+ NITRO_SSL_KEY: httpsOptions?.key && this.#serializeCertificateValue(httpsOptions.key)
89
+ }
90
+ const originalEnvironment = new Map()
91
91
 
92
- if (!httpsOptions?.cert && !httpsOptions?.key) {
93
- await this.#importProductionNitro(outputDirectory)
94
- } else {
95
- const originalCert = process.env.NITRO_SSL_CERT
96
- const originalKey = process.env.NITRO_SSL_KEY
92
+ for (const [key, value] of Object.entries(environment)) {
93
+ if (typeof value === 'undefined') {
94
+ continue
95
+ }
97
96
 
98
- process.env.NITRO_SSL_CERT = this.#serializeCertificateValue(httpsOptions.cert)
99
- process.env.NITRO_SSL_KEY = this.#serializeCertificateValue(httpsOptions.key)
97
+ originalEnvironment.set(key, process.env[key])
98
+ process.env[key] = value.toString()
99
+ }
100
100
 
101
- try {
102
- await this.#importProductionNitro(outputDirectory)
103
- } finally {
104
- this.#restoreEnvironmentVariables('NITRO_SSL_CERT', originalCert)
105
- this.#restoreEnvironmentVariables('NITRO_SSL_KEY', originalKey)
101
+ try {
102
+ await this.#importProductionNitro(outputDirectory)
103
+ } finally {
104
+ for (const [key, value] of originalEnvironment) {
105
+ this.#restoreEnvironmentVariables(key, value)
106
106
  }
107
107
  }
108
108
 
@@ -114,9 +114,9 @@ export class TanstackCapability extends ViteCapability {
114
114
  return this.url
115
115
  }
116
116
 
117
- async stop () {
117
+ async _stop () {
118
118
  const hasChildrenManager = !!this.childManager
119
- await super.stop()
119
+ await super._stop()
120
120
 
121
121
  // ViteCapability.stop already stops child processs
122
122
  if (hasChildrenManager || !this.isProduction) {
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 tanstack = defineCapabilityFactory('@platformatic/tanstack', schema, {
10
+ version,
11
+ flatten: ['vite']
12
+ })
package/lib/schema.js CHANGED
@@ -1,12 +1,15 @@
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/lib/schema.js'
2
+ import { schemaComponents as utilsSchemaComponents } from '@platformatic/foundation/lib/schema.js'
3
+ import { schemaComponents as viteSchemaComponents } from '@platformatic/vite/lib/schema.js'
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
+ // The port is checked before any startup path is selected, so no port means no start.
11
+ export const servesWithoutPort = { development: false, production: false }
12
+
10
13
  export const schemaComponents = {}
11
14
 
12
15
  export const schema = {
package/package.json CHANGED
@@ -1,9 +1,15 @@
1
1
  {
2
2
  "name": "@platformatic/tanstack",
3
- "version": "3.67.0",
3
+ "version": "4.0.0-new-config.0",
4
4
  "description": "Platformatic TanStack 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,10 +22,10 @@
16
22
  "homepage": "https://github.com/platformatic/platformatic#readme",
17
23
  "dependencies": {
18
24
  "semver": "^7.6.3",
19
- "@platformatic/basic": "3.67.0",
20
- "@platformatic/globals": "3.67.0",
21
- "@platformatic/vite": "3.67.0",
22
- "@platformatic/foundation": "3.67.0"
25
+ "@platformatic/vite": "4.0.0-new-config.0",
26
+ "@platformatic/foundation": "4.0.0-new-config.0",
27
+ "@platformatic/basic": "4.0.0-new-config.0",
28
+ "@platformatic/globals": "4.0.0-new-config.0"
23
29
  },
24
30
  "devDependencies": {
25
31
  "@tanstack/react-router": "^1.139.7",
@@ -39,8 +45,8 @@
39
45
  "vite-plugin-solid": "^2.11.10",
40
46
  "vite-tsconfig-paths": "^5.1.4",
41
47
  "ws": "^8.18.0",
42
- "@platformatic/service": "3.67.0",
43
- "@platformatic/gateway": "3.67.0"
48
+ "@platformatic/service": "4.0.0-new-config.0",
49
+ "@platformatic/gateway": "4.0.0-new-config.0"
44
50
  },
45
51
  "engines": {
46
52
  "node": ">=22.19.0"
package/schema.js ADDED
@@ -0,0 +1,7 @@
1
+ // The light /schema subpath, part of the v4 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'
package/schema.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://schemas.platformatic.dev/@platformatic/tanstack/3.67.0.json",
2
+ "$id": "https://schemas.platformatic.dev/@platformatic/tanstack/4.0.0-new-config.0.json",
3
3
  "$schema": "http://json-schema.org/draft-07/schema#",
4
4
  "title": "Platformatic TanStack Config",
5
5
  "type": "object",
@@ -202,7 +202,7 @@
202
202
  "shared",
203
203
  "perWorkerIncrement"
204
204
  ],
205
- "description": "Configures how entrypoint server worker ports are assigned. When set to shared, all workers listen on the same port. When set to perWorkerIncrement, each worker will use its own port, starting from port (worker 0)."
205
+ "description": "Configures how the port is assigned when the application runs multiple workers. When set to shared (the default), all workers listen on the same port (which requires SO_REUSEPORT support). When set to perWorkerIncrement, each worker listens on its own port, starting from port (worker 0) and incrementing by one for each additional worker."
206
206
  },
207
207
  "backlog": {
208
208
  "type": "integer",
@@ -536,7 +536,14 @@
536
536
  "resolvePath": true
537
537
  },
538
538
  "config": {
539
- "type": "string"
539
+ "anyOf": [
540
+ {
541
+ "type": "string"
542
+ },
543
+ {
544
+ "type": "object"
545
+ }
546
+ ]
540
547
  },
541
548
  "url": {
542
549
  "type": "string"
@@ -545,9 +552,6 @@
545
552
  "type": "string",
546
553
  "default": "main"
547
554
  },
548
- "useHttp": {
549
- "type": "boolean"
550
- },
551
555
  "reuseTcpPorts": {
552
556
  "type": "boolean",
553
557
  "default": true
@@ -1161,133 +1165,6 @@
1161
1165
  "default": {},
1162
1166
  "additionalProperties": true
1163
1167
  },
1164
- "server": {
1165
- "type": "object",
1166
- "properties": {
1167
- "hostname": {
1168
- "type": "string"
1169
- },
1170
- "port": {
1171
- "anyOf": [
1172
- {
1173
- "type": "integer"
1174
- },
1175
- {
1176
- "type": "string"
1177
- }
1178
- ]
1179
- },
1180
- "portAssignment": {
1181
- "type": "string",
1182
- "enum": [
1183
- "shared",
1184
- "perWorkerIncrement"
1185
- ],
1186
- "description": "Configures how entrypoint server worker ports are assigned. When set to shared, all workers listen on the same port. When set to perWorkerIncrement, each worker will use its own port, starting from port (worker 0)."
1187
- },
1188
- "backlog": {
1189
- "type": "integer",
1190
- "description": "The maximum length of the queue of pending connections"
1191
- },
1192
- "http2": {
1193
- "type": "boolean"
1194
- },
1195
- "https": {
1196
- "type": "object",
1197
- "properties": {
1198
- "allowHTTP1": {
1199
- "type": "boolean"
1200
- },
1201
- "key": {
1202
- "anyOf": [
1203
- {
1204
- "type": "string"
1205
- },
1206
- {
1207
- "type": "object",
1208
- "properties": {
1209
- "path": {
1210
- "type": "string",
1211
- "resolvePath": true
1212
- }
1213
- },
1214
- "additionalProperties": false
1215
- },
1216
- {
1217
- "type": "array",
1218
- "items": {
1219
- "anyOf": [
1220
- {
1221
- "type": "string"
1222
- },
1223
- {
1224
- "type": "object",
1225
- "properties": {
1226
- "path": {
1227
- "type": "string",
1228
- "resolvePath": true
1229
- }
1230
- },
1231
- "additionalProperties": false
1232
- }
1233
- ]
1234
- }
1235
- }
1236
- ]
1237
- },
1238
- "cert": {
1239
- "anyOf": [
1240
- {
1241
- "type": "string"
1242
- },
1243
- {
1244
- "type": "object",
1245
- "properties": {
1246
- "path": {
1247
- "type": "string",
1248
- "resolvePath": true
1249
- }
1250
- },
1251
- "additionalProperties": false
1252
- },
1253
- {
1254
- "type": "array",
1255
- "items": {
1256
- "anyOf": [
1257
- {
1258
- "type": "string"
1259
- },
1260
- {
1261
- "type": "object",
1262
- "properties": {
1263
- "path": {
1264
- "type": "string",
1265
- "resolvePath": true
1266
- }
1267
- },
1268
- "additionalProperties": false
1269
- }
1270
- ]
1271
- }
1272
- }
1273
- ]
1274
- },
1275
- "requestCert": {
1276
- "type": "boolean"
1277
- },
1278
- "rejectUnauthorized": {
1279
- "type": "boolean"
1280
- }
1281
- },
1282
- "additionalProperties": false,
1283
- "required": [
1284
- "key",
1285
- "cert"
1286
- ]
1287
- }
1288
- },
1289
- "additionalProperties": false
1290
- },
1291
1168
  "reuseTcpPorts": {
1292
1169
  "type": "boolean",
1293
1170
  "default": true
package/watt.json DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "$schema": "https://schemas.platformatic.dev/@platformatic/vite/3.26.0.json?autogenerated=true"
3
- }