tungsten 0.1.70 → 0.1.71

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.
Files changed (73) hide show
  1. package/dist/Components.d.ts +2 -2
  2. package/dist/Components.d.ts.map +1 -1
  3. package/dist/Framework.d.ts.map +1 -1
  4. package/dist/Framework.js +11 -7
  5. package/dist/FrameworkConfig.d.ts +3 -1
  6. package/dist/FrameworkConfig.d.ts.map +1 -1
  7. package/dist/Instance/Instance.d.ts.map +1 -1
  8. package/dist/Instance/Instance.js +7 -1
  9. package/dist/Servers/DevServer.d.ts +4 -1
  10. package/dist/Servers/DevServer.d.ts.map +1 -1
  11. package/dist/Servers/DevServer.js +141 -48
  12. package/dist/Servers/ProdServer.d.ts +0 -1
  13. package/dist/Servers/ProdServer.d.ts.map +1 -1
  14. package/dist/Servers/ProdServer.js +48 -12
  15. package/dist/Servers/TungstenServer.d.ts.map +1 -1
  16. package/dist/Servers/TungstenServer.js +5 -0
  17. package/dist/Servers/hono/DevServerHono.d.ts +2 -0
  18. package/dist/Servers/hono/DevServerHono.d.ts.map +1 -0
  19. package/dist/Servers/hono/DevServerHono.js +427 -0
  20. package/dist/Servers/hono/ProdServerHono.d.ts +2 -0
  21. package/dist/Servers/hono/ProdServerHono.d.ts.map +1 -0
  22. package/dist/Servers/hono/ProdServerHono.js +313 -0
  23. package/dist/Servers/hono/TungstenServerHono.d.ts +6 -0
  24. package/dist/Servers/hono/TungstenServerHono.d.ts.map +1 -0
  25. package/dist/Servers/hono/TungstenServerHono.js +48 -0
  26. package/dist/Servers/loadEnvsDev.d.ts.map +1 -1
  27. package/dist/Servers/loadEnvsDev.js +9 -1
  28. package/dist/Servers/tungstenCorePrivateEnvSchema.d.ts +10 -0
  29. package/dist/Servers/tungstenCorePrivateEnvSchema.d.ts.map +1 -0
  30. package/dist/Servers/tungstenCorePrivateEnvSchema.js +24 -0
  31. package/dist/api/ApiEndpointHono.d.ts +3 -0
  32. package/dist/api/ApiEndpointHono.d.ts.map +1 -0
  33. package/dist/api/ApiEndpointHono.js +1 -0
  34. package/dist/api/ApiRouteHono.d.ts +7 -0
  35. package/dist/api/ApiRouteHono.d.ts.map +1 -0
  36. package/dist/api/ApiRouteHono.js +1 -0
  37. package/dist/api/ApiRoutesHono.d.ts +5 -0
  38. package/dist/api/ApiRoutesHono.d.ts.map +1 -0
  39. package/dist/api/ApiRoutesHono.js +1 -0
  40. package/dist/api/getApiRoutesHono.d.ts +6 -0
  41. package/dist/api/getApiRoutesHono.d.ts.map +1 -0
  42. package/dist/api/getApiRoutesHono.js +14 -0
  43. package/dist/build/modifySassImports.sxyt.js +1 -1
  44. package/dist/components/RedirectComponent.d.ts +1 -1
  45. package/dist/components/RedirectComponent.d.ts.map +1 -1
  46. package/dist/defaultConfig.d.ts +2 -0
  47. package/dist/defaultConfig.d.ts.map +1 -1
  48. package/dist/defaultConfig.js +3 -1
  49. package/dist/env/Interfaces.d.ts +2 -4
  50. package/dist/env/Interfaces.d.ts.map +1 -1
  51. package/dist/frameworkConfigSchema.d.ts +7 -7
  52. package/dist/indexInner.d.ts +2 -0
  53. package/dist/indexInner.d.ts.map +1 -1
  54. package/dist/indexInner.js +2 -0
  55. package/dist/makeFinalConfig.d.ts.map +1 -1
  56. package/dist/makeFinalConfig.js +1 -1
  57. package/dist/routing/RedirectCode.d.ts +2 -0
  58. package/dist/routing/RedirectCode.d.ts.map +1 -0
  59. package/dist/routing/RedirectCode.js +1 -0
  60. package/dist/routing/RouteDataFunction.type.d.ts +2 -1
  61. package/dist/routing/RouteDataFunction.type.d.ts.map +1 -1
  62. package/dist/routing/RouteDataReturnType.d.ts +2 -1
  63. package/dist/routing/RouteDataReturnType.d.ts.map +1 -1
  64. package/dist/routing/RoutingRedirect.d.ts +1 -1
  65. package/dist/routing/RoutingRedirect.d.ts.map +1 -1
  66. package/dist/routing/WebRedirect.d.ts +8 -0
  67. package/dist/routing/WebRedirect.d.ts.map +1 -0
  68. package/dist/routing/WebRedirect.js +11 -0
  69. package/dist/routing/registerGlobalData.d.ts +3 -1
  70. package/dist/routing/registerGlobalData.d.ts.map +1 -1
  71. package/dist/routing/registerGlobalData.js +4 -2
  72. package/package.json +35 -31
  73. package/types/helpers.d.ts +2 -0
@@ -0,0 +1,313 @@
1
+ // import type { AddressInfo } from 'net'
2
+ // //import express from 'express'
3
+ // import { Hono } from 'hono'
4
+ // import { serve } from '@hono/node-server'
5
+ // import { Server } from 'http'
6
+ // import { join } from 'path'
7
+ // import { existsSync } from 'fs'
8
+ // //import { SxyServer } from './SxyServer.js'
9
+ // import type { FrameworkConfigComplete } from '../../FrameworkConfig.js'
10
+ // import type { CompilationInfo } from '../../build/CompilationInfo.js'
11
+ // import type { ApiRoutes } from '../../api/ApiRoutes.js'
12
+ // import { staticFolder, assetsFolder, packageNameCapitalized, publicFolder } from '../../settings.js'
13
+ // import { rootToHtml as renderRootToHtml } from '../../render/rootToHtml.js'
14
+ // import { contentToHtml as renderContentToHtml } from '../../render/contentToHtml.js'
15
+ // import { Instance } from '../../Instance/Instance.js'
16
+ // import { cliOut, cliWarn, cliLog, cliNews, cliDebug, cliTodo } from '../../cliOutput.js' // eslint-disable-line @typescript-eslint/no-unused-vars
17
+ // import { Framework } from '../../Framework.js'
18
+ // import { TungstenError } from '../../TungstenError.js'
19
+ // import { makeInstanceConfigFromFrameworkConfig } from '../../makeInstanceConfigFromFrameworkConfig.js'
20
+ // //import { addRequireResolveHooks } from '../reRouting/addRequireResolveHooks.js'
21
+ // import { standardizeWebPath } from '../../standardizeWebPath.js'
22
+ // import { throwError } from '../../throwError.js'
23
+ // import { AnyComponentType } from '../../AnyComponentType.js'
24
+ // import { AppRoutes } from '../../routing/AppRoutes.js'
25
+ // import { ReqRes } from '../../ReqRes.js'
26
+ // import { routing } from '../routing.jsx'
27
+ // import { globalDataFunc } from '../../routing/registerGlobalData.js'
28
+ // import { ServerDataLoading } from '../../Store/ServerDataLoading.js'
29
+ // import { ServerMiddleware } from '../ServerMiddleware.js'
30
+ // import { TungstenServer } from '../TungstenServer.jsx'
31
+ // import { portError } from '../portError.js'
32
+ // import { initStores } from '../initStores.js'
33
+ // import { RoutingRedirect } from '../../routing/RoutingRedirect.js'
34
+ // import { RedirectComponent } from 'tungsten/components/RedirectComponent.js'
35
+ // import { TungstenServerHono } from './TungstenServerHono.jsx'
36
+ export {};
37
+ // function debug(...texts: any[]) { // eslint-disable-line @typescript-eslint/no-unused-vars
38
+ // // console.log(...texts)
39
+ // }
40
+ // export class ProdServerHono extends TungstenServerHono {
41
+ // framework: Framework
42
+ // config: FrameworkConfigComplete
43
+ // compilationInfo: CompilationInfo
44
+ // appRoutes: AppRoutes
45
+ // RootComponentOrNull: AnyComponentType | null
46
+ // // projectDir: string
47
+ // // prodBuildLocation: string
48
+ // // bundleLocation: string
49
+ // //port: number
50
+ // location: string | null = null
51
+ // app: express.Application
52
+ // apiRoutesPromise?: Promise<ApiRoutes>
53
+ // apiRoutes?: ApiRoutes
54
+ // server?: Server
55
+ // constructor(
56
+ // framework: Framework,
57
+ // config: FrameworkConfigComplete,
58
+ // compilationInfo: CompilationInfo,
59
+ // appRoutes: AppRoutes,
60
+ // RootComponentOrNull: AnyComponentType | null,
61
+ // serverMiddleware: ServerMiddleware | null
62
+ // ) {
63
+ // super()
64
+ // this.framework = framework
65
+ // this.config = config
66
+ // this.compilationInfo = compilationInfo
67
+ // this.appRoutes = appRoutes
68
+ // this.RootComponentOrNull = RootComponentOrNull
69
+ // // if (tungstenPrivateEnv.TUNGSTEN_SERVER_PORT === -999) {
70
+ // // throwError('ProdServer', 'TUNGSTEN_SERVER_PORT environment variable has not been set')
71
+ // // }
72
+ // // !! I wrote this line while drunk. Please check this over. I think its wrong
73
+ // //const _port = Number((typeof tungstenPrivateEnv !== 'undefined')
74
+ // // ? tungstenPrivateEnv.TUNGSTEN_SERVER_PORT
75
+ // // : process.env.TUNGSTEN_SERVER_PORT)
76
+ // // seems like all we need is:
77
+ // this.app = express()
78
+ // if (tungstenPrivateEnv.DEBUG === true) {
79
+ // let reqId = 0
80
+ // this.app.use((req, res, next) => {
81
+ // reqId++
82
+ // cliDebug(`Received request [${reqId}] for ${req.url}`)
83
+ // next()
84
+ // })
85
+ // }
86
+ // const requestLog = (tungstenPrivateEnv.DEBUG === true)
87
+ // const originMismatchWarning = (this.config.suppressOriginMismatchWarning !== true)
88
+ // if (requestLog || originMismatchWarning) {
89
+ // this.app.use((req, res, next) => {
90
+ // const target = req.protocol + '://' + String(req.header('host')) + req.url
91
+ // const origin = req.header('origin')
92
+ // // request log
93
+ // if (requestLog) {
94
+ // let message = 'Received request at ' + target
95
+ // if (origin !== undefined) {
96
+ // message += ' from ' + String(req.header('origin'))
97
+ // // should we use referrer as a backup option?
98
+ // // not sure what that is
99
+ // }
100
+ // cliOut(message)
101
+ // }
102
+ // // origin-target mismatch warning
103
+ // if (originMismatchWarning) {
104
+ // if (origin !== undefined && origin === this.location && origin !== target) {
105
+ // cliWarn(
106
+ // `Received a request from the frontend, but it's origin`
107
+ // + ` is not the same as the request origin.`
108
+ // + ` This may indicate a misconfiguration, and may prevent`
109
+ // + ` the passing of cookies to the tungsten server.`
110
+ // )
111
+ // }
112
+ // }
113
+ // next()
114
+ // })
115
+ // }
116
+ // if (serverMiddleware) {
117
+ // const { path, middlewares } = serverMiddleware
118
+ // this.app.use(path, middlewares)
119
+ // }
120
+ // //this.app.set('etag', false)
121
+ // if (this.compilationInfo.bundleLocation === undefined) {
122
+ // throwError('ProdServer', 'compilationInfo.bundleLocation is unset/undefined')
123
+ // }
124
+ // this.app.use('/bundle', express.static(this.compilationInfo.bundleLocation))
125
+ // const publicLocation = join(this.compilationInfo.location, publicFolder)
126
+ // //console.log('publicLocation', publicLocation, existsSync(publicLocation))
127
+ // if (existsSync(publicLocation)) this.app.use(express.static(publicLocation)) // files from public folder
128
+ // //console.log("serving static files with etag")
129
+ // this.app.use(express.static(join(this.compilationInfo.location, staticFolder)))
130
+ // if (this.config.assetsDir !== undefined) {
131
+ // this.app.use('/assets', express.static(join(this.compilationInfo.location, assetsFolder)))
132
+ // }
133
+ // this.app.use(express.static(this.compilationInfo.location))
134
+ // if (typeof config.apiRoutes === 'string' && config.apiRoutes !== '') {
135
+ // const apiPath = standardizeWebPath(this.config.apiPath)
136
+ // cliOut(`API listening at ${apiPath}`)
137
+ // this.app.use(apiPath, express.json())
138
+ // this.app.use(apiPath, this.handleRequestApi)
139
+ // }
140
+ // this.app.use(this.handleRequest)
141
+ // }
142
+ // // private addServerMiddleware = (serverMiddleware: ServerMiddlewareInfo): void => {
143
+ // // const [middlewareFile, middlewareExportName, middlewarePath] = serverMiddleware
144
+ // // const fullFilePath = 'file://' + join(this.compilationInfo.codeLocation, middlewareFile)
145
+ // // const middlewareModule = await import(fullFilePath)
146
+ // // if ( ! (middlewareExportName in middlewareModule) ) {
147
+ // // throwError('DevServer', `export ${middlewareExportName} not found in ${middlewareFile} when trying to load server middleware`)
148
+ // // }
149
+ // // const middleware = middlewareModule[middlewareExportName] as RequestHandler[]
150
+ // // console.log('prod middleware', middleware)
151
+ // // const path = middlewarePath.startsWith('/') ? middlewarePath : '/' + middlewarePath
152
+ // // console.log('path', `|${path}|`)
153
+ // // console.log('this.app', this.app)
154
+ // // this.app.use('/api', (req, res, next) => {
155
+ // // console.log('request to api 1')
156
+ // // next()
157
+ // // })
158
+ // // this.app.use(path, (req, res, next) => {
159
+ // // console.log('request to api')
160
+ // // next()
161
+ // // })
162
+ // // this.app.use(path, middleware)
163
+ // // cliOut(`Server Middleware added to server at ${path}`)
164
+ // // }
165
+ // private handleRequestApi = async (
166
+ // req: express.Request, res: express.Response, next: express.NextFunction
167
+ // ): Promise<void> => {
168
+ // //this.apiRoutes = await this.apiRoutesPromise
169
+ // throw new TungstenError(`handleRequestApi incomplete in dev server - add to get the API in the build step`)
170
+ // // const requestPath = standardizeWebPath(req.baseUrl + req.path)
171
+ // // for (const [path, route] of Object.entries(this.apiRoutes)) {
172
+ // // //console.log(path, 'vs', requestPath)
173
+ // // //console.log('path', path, standardizeWebPath(path))
174
+ // // if (standardizeWebPath(path) === requestPath) {
175
+ // // //console.log('API route matched', path)
176
+ // // return route.endpoint(req, res)
177
+ // // }
178
+ // // }
179
+ // // // else
180
+ // // res.sendStatus(404)
181
+ // }
182
+ // handleRequest = async (req: express.Request, res: express.Response): Promise<void> => {
183
+ // if (/\.(css|scss|sass|js|jsx|png|jpg|jpeg|svg|ico|txt)$/.test(req.url)) {
184
+ // cliLog(`Requested asset file ${req.url} was not found`)
185
+ // res.status(404).end()
186
+ // return
187
+ // }
188
+ // try {
189
+ // const location = req.url
190
+ // const instanceConfig = makeInstanceConfigFromFrameworkConfig(this.config)
191
+ // if (this.framework.frameworkModules === undefined) {
192
+ // throwError('ProdServer.handleRequest()',
193
+ // 'framework.frameworkModules is undefined'
194
+ // )
195
+ // }
196
+ // if (this.framework.clientImportAliases === undefined) {
197
+ // throwError('ProdServer.handleRequest()',
198
+ // 'framework.clientImportAliases is undefined'
199
+ // )
200
+ // }
201
+ // // const appRoutes: AppRoutes = await getRoutes(this.compilationInfo, this.config)
202
+ // // let RootComponentClass: AnyComponentType
203
+ // // if (this.config.useRootComponent) {
204
+ // // const rootComponentFileFull = join(this.compilationInfo.location, this.config.rootComponent)
205
+ // // RootComponentClass = await getComponent(rootComponentFileFull, this.config.rootComponent)
206
+ // // } else {
207
+ // // throwError('DevServer', 'useRootComponent = false not implemented yet')
208
+ // // }
209
+ // const { compilationInfo, config, appRoutes, RootComponentOrNull } = this
210
+ // const reqRes: ReqRes = { req, res }
211
+ // //const routes = instance.getRoutes()
212
+ // const serverDataLoading: ServerDataLoading = { value: false }
213
+ // const routes = (typeof appRoutes === 'function') ? appRoutes(reqRes) : appRoutes
214
+ // const [globalData, matchedRouteInfo] = await Promise.all([
215
+ // (globalDataFunc.value !== undefined) ? globalDataFunc.value(reqRes) : {},
216
+ // routing(location, routes, serverDataLoading)
217
+ // ])
218
+ // //instance.matchedRouteInfo =
219
+ // //cliTodo('Can we move redirect handling to base class?')
220
+ // // // 2025-03-14 copied this code here from Dev server,
221
+ // // // because it looked like it was missing
222
+ // // if (matchedRouteInfo.data instanceof RoutingRedirect) {
223
+ // // const redirect = matchedRouteInfo.data
224
+ // // res.redirect(redirect.code, redirect.to)
225
+ // // return
226
+ // // }
227
+ // // // handle redirect components
228
+ // // if (
229
+ // // matchedRouteInfo.content instanceof RedirectComponent
230
+ // // //&& matchedRouteInfo.content.__tungstenComponentType === 'redirect'
231
+ // // ) {
232
+ // // const { code = 302, to } = matchedRouteInfo.content.props
233
+ // // res.redirect(code, to)
234
+ // // return
235
+ // // }
236
+ // const redirected = this.handleRedirects(res, matchedRouteInfo)
237
+ // if (redirected) return // end early
238
+ // const { internalStore, stores, storeSubscriptions }
239
+ // = initStores(location, reqRes, globalData, matchedRouteInfo, serverDataLoading)
240
+ // const instance = new Instance(
241
+ // location, instanceConfig, reqRes, appRoutes, routes, internalStore,
242
+ // stores, storeSubscriptions, globalData, matchedRouteInfo
243
+ // )
244
+ // let html: string
245
+ // if (RootComponentOrNull !== null) {
246
+ // html = await renderRootToHtml(
247
+ // this.compilationInfo, this.framework.clientImportAliases,
248
+ // RootComponentOrNull, instance, config, this.config.siteBasePath
249
+ // )
250
+ // } else {
251
+ // const { params, data } = matchedRouteInfo
252
+ // let { content } = matchedRouteInfo
253
+ // if (typeof content === 'function') {
254
+ // content = content(data, params, {} /* props */, globalData, location)
255
+ // //throwError('DevServer', 'route content is a function')
256
+ // }
257
+ // html = await renderContentToHtml(
258
+ // this.compilationInfo, this.framework.clientImportAliases,
259
+ // content, instance, config, this.config.siteBasePath
260
+ // )
261
+ // }
262
+ // //debug('html', html)
263
+ // res.setHeader('Content-Type', 'text/html')
264
+ // res.status((instance.matchedRouteInfo.key === '404') ? 404 : 200)
265
+ // res.send(html)
266
+ // } catch(e) {
267
+ // cliLog('handleRequest() error', e)
268
+ // res.setHeader('Content-Type', 'text/html')
269
+ // res.status(500)
270
+ // res.send(this.errorPage())
271
+ // }
272
+ // }
273
+ // errorPage = () => {
274
+ // return `<!DOCTYPE html>
275
+ // </html>
276
+ // <head><title>Error</title></head>
277
+ // <body>
278
+ // <h1>Internal error</h1>
279
+ // <p>Something went wrong. Please contact the site owner for help.</p>
280
+ // </body>
281
+ // </html>`
282
+ // }
283
+ // // private async handlePost(req: express.Request, res: express.Response): Promise<void> {
284
+ // // throw new TungstenError(`Err - Dev server received a post request. Not supported yet.`)
285
+ // // }
286
+ // // I don't think we ever override the port, not sure why
287
+ // start(portOverride?: number | null, mute = false): Promise<string> {
288
+ // return new Promise( (resolve) => {
289
+ // const proto = tungstenPrivateEnv.FRONTEND_PROTO ?? 'http'
290
+ // const host = tungstenPrivateEnv.FRONTEND_HOST ?? 'localhost'
291
+ // let port: number | null
292
+ // if (portOverride !== undefined) {
293
+ // port = portOverride
294
+ // } else {
295
+ // const _port = tungstenPrivateEnv.TUNGSTEN_SERVER_PORT ?? 3000
296
+ // if (isNaN(_port) || _port === 0) throwError('ProdServer', portError(_port))
297
+ // port = _port
298
+ // }
299
+ // //const port = (portOverride !== undefined) ? portOverride : port
300
+ // // eslint-disable-next-line no-console
301
+ // this.server = this.app.listen(port, () => {
302
+ // const serverAddress = this.server!.address() as AddressInfo // eslint-disable-line @typescript-eslint/no-non-null-assertion, no-type-assertion/no-type-assertion
303
+ // this.location = `${proto}://${host}:${serverAddress.port}`
304
+ // if (!mute) cliNews(`${packageNameCapitalized} prod server ready at ${this.location}`)
305
+ // resolve(this.location)
306
+ // })
307
+ // })
308
+ // }
309
+ // stop() {
310
+ // if (this.server !== undefined) this.server.close()
311
+ // }
312
+ // //treeToHtml = treeToHtml
313
+ // }
@@ -0,0 +1,6 @@
1
+ import type { MatchedRouteInfo } from '../MatchedRouteInfo.js';
2
+ import { Context } from 'hono';
3
+ export declare class TungstenServerHono {
4
+ protected handleRedirects(c: Context, matchedRouteInfo: MatchedRouteInfo): boolean;
5
+ }
6
+ //# sourceMappingURL=TungstenServerHono.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TungstenServerHono.d.ts","sourceRoot":"","sources":["../../../src/Servers/hono/TungstenServerHono.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAG9D,OAAO,EAAQ,OAAO,EAAE,MAAM,MAAM,CAAA;AAsBpC,qBAAa,kBAAkB;IAC3B,SAAS,CAAC,eAAe,CAAC,CAAC,EAAE,OAAO,EAAY,gBAAgB,EAAE,gBAAgB,GAAG,OAAO;CAyC/F"}
@@ -0,0 +1,48 @@
1
+ //import type { Response as ExpressResponse } from 'express'
2
+ import { Hono } from 'hono';
3
+ import { ContentNodeIsClassComponent } from "../../ContentNode.js";
4
+ import { RoutingRedirect } from "../../routing/RoutingRedirect.js";
5
+ import { cliTodo } from "../../cliOutput.js";
6
+ import { RedirectComponent } from "../../components/RedirectComponent.js";
7
+ import { $props, $type } from "../../contentNodeSymbols.js";
8
+ import { WebRedirect } from "../../routing/WebRedirect.js";
9
+ const app = new Hono();
10
+ app.get(async c => {
11
+ const id = c.req.param('id');
12
+ c.res;
13
+ // ...
14
+ });
15
+ function debug(...texts) {
16
+ // console.log(...texts)
17
+ }
18
+ export class TungstenServerHono {
19
+ handleRedirects(c /* any */, matchedRouteInfo) {
20
+ // handle any redirect issued during routing
21
+ if (matchedRouteInfo.data instanceof RoutingRedirect) {
22
+ const redirect = matchedRouteInfo.data;
23
+ c.redirect(redirect.to, redirect.code);
24
+ return true;
25
+ } else if (matchedRouteInfo.data instanceof WebRedirect) {
26
+ const redirect = matchedRouteInfo.data;
27
+ c.redirect(redirect.to, redirect.code);
28
+ return true;
29
+ }
30
+ // console.log('content', matchedRouteInfo.content)
31
+ // console.log('is func', typeof matchedRouteInfo.content !== 'function')
32
+ // console.log('ContentNodeIsClassComponent', ContentNodeIsClassComponent(matchedRouteInfo.content as any))
33
+ // console.log('instanceof', (matchedRouteInfo as any).content[$type] instanceof RedirectComponent)
34
+ // console.log('prototype instanceof', (matchedRouteInfo as any).content[$type].prototype instanceof RedirectComponent)
35
+ // console.log('__tungstenRedirect', (matchedRouteInfo as any).content[$type].__tungstenRedirect)
36
+ // console.log('$type', (matchedRouteInfo as any).content[$type])
37
+ //console.log('content[$type]', matchedRouteInfo.content[$type])
38
+ //console.log('instanceof', matchedRouteInfo.content instanceof RedirectComponent)
39
+ if (typeof matchedRouteInfo.content !== 'function' && ContentNodeIsClassComponent(matchedRouteInfo.content) && (matchedRouteInfo.content[$type] === RedirectComponent || matchedRouteInfo.content[$type].prototype instanceof RedirectComponent)) {
40
+ cliTodo('consider type of RedirectComponent props');
41
+ const code = matchedRouteInfo.content[$props].code || 302;
42
+ const to = matchedRouteInfo.content[$props].to;
43
+ c.redirect(to, code);
44
+ return true;
45
+ }
46
+ return false;
47
+ }
48
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"loadEnvsDev.d.ts","sourceRoot":"","sources":["../../src/Servers/loadEnvsDev.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AAOpE,KAAK,UAAU,GAAG;IACd,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IAChC,EAAE,CAAC,EAAE,MAAM,CAAC;CACf,CAAA;AAED,wBAAsB,WAAW,CAC7B,MAAM,EAAE,uBAAuB,EAC/B,IAAI,EAAE,IAAI,EACV,iBAAiB,EAAE,UAAU,EAC7B,UAAU,EAAE,OAAO,iBAsFtB"}
1
+ {"version":3,"file":"loadEnvsDev.d.ts","sourceRoot":"","sources":["../../src/Servers/loadEnvsDev.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AAQpE,KAAK,UAAU,GAAG;IACd,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IAChC,EAAE,CAAC,EAAE,MAAM,CAAC;CACf,CAAA;AAED,wBAAsB,WAAW,CAC7B,MAAM,EAAE,uBAAuB,EAC/B,IAAI,EAAE,IAAI,EACV,iBAAiB,EAAE,UAAU,EAC7B,UAAU,EAAE,OAAO,iBAkGtB"}
@@ -6,6 +6,7 @@ import { parseIni } from "../parseIni.js";
6
6
  import { cliLog, cliOut } from "../cliOutput.js";
7
7
  import { injectEnv } from "../env/injectEnv.js";
8
8
  import { throwError } from 'tungsten/throwError.js';
9
+ import { tungstenCorePrivateEnvSchema } from "./tungstenCorePrivateEnvSchema.js";
9
10
  export async function loadEnvsDev(config, load, initialProcessEnv, _firstLoad) {
10
11
  //console.log('loadEnvsDev')
11
12
  const tempEnv = {
@@ -43,7 +44,14 @@ export async function loadEnvsDev(config, load, initialProcessEnv, _firstLoad) {
43
44
  // global.tungstenPrivateEnv = envSchemas.privateEnvSchema.parse(process.env)
44
45
  const result = envSchemas.privateEnvSchema.safeParse(tempEnv);
45
46
  if (!result.success) {
46
- throwError('Private Env failed schema validation', '\n' + JSON.stringify(result.error.format(), null, 4) + '\nenv: ' + JSON.stringify(tempEnv, null, 4) + '\nparsed env ' + JSON.stringify(tempEnv, null, 4));
47
+ throwError('Your environment variables failed your privateEnvSchema validation', '\n' + JSON.stringify(result.error.format(), null, 4) + '\nenv: ' + JSON.stringify(tempEnv, null, 4) + '\nparsed env ' + JSON.stringify(tempEnv, null, 4));
48
+ }
49
+ const coreResult = tungstenCorePrivateEnvSchema.safeParse(result.data);
50
+ //console.log('coreResult', coreResult)
51
+ if (!coreResult.success) {
52
+ throwError('Your private environment variables don\'t meet the Tungsten requirements. Ensure your .env and privateEnvSchema provide an output meeting these requirements. You may need to coerce data to the correct type.',
53
+ // eslint-disable-line max-len
54
+ '\n' + JSON.stringify(coreResult.error.format(), null, 4) + '\nenv: ' + JSON.stringify(tempEnv, null, 4) + '\nparsed env ' + JSON.stringify(tempEnv, null, 4));
47
55
  }
48
56
  global.tungstenPrivateEnv = result.data;
49
57
  //console.log('global.tungstenPrivateEnv', global.tungstenPrivateEnv)
@@ -0,0 +1,10 @@
1
+ import { z } from 'zod';
2
+ export declare const tungstenCorePrivateEnvSchema: z.ZodObject<{
3
+ TUNGSTEN_SERVER_PORT: z.ZodOptional<z.ZodNumber>;
4
+ FRONTEND_PROTO: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"http">, z.ZodLiteral<"https">]>>;
5
+ FRONTEND_HOST: z.ZodOptional<z.ZodString>;
6
+ FRONTEND_PORT: z.ZodOptional<z.ZodNumber>;
7
+ DEBUG: z.ZodOptional<z.ZodBoolean>;
8
+ }, z.core.$loose>;
9
+ export type TungstenCorePrivateEnv = typeof tungstenCorePrivateEnvSchema._output;
10
+ //# sourceMappingURL=tungstenCorePrivateEnvSchema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tungstenCorePrivateEnvSchema.d.ts","sourceRoot":"","sources":["../../src/Servers/tungstenCorePrivateEnvSchema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAkBvB,eAAO,MAAM,4BAA4B;;;;;;iBASvC,CAAA;AAGF,MAAM,MAAM,sBAAsB,GAAG,OAAO,4BAA4B,CAAC,OAAO,CAAA"}
@@ -0,0 +1,24 @@
1
+ import { z } from 'zod';
2
+ // mutative
3
+ // const protoSchema = z.union([z.literal('http'), z.literal('https')])
4
+ // const portSchema = z.coerce.number().gt(0)
5
+ // export const tungstenCorePrivateEnvSchema = z.object({
6
+ // TUNGSTEN_SERVER_PORT: z.optional(portSchema),
7
+ // FRONTEND_PROTO: z.optional(protoSchema),
8
+ // FRONTEND_HOST: z.optional(z.string()),
9
+ // FRONTEND_PORT: z.optional(portSchema),
10
+ // DEBUG: z.optional(z.boolean())
11
+ // })
12
+ // non-mutative
13
+ const protoSchema = z.union([z.literal('http'), z.literal('https')]);
14
+ const portSchema = z.number().gt(0);
15
+ export const tungstenCorePrivateEnvSchema = z.looseObject({
16
+ TUNGSTEN_SERVER_PORT: z.optional(portSchema),
17
+ FRONTEND_PROTO: z.optional(protoSchema),
18
+ FRONTEND_HOST: z.optional(z.string()),
19
+ FRONTEND_PORT: z.optional(portSchema),
20
+ DEBUG: z.optional(z.boolean())
21
+ // SUPPRESS: z.optional(z.object({
22
+ // ORIGIN_MISMATCH_WARNING: z.optional(z.boolean())
23
+ // }))
24
+ });
@@ -0,0 +1,3 @@
1
+ import type { Context, Next } from 'hono';
2
+ export type ApiEndpointHono = (c: Context, next: Next) => Response;
3
+ //# sourceMappingURL=ApiEndpointHono.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApiEndpointHono.d.ts","sourceRoot":"","sources":["../../src/api/ApiEndpointHono.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAEzC,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,KAAK,QAAQ,CAAA"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ import type { ApiEndpointHono } from './ApiEndpointHono.js';
2
+ import { Method } from './Method.js';
3
+ export type ApiRouteHono = {
4
+ method: Method;
5
+ endpoint: ApiEndpointHono;
6
+ };
7
+ //# sourceMappingURL=ApiRouteHono.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApiRouteHono.d.ts","sourceRoot":"","sources":["../../src/api/ApiRouteHono.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,MAAM,MAAM,YAAY,GAAG;IACvB,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,eAAe,CAAA;CAC5B,CAAA"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ import { ApiRouteHono } from './ApiRouteHono.js';
2
+ export type ApiRoutesHono = {
3
+ [key: string]: ApiRouteHono;
4
+ };
5
+ //# sourceMappingURL=ApiRoutesHono.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApiRoutesHono.d.ts","sourceRoot":"","sources":["../../src/api/ApiRoutesHono.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAEhD,MAAM,MAAM,aAAa,GAAG;IACxB,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,CAAA;CAC9B,CAAA"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ import { Mode } from '../Mode.js';
2
+ import type { ApiRoutesHono } from './ApiRoutesHono.js';
3
+ import { FrameworkConfig } from '../FrameworkConfig.js';
4
+ import { CompilationInfo } from '../build/CompilationInfo.js';
5
+ export declare function getApiRoutesHono(config: FrameworkConfig, compilationInfo: CompilationInfo, mode: Mode): Promise<ApiRoutesHono>;
6
+ //# sourceMappingURL=getApiRoutesHono.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getApiRoutesHono.d.ts","sourceRoot":"","sources":["../../src/api/getApiRoutesHono.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAGjC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD,OAAO,EAAE,eAAe,EAAC,MAAM,6BAA6B,CAAA;AAK5D,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,eAAe,EAAE,eAAe,EAAE,eAAe,EAAE,IAAI,EAAE,IAAI,0BAe3G"}
@@ -0,0 +1,14 @@
1
+ import { join } from 'path';
2
+ import { TungstenError } from "../TungstenError.js";
3
+ import { getExportDev } from "./getExportDev.js";
4
+ import { getExport } from "./getExport.js";
5
+ export async function getApiRoutesHono(config, compilationInfo, mode) {
6
+ if (typeof config.apiRoutes !== 'string') {
7
+ throw new TungstenError(`getApiRoutes() error - config.apiRoutes is not valid`);
8
+ }
9
+ const apiRoutesFileFull = join(compilationInfo.location, config.apiRoutes);
10
+ //console.log('rootComponentFileFull', 'xxx', 'config.rootComponent', config.rootComponent)
11
+ //console.log('rootComponentFileFull', apiRoutesFileFull, 'config.rootComponent', config.apiRoutes)
12
+ const apiRoutes = mode === 'dev' ? await getExportDev(apiRoutesFileFull, config.apiRoutes) : await getExport(apiRoutesFileFull, config.apiRoutes);
13
+ return apiRoutes;
14
+ }
@@ -31,7 +31,7 @@ describe('modifySassImports()', ({
31
31
  it(`modifies 2 sass imports in content '${input2}'`, () => {
32
32
  const imports = sassImportParser(input2);
33
33
  imports[0].to = '/project/styles/foo' // eslint-disable-line no-type-assertion/no-type-assertion
34
- ;
34
+ ;
35
35
  imports[1].to = '/project/styles/baz'; // eslint-disable-line no-type-assertion/no-type-assertion
36
36
  console.log('imports', imports);
37
37
  // const imports = [
@@ -1,6 +1,6 @@
1
1
  import { TungstenSimpleComponent } from '../Components.jsx';
2
2
  import type { Path } from '../routing/RouteTypes.js';
3
- import type { RedirectCode } from '../routing/RoutingRedirect.js';
3
+ import type { RedirectCode } from '../routing/RedirectCode.js';
4
4
  export type RedirectComponentProps = {
5
5
  to: Path;
6
6
  code?: RedirectCode;
@@ -1 +1 @@
1
- {"version":3,"file":"RedirectComponent.d.ts","sourceRoot":"","sources":["../../src/components/RedirectComponent.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAEjE,MAAM,MAAM,sBAAsB,GAAG;IACjC,EAAE,EAAE,IAAI,CAAA;IACR,IAAI,CAAC,EAAE,YAAY,CAAA;CACtB,CAAA;AACD,qBAAa,iBAAkB,SAAQ,uBAAuB,CAAC,sBAAsB,CAAC;IAClF,MAAM,CAAC,kBAAkB,UAAO;IAIhC,OAAO,iFAEG;CACb"}
1
+ {"version":3,"file":"RedirectComponent.d.ts","sourceRoot":"","sources":["../../src/components/RedirectComponent.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAE9D,MAAM,MAAM,sBAAsB,GAAG;IACjC,EAAE,EAAE,IAAI,CAAA;IACR,IAAI,CAAC,EAAE,YAAY,CAAA;CACtB,CAAA;AACD,qBAAa,iBAAkB,SAAQ,uBAAuB,CAAC,sBAAsB,CAAC;IAClF,MAAM,CAAC,kBAAkB,UAAO;IAIhC,OAAO,iFAEG;CACb"}
@@ -13,6 +13,8 @@ export declare const defaultConfig: {
13
13
  packageSystem: "rewrites";
14
14
  ignoreDirs: string[];
15
15
  apiPath: string;
16
+ suppressNoHeadWarning: false;
17
+ suppressOriginMismatchWarning: false;
16
18
  };
17
19
  export type FrameworkConfigDefault = typeof defaultConfig;
18
20
  //# sourceMappingURL=defaultConfig.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"defaultConfig.d.ts","sourceRoot":"","sources":["../src/defaultConfig.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;CAmBS,CAAA;AAEnC,MAAM,MAAM,sBAAsB,GAAG,OAAO,aAAa,CAAA"}
1
+ {"version":3,"file":"defaultConfig.d.ts","sourceRoot":"","sources":["../src/defaultConfig.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;CAqBS,CAAA;AAEnC,MAAM,MAAM,sBAAsB,GAAG,OAAO,aAAa,CAAA"}
@@ -17,6 +17,8 @@ export const defaultConfig = {
17
17
  // apiRoutes
18
18
  ignoreDirs: ['server'],
19
19
  // rename to ignoreFolders?
20
- apiPath: '/api'
20
+ apiPath: '/api',
21
21
  //debug: false // moved to env
22
+ suppressNoHeadWarning: false,
23
+ suppressOriginMismatchWarning: false
22
24
  };
@@ -1,10 +1,8 @@
1
+ import type { TungstenCorePrivateEnv } from '../Servers/tungstenCorePrivateEnvSchema.js';
1
2
  declare global {
2
- interface TungstenPrivateEnv {
3
- TUNGSTEN_SERVER_PORT: number;
4
- DEBUG?: boolean;
3
+ interface TungstenPrivateEnv extends TungstenCorePrivateEnv {
5
4
  }
6
5
  export interface TungstenPublicEnv {
7
6
  }
8
7
  }
9
- export {};
10
8
  //# sourceMappingURL=Interfaces.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Interfaces.d.ts","sourceRoot":"","sources":["../../src/env/Interfaces.ts"],"names":[],"mappings":"AAEA,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,kBAAkB;QACxB,oBAAoB,EAAE,MAAM,CAAA;QAC5B,KAAK,CAAC,EAAE,OAAO,CAAA;KAClB;IACD,MAAM,WAAW,iBAAiB;KAAG;CACxC"}
1
+ {"version":3,"file":"Interfaces.d.ts","sourceRoot":"","sources":["../../src/env/Interfaces.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAA;AAExF,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,kBAAmB,SAAQ,sBAAsB;KAAG;IAC9D,MAAM,WAAW,iBAAiB;KAAG;CACxC"}