tungsten 0.1.70 → 0.1.72
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/dist/Components.d.ts +2 -2
- package/dist/Components.d.ts.map +1 -1
- package/dist/Framework.d.ts.map +1 -1
- package/dist/Framework.js +11 -7
- package/dist/FrameworkConfig.d.ts +3 -1
- package/dist/FrameworkConfig.d.ts.map +1 -1
- package/dist/Instance/Instance.d.ts +3 -1
- package/dist/Instance/Instance.d.ts.map +1 -1
- package/dist/Instance/Instance.js +39 -10
- package/dist/Servers/DevServer.d.ts +4 -1
- package/dist/Servers/DevServer.d.ts.map +1 -1
- package/dist/Servers/DevServer.js +143 -48
- package/dist/Servers/ProdServer.d.ts +0 -1
- package/dist/Servers/ProdServer.d.ts.map +1 -1
- package/dist/Servers/ProdServer.js +48 -12
- package/dist/Servers/TungstenServer.d.ts.map +1 -1
- package/dist/Servers/TungstenServer.js +21 -7
- package/dist/Servers/hono/DevServerHono.d.ts +2 -0
- package/dist/Servers/hono/DevServerHono.d.ts.map +1 -0
- package/dist/Servers/hono/DevServerHono.js +427 -0
- package/dist/Servers/hono/ProdServerHono.d.ts +2 -0
- package/dist/Servers/hono/ProdServerHono.d.ts.map +1 -0
- package/dist/Servers/hono/ProdServerHono.js +313 -0
- package/dist/Servers/hono/TungstenServerHono.d.ts +6 -0
- package/dist/Servers/hono/TungstenServerHono.d.ts.map +1 -0
- package/dist/Servers/hono/TungstenServerHono.js +53 -0
- package/dist/Servers/initStores.js +1 -1
- package/dist/Servers/loadEnvsDev.d.ts.map +1 -1
- package/dist/Servers/loadEnvsDev.js +9 -1
- package/dist/Servers/tungstenCorePrivateEnvSchema.d.ts +10 -0
- package/dist/Servers/tungstenCorePrivateEnvSchema.d.ts.map +1 -0
- package/dist/Servers/tungstenCorePrivateEnvSchema.js +24 -0
- package/dist/Store/InternalStoreSchema.d.ts +3 -1
- package/dist/Store/InternalStoreSchema.d.ts.map +1 -1
- package/dist/Store/InternalStoreSchema.js +3 -1
- package/dist/api/ApiEndpointHono.d.ts +3 -0
- package/dist/api/ApiEndpointHono.d.ts.map +1 -0
- package/dist/api/ApiEndpointHono.js +1 -0
- package/dist/api/ApiRouteHono.d.ts +7 -0
- package/dist/api/ApiRouteHono.d.ts.map +1 -0
- package/dist/api/ApiRouteHono.js +1 -0
- package/dist/api/ApiRoutesHono.d.ts +5 -0
- package/dist/api/ApiRoutesHono.d.ts.map +1 -0
- package/dist/api/ApiRoutesHono.js +1 -0
- package/dist/api/getApiRoutesHono.d.ts +6 -0
- package/dist/api/getApiRoutesHono.d.ts.map +1 -0
- package/dist/api/getApiRoutesHono.js +14 -0
- package/dist/build/modifySassImports.sxyt.js +1 -1
- package/dist/components/RouteRedirectComponent.d.ts +12 -0
- package/dist/components/RouteRedirectComponent.d.ts.map +1 -0
- package/dist/components/RouteRedirectComponent.js +15 -0
- package/dist/components/WebRedirectComponent.d.ts +11 -0
- package/dist/components/WebRedirectComponent.d.ts.map +1 -0
- package/dist/components/{RedirectComponent.js → WebRedirectComponent.js} +2 -2
- package/dist/defaultConfig.d.ts +2 -0
- package/dist/defaultConfig.d.ts.map +1 -1
- package/dist/defaultConfig.js +3 -1
- package/dist/env/Interfaces.d.ts +2 -4
- package/dist/env/Interfaces.d.ts.map +1 -1
- package/dist/frameworkConfigSchema.d.ts +7 -7
- package/dist/indexInner.d.ts +5 -2
- package/dist/indexInner.d.ts.map +1 -1
- package/dist/indexInner.js +4 -1
- package/dist/makeFinalConfig.d.ts.map +1 -1
- package/dist/makeFinalConfig.js +1 -1
- package/dist/routing/RedirectCode.d.ts +2 -0
- package/dist/routing/RedirectCode.d.ts.map +1 -0
- package/dist/routing/RedirectCode.js +1 -0
- package/dist/routing/RouteDataFunction.type.d.ts +2 -1
- package/dist/routing/RouteDataFunction.type.d.ts.map +1 -1
- package/dist/routing/RouteDataReturnType.d.ts +2 -1
- package/dist/routing/RouteDataReturnType.d.ts.map +1 -1
- package/dist/routing/Routes.d.ts +5 -0
- package/dist/routing/Routes.d.ts.map +1 -1
- package/dist/routing/RoutingRedirect.d.ts +1 -1
- package/dist/routing/RoutingRedirect.d.ts.map +1 -1
- package/dist/routing/WebRedirect.d.ts +8 -0
- package/dist/routing/WebRedirect.d.ts.map +1 -0
- package/dist/routing/WebRedirect.js +11 -0
- package/dist/routing/registerGlobalData.d.ts +3 -1
- package/dist/routing/registerGlobalData.d.ts.map +1 -1
- package/dist/routing/registerGlobalData.js +4 -2
- package/package.json +35 -31
- package/types/helpers.d.ts +2 -0
- package/dist/components/RedirectComponent.d.ts +0 -12
- package/dist/components/RedirectComponent.d.ts.map +0 -1
|
@@ -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;AAuBpC,qBAAa,kBAAkB;IAC3B,SAAS,CAAC,eAAe,CAAC,CAAC,EAAE,OAAO,EAAY,gBAAgB,EAAE,gBAAgB,GAAG,OAAO;CA6C/F"}
|
|
@@ -0,0 +1,53 @@
|
|
|
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 { RouteRedirectComponent } from "../../components/RouteRedirectComponent.js";
|
|
7
|
+
import { $props, $type } from "../../contentNodeSymbols.js";
|
|
8
|
+
import { WebRedirect } from "../../routing/WebRedirect.js";
|
|
9
|
+
import { throwError } from "../../throwError.js";
|
|
10
|
+
const app = new Hono();
|
|
11
|
+
app.get(async c => {
|
|
12
|
+
const id = c.req.param('id');
|
|
13
|
+
c.res;
|
|
14
|
+
// ...
|
|
15
|
+
});
|
|
16
|
+
function debug(...texts) {
|
|
17
|
+
// console.log(...texts)
|
|
18
|
+
}
|
|
19
|
+
export class TungstenServerHono {
|
|
20
|
+
handleRedirects(c /* any */, matchedRouteInfo) {
|
|
21
|
+
// handle any redirect issued during routing
|
|
22
|
+
if (matchedRouteInfo.data instanceof RoutingRedirect) {
|
|
23
|
+
const redirect = matchedRouteInfo.data;
|
|
24
|
+
c.redirect(redirect.to, redirect.code);
|
|
25
|
+
return true;
|
|
26
|
+
} else if (matchedRouteInfo.data instanceof WebRedirect) {
|
|
27
|
+
const redirect = matchedRouteInfo.data;
|
|
28
|
+
c.redirect(redirect.to, redirect.code);
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
// console.log('content', matchedRouteInfo.content)
|
|
32
|
+
// console.log('is func', typeof matchedRouteInfo.content !== 'function')
|
|
33
|
+
// console.log('ContentNodeIsClassComponent', ContentNodeIsClassComponent(matchedRouteInfo.content as any))
|
|
34
|
+
// console.log('instanceof', (matchedRouteInfo as any).content[$type] instanceof RedirectComponent)
|
|
35
|
+
// console.log('prototype instanceof', (matchedRouteInfo as any).content[$type].prototype instanceof RedirectComponent)
|
|
36
|
+
// console.log('__tungstenRedirect', (matchedRouteInfo as any).content[$type].__tungstenRedirect)
|
|
37
|
+
// console.log('$type', (matchedRouteInfo as any).content[$type])
|
|
38
|
+
//console.log('content[$type]', matchedRouteInfo.content[$type])
|
|
39
|
+
//console.log('instanceof', matchedRouteInfo.content instanceof RedirectComponent)
|
|
40
|
+
if (typeof matchedRouteInfo.content !== 'function' && ContentNodeIsClassComponent(matchedRouteInfo.content)) {
|
|
41
|
+
if (matchedRouteInfo.content[$type] === RouteRedirectComponent || matchedRouteInfo.content[$type].prototype instanceof RouteRedirectComponent) {
|
|
42
|
+
cliTodo('consider type of RedirectComponent props');
|
|
43
|
+
const code = matchedRouteInfo.content[$props].code || 302;
|
|
44
|
+
const to = matchedRouteInfo.content[$props].to;
|
|
45
|
+
c.redirect(to, code);
|
|
46
|
+
return true;
|
|
47
|
+
} else {
|
|
48
|
+
throwError('TungstenServerHono', 'Need to check for WebRedirectComponent here');
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -4,7 +4,7 @@ import { createStores } from "../Store/createStores.js";
|
|
|
4
4
|
export function initStores(location, reqResOrNull, globalData, matchedRouteInfo, serverDataLoading = null) {
|
|
5
5
|
const storeSubscriptions = new Map();
|
|
6
6
|
const internalStoreSubscribedElements = new Map();
|
|
7
|
-
const internalStore = makeStore(new InternalStoreSchema(location), internalStoreSubscribedElements, serverDataLoading);
|
|
7
|
+
const internalStore = makeStore(new InternalStoreSchema(location, matchedRouteInfo), internalStoreSubscribedElements, serverDataLoading);
|
|
8
8
|
storeSubscriptions.set(internalStore, internalStoreSubscribedElements);
|
|
9
9
|
const stores = createStores(reqResOrNull, matchedRouteInfo, globalData, storeSubscriptions, serverDataLoading);
|
|
10
10
|
return {
|
|
@@ -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;
|
|
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('
|
|
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
|
+
});
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import type { MatchedRouteInfo } from '../Servers/MatchedRouteInfo.js';
|
|
1
2
|
export declare class InternalStoreSchema {
|
|
2
3
|
location: string;
|
|
3
|
-
|
|
4
|
+
matchedRouteInfo: MatchedRouteInfo;
|
|
5
|
+
constructor(location: string, matchedRouteInfo: MatchedRouteInfo);
|
|
4
6
|
}
|
|
5
7
|
//# sourceMappingURL=InternalStoreSchema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InternalStoreSchema.d.ts","sourceRoot":"","sources":["../../src/Store/InternalStoreSchema.ts"],"names":[],"mappings":"AACA,qBAAa,mBAAmB;IAC5B,QAAQ,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"InternalStoreSchema.d.ts","sourceRoot":"","sources":["../../src/Store/InternalStoreSchema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AAEtE,qBAAa,mBAAmB;IAC5B,QAAQ,EAAE,MAAM,CAAA;IAChB,gBAAgB,EAAE,gBAAgB,CAAA;gBACtB,QAAQ,EAAE,MAAM,EAAE,gBAAgB,EAAE,gBAAgB;CAInE"}
|
|
@@ -2,8 +2,10 @@ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object
|
|
|
2
2
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
3
3
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
4
4
|
export class InternalStoreSchema {
|
|
5
|
-
constructor(location) {
|
|
5
|
+
constructor(location, matchedRouteInfo) {
|
|
6
6
|
_defineProperty(this, "location", void 0);
|
|
7
|
+
_defineProperty(this, "matchedRouteInfo", void 0);
|
|
7
8
|
this.location = location;
|
|
9
|
+
this.matchedRouteInfo = matchedRouteInfo;
|
|
8
10
|
}
|
|
9
11
|
}
|
|
@@ -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 @@
|
|
|
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 @@
|
|
|
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 = [
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TungstenSimpleComponent } from '../Components.jsx';
|
|
2
|
+
import type { RedirectCode } from '../routing/RedirectCode.js';
|
|
3
|
+
import { MinimumRoutes } from '../routing/Routes.js';
|
|
4
|
+
export type RouteRedirectComponentProps<Routes extends MinimumRoutes> = {
|
|
5
|
+
to: keyof Routes;
|
|
6
|
+
code?: RedirectCode;
|
|
7
|
+
};
|
|
8
|
+
export declare class RouteRedirectComponent<Routes extends MinimumRoutes> extends TungstenSimpleComponent<RouteRedirectComponentProps<Routes>> {
|
|
9
|
+
static __tungstenRedirect: boolean;
|
|
10
|
+
content: () => "This should redirect - if you see this, redirection didn't work" | null;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=RouteRedirectComponent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RouteRedirectComponent.d.ts","sourceRoot":"","sources":["../../src/components/RouteRedirectComponent.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAEpD,MAAM,MAAM,2BAA2B,CAAC,MAAM,SAAS,aAAa,IAAI;IACpE,EAAE,EAAE,MAAM,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,YAAY,CAAA;CACtB,CAAA;AACD,qBAAa,sBAAsB,CAAC,MAAM,SAAS,aAAa,CAC5D,SAAQ,uBAAuB,CAAC,2BAA2B,CAAC,MAAM,CAAC,CAAC;IAEpE,MAAM,CAAC,kBAAkB,UAAO;IAIhC,OAAO,iFAEG;CACb"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
2
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
3
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
4
|
+
import { isDev } from 'tungsten/isDev.js';
|
|
5
|
+
import { TungstenSimpleComponent } from "../Components.js";
|
|
6
|
+
export class RouteRedirectComponent extends TungstenSimpleComponent {
|
|
7
|
+
constructor(...args) {
|
|
8
|
+
super(...args);
|
|
9
|
+
//__tungstenComponentType = 'redirect' as const
|
|
10
|
+
//to = this.props.to
|
|
11
|
+
//code = this.props.code
|
|
12
|
+
_defineProperty(this, "content", () => isDev ? 'This should redirect - if you see this, redirection didn\'t work' : null);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
_defineProperty(RouteRedirectComponent, "__tungstenRedirect", true);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TungstenSimpleComponent } from '../Components.jsx';
|
|
2
|
+
import type { RedirectCode } from '../routing/RedirectCode.js';
|
|
3
|
+
export type WebRedirectComponentProps = {
|
|
4
|
+
to: string;
|
|
5
|
+
code?: RedirectCode;
|
|
6
|
+
};
|
|
7
|
+
export declare class WebRedirectComponent extends TungstenSimpleComponent<WebRedirectComponent> {
|
|
8
|
+
static __tungstenRedirect: boolean;
|
|
9
|
+
content: () => "This should redirect - if you see this, redirection didn't work" | null;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=WebRedirectComponent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebRedirectComponent.d.ts","sourceRoot":"","sources":["../../src/components/WebRedirectComponent.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAE9D,MAAM,MAAM,yBAAyB,GAAG;IACpC,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,CAAC,EAAE,YAAY,CAAA;CACtB,CAAA;AACD,qBAAa,oBAAqB,SAAQ,uBAAuB,CAAC,oBAAoB,CAAC;IACnF,MAAM,CAAC,kBAAkB,UAAO;IAIhC,OAAO,iFAEG;CACb"}
|