tungsten 0.4.12 → 0.4.13

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 (245) hide show
  1. package/dist/.build-complete +1 -1
  2. package/dist/.tsbuildinfo +1 -0
  3. package/dist/AnyComponent.d.ts.map +1 -1
  4. package/dist/Components.d.ts.map +1 -1
  5. package/dist/Components.js +11 -8
  6. package/dist/DomPointer.js +1 -1
  7. package/dist/DomRegion.js +2 -2
  8. package/dist/Framework.js +1 -1
  9. package/dist/FrameworkConfig.d.ts.map +1 -1
  10. package/dist/Instance/Instance.js +1 -1
  11. package/dist/RenderedContentNode.d.ts.map +1 -1
  12. package/dist/RenderedContentNode.js +2 -1
  13. package/dist/Sass.d.ts.map +1 -1
  14. package/dist/Sass.js +1 -0
  15. package/dist/Servers/DevServer.d.ts.map +1 -1
  16. package/dist/Servers/DevServer.js +4 -3
  17. package/dist/Servers/ProdServer.js +1 -1
  18. package/dist/Servers/StaticSiteServer.js +1 -1
  19. package/dist/Servers/loadEnvsDev.d.ts +1 -1
  20. package/dist/Servers/loadEnvsDev.d.ts.map +1 -1
  21. package/dist/Servers/loadEnvsDev.js +4 -2
  22. package/dist/Servers/routing.d.ts.map +1 -1
  23. package/dist/Servers/routing.js +1 -1
  24. package/dist/Store/Store.js +1 -1
  25. package/dist/Store/TypeSafeStore.js +1 -1
  26. package/dist/Store/makeStore.js +1 -1
  27. package/dist/Store/registerStore.js +1 -1
  28. package/dist/TElement.js +1 -1
  29. package/dist/TungstenApp.js +6 -2
  30. package/dist/api/getExport.d.ts.map +1 -1
  31. package/dist/api/getExport.js +1 -0
  32. package/dist/babelPlugins/BabelTransformBindDirect.js +2 -0
  33. package/dist/babelPlugins/BabelTransformBindVar.d.ts.map +1 -1
  34. package/dist/babelPlugins/BabelTransformComponentState.d.ts.map +1 -1
  35. package/dist/babelPlugins/BabelTransformComponentStyles.d.ts.map +1 -1
  36. package/dist/babelPlugins/BabelTransformComponentStyles.js +5 -4
  37. package/dist/babelPlugins/BabelTransformCssImports.d.ts.map +1 -1
  38. package/dist/babelPlugins/BabelTransformCssImports.js +2 -2
  39. package/dist/babelPlugins/BabelTransformDependencyImportsOld.js +1 -1
  40. package/dist/babelPlugins/BabelTransformDeproxyState.d.ts.map +1 -1
  41. package/dist/babelPlugins/BabelTransformPackageImports.d.ts.map +1 -1
  42. package/dist/babelPlugins/BabelTransformPackageImports.js +10 -5
  43. package/dist/babelPlugins/BabelTransformRemoveBlocks.d.ts.map +1 -1
  44. package/dist/babelPlugins/transformPackageImports/BabelTransformDependencyImportsCjs.d.ts.map +1 -1
  45. package/dist/babelPlugins/transformPackageImports/BabelTransformDependencyImportsCjs.js +2 -1
  46. package/dist/babelPlugins/transformPackageImports/BabelTransformDependencyImportsEsm.d.ts.map +1 -1
  47. package/dist/babelPlugins/transformPackageImports/BabelTransformDependencyImportsEsm.js +2 -1
  48. package/dist/bin/args.js +1 -1
  49. package/dist/bin/commands/build.js +1 -1
  50. package/dist/bin/commands/compileSimplePackage.js +1 -0
  51. package/dist/bin/index.d.ts.map +1 -1
  52. package/dist/bin/index.js +11 -3
  53. package/dist/bin/vendorHook.d.ts +3 -0
  54. package/dist/bin/vendorHook.d.ts.map +1 -0
  55. package/dist/bin/vendorHook.js +34 -0
  56. package/dist/browserStorage.js +4 -2
  57. package/dist/build/babel.user.common.config.d.ts +2 -0
  58. package/dist/build/babel.user.common.config.d.ts.map +1 -1
  59. package/dist/build/babel.user.common.config.js +10 -4
  60. package/dist/build/compileJavascript.d.ts.map +1 -1
  61. package/dist/build/compileJavascript.js +40 -27
  62. package/dist/build/compileStyles.js +4 -4
  63. package/dist/build/copyAssets.js +3 -3
  64. package/dist/build/copyPublicFiles.js +3 -3
  65. package/dist/build/frameworkStylesheets.js +1 -1
  66. package/dist/build/getAllSxyClientModules.d.ts.map +1 -1
  67. package/dist/build/getAllSxyClientModules.js +4 -28
  68. package/dist/build/getSxyClientPackageAliases.d.ts.map +1 -1
  69. package/dist/build/makeBabelUserDevConfig.d.ts.map +1 -1
  70. package/dist/build/makeBabelUserProdConfig.d.ts.map +1 -1
  71. package/dist/build/rollupExtractComponentStylesheets.js +1 -1
  72. package/dist/build/sassImportParser.js +2 -2
  73. package/dist/build/tallyBabel.d.ts +3 -0
  74. package/dist/build/tallyBabel.d.ts.map +1 -0
  75. package/dist/build/tallyBabel.js +11 -0
  76. package/dist/clone.js +4 -4
  77. package/dist/compat/context.d.ts.map +1 -1
  78. package/dist/compat/types.d.ts.map +1 -1
  79. package/dist/componentProxyHandlers.d.ts.map +1 -1
  80. package/dist/componentProxyHandlers.js +5 -9
  81. package/dist/components/Stylesheet.d.ts +1 -2
  82. package/dist/components/Stylesheet.d.ts.map +1 -1
  83. package/dist/components/Stylesheet.js +1 -1
  84. package/dist/components/bindable/BindableCheckbox.d.ts.map +1 -1
  85. package/dist/components/bindable/BindableInput.d.ts.map +1 -1
  86. package/dist/components/bindable/BindableInputTypedLegacy.d.ts.map +1 -1
  87. package/dist/components/bindable/BindableRadio.d.ts.map +1 -1
  88. package/dist/components/bindable/BindableTextarea.d.ts.map +1 -1
  89. package/dist/components/library/RichTextEditor/RichTextEditor.js +2 -2
  90. package/dist/components/library/RichTextEditor/contentTree.js +1 -1
  91. package/dist/concat.d.ts.map +1 -1
  92. package/dist/concat.js +2 -2
  93. package/dist/copy.d.ts.map +1 -1
  94. package/dist/createRoutes.d.ts +1 -1
  95. package/dist/createRoutes.d.ts.map +1 -1
  96. package/dist/env/Env.js +2 -2
  97. package/dist/env/getEnvSchemas.d.ts +2 -2
  98. package/dist/env/getEnvSchemas.d.ts.map +1 -1
  99. package/dist/env/getEnvSchemas.js +7 -5
  100. package/dist/env/windowGlobalEnvStatement.d.ts.map +1 -1
  101. package/dist/findProjectDir.d.ts.map +1 -1
  102. package/dist/findProjectDir.js +18 -4
  103. package/dist/findUserConfig.js +2 -2
  104. package/dist/foreach.js +1 -0
  105. package/dist/frameworkConfigSchema.js +2 -2
  106. package/dist/getComponent.d.ts.map +1 -1
  107. package/dist/getComponentDev.d.ts.map +1 -1
  108. package/dist/getRoutes.d.ts.map +1 -1
  109. package/dist/getRoutes.js +13 -22
  110. package/dist/getRoutesDevs.d.ts.map +1 -1
  111. package/dist/getStackTrace.js +1 -1
  112. package/dist/glob.d.ts +5 -0
  113. package/dist/glob.d.ts.map +1 -0
  114. package/dist/glob.js +103 -0
  115. package/dist/helpers/getFetchCompatibleHeaders.js +2 -2
  116. package/dist/hmr/applyHmrModule.js +5 -5
  117. package/dist/hmr/componentIdentity.js +1 -1
  118. package/dist/hmr/instanceRegistry.js +2 -2
  119. package/dist/hooks/useReducer.d.ts.map +1 -1
  120. package/dist/hooks/useState.d.ts.map +1 -1
  121. package/dist/hooks/useState.js +2 -8
  122. package/dist/hydrate/hydrate.d.ts +1 -1
  123. package/dist/hydrate/hydrate.d.ts.map +1 -1
  124. package/dist/hydrate/hydrate.js +26 -24
  125. package/dist/hydrate/reconcileHydratedAttributes.js +2 -2
  126. package/dist/makeFinalConfig.d.ts.map +1 -1
  127. package/dist/makeFinalConfig.js +2 -2
  128. package/dist/markOptionSelected.js +1 -1
  129. package/dist/mergeConfigs.d.ts.map +1 -1
  130. package/dist/mergeConfigs.js +11 -2
  131. package/dist/mutatingFunctions.js +3 -3
  132. package/dist/postcssPlugins/TransformCssNames.js +2 -2
  133. package/dist/rawHtml/parseHtml.js +1 -1
  134. package/dist/render/componentNodeToRenderingTree.d.ts.map +1 -1
  135. package/dist/render/componentNodeToRenderingTree.js +6 -17
  136. package/dist/render/contentToHtml.d.ts.map +1 -1
  137. package/dist/render/contentToHtml.js +1 -1
  138. package/dist/render/getFunctionBodyAsString.d.ts.map +1 -1
  139. package/dist/render/getFunctionBodyAsString.js +2 -5
  140. package/dist/render/processProps.js +2 -2
  141. package/dist/render/renderingTreeToHtml.d.ts.map +1 -1
  142. package/dist/render/rootToHtml.d.ts.map +1 -1
  143. package/dist/routing/Route.js +1 -1
  144. package/dist/routing/RouteDataFunction.type.d.ts.map +1 -1
  145. package/dist/routing/RoutesWithSafeParams.js +1 -1
  146. package/dist/routing/WebRedirect.d.ts.map +1 -1
  147. package/dist/routing/compareRequestToRegex.js +2 -2
  148. package/dist/routing/getPathPriority.js +1 -1
  149. package/dist/serverRpc.d.ts.map +1 -1
  150. package/dist/slash.d.ts +2 -0
  151. package/dist/slash.d.ts.map +1 -0
  152. package/dist/slash.js +5 -0
  153. package/dist/spawnShellCommand.js +1 -1
  154. package/dist/staticGen/staticGen.d.ts.map +1 -1
  155. package/dist/staticGen/staticGen.js +9 -7
  156. package/dist/staticGen/staticGenFunctions.js +1 -1
  157. package/dist/style/jssToCss.d.ts.map +1 -1
  158. package/dist/style/jssToCss.js +11 -9
  159. package/dist/style/unusedStyles.d.ts.map +1 -1
  160. package/dist/testing/host.js +11 -11
  161. package/dist/testing/hydrateTestApp.d.ts.map +1 -1
  162. package/dist/testing/hydrateTestApp.js +9 -9
  163. package/dist/testing/index.d.ts.map +1 -1
  164. package/dist/testing/installTestStyleProcessors.js +1 -1
  165. package/dist/testing/loadEnv.d.ts +4 -1
  166. package/dist/testing/loadEnv.d.ts.map +1 -1
  167. package/dist/testing/loadEnv.js +2 -2
  168. package/dist/testing/temp/componentPackageMock.js +3 -3
  169. package/dist/timeProfiler.d.ts +4 -0
  170. package/dist/timeProfiler.d.ts.map +1 -1
  171. package/dist/timeProfiler.js +16 -0
  172. package/dist/todo.js +2 -1
  173. package/dist/update/integrateUpdateVdom.d.ts.map +1 -1
  174. package/dist/update/integrateUpdateVdom.js +17 -14
  175. package/dist/update/integrateUpdateVdomPrebuild.js +5 -5
  176. package/dist/watch.js +2 -2
  177. package/package.json +10 -29
  178. package/types/modules.d.ts +0 -1
  179. package/vendor/babel-core.js +26 -0
  180. package/vendor/babel-parser.js +9 -0
  181. package/vendor/babel-plugin-syntax-import-assertions.js +50 -0
  182. package/vendor/babel-preset-react.js +872 -0
  183. package/vendor/babel-preset-typescript.js +26 -0
  184. package/vendor/babel-types.js +9 -0
  185. package/vendor/chalk-extensions.js +1994 -0
  186. package/vendor/chalk.js +647 -0
  187. package/vendor/chokidar.js +6889 -0
  188. package/vendor/chunk-1TN2rK3j.js +1218 -0
  189. package/vendor/chunk-1UuLTU0U.js +34 -0
  190. package/vendor/chunk-B_NeooyV.js +86 -0
  191. package/vendor/chunk-C12hSZn7.js +88 -0
  192. package/vendor/chunk-C3YkUGz5.js +19 -0
  193. package/vendor/chunk-C3fcZDjl.js +41964 -0
  194. package/vendor/chunk-C9FSKeSx.js +14603 -0
  195. package/vendor/chunk-CPArXGxa.js +14623 -0
  196. package/vendor/cjs-module-lexer.js +6 -0
  197. package/vendor/dotenv.js +412 -0
  198. package/vendor/express.js +40577 -0
  199. package/vendor/import-meta-resolve.js +2201 -0
  200. package/vendor/manifest.json +29 -0
  201. package/vendor/postcss.js +8546 -0
  202. package/vendor/serialize-javascript.js +293 -0
  203. package/vendor/sxy-lib-arrays.js +113 -0
  204. package/vendor/sxy-lib-object-copy.js +1781 -0
  205. package/vendor/sxy-lib-objects.js +156 -0
  206. package/vendor/sxy-lib-promises.js +47 -0
  207. package/vendor/sxy-package-investigator.js +202 -0
  208. package/vendor/valibot.js +7664 -0
  209. package/dist/Servers/hono/DevServerHono.d.ts +0 -2
  210. package/dist/Servers/hono/DevServerHono.d.ts.map +0 -1
  211. package/dist/Servers/hono/DevServerHono.js +0 -423
  212. package/dist/Servers/hono/ProdServerHono.d.ts +0 -2
  213. package/dist/Servers/hono/ProdServerHono.d.ts.map +0 -1
  214. package/dist/Servers/hono/ProdServerHono.js +0 -220
  215. package/dist/Servers/hono/TungstenServerHono.d.ts +0 -6
  216. package/dist/Servers/hono/TungstenServerHono.d.ts.map +0 -1
  217. package/dist/Servers/hono/TungstenServerHono.js +0 -36
  218. package/dist/api/ApiEndpointHono.d.ts +0 -3
  219. package/dist/api/ApiEndpointHono.d.ts.map +0 -1
  220. package/dist/api/ApiEndpointHono.js +0 -1
  221. package/dist/api/ApiRouteHono.d.ts +0 -7
  222. package/dist/api/ApiRouteHono.d.ts.map +0 -1
  223. package/dist/api/ApiRouteHono.js +0 -1
  224. package/dist/api/ApiRoutesHono.d.ts +0 -5
  225. package/dist/api/ApiRoutesHono.d.ts.map +0 -1
  226. package/dist/api/ApiRoutesHono.js +0 -1
  227. package/dist/api/getApiRoutesHono.d.ts +0 -6
  228. package/dist/api/getApiRoutesHono.d.ts.map +0 -1
  229. package/dist/api/getApiRoutesHono.js +0 -14
  230. package/dist/build/compilePackages.d.ts +0 -2
  231. package/dist/build/compilePackages.d.ts.map +0 -1
  232. package/dist/build/compilePackages.js +0 -89
  233. package/dist/build/findRequiredUserModule.d.ts +0 -2
  234. package/dist/build/findRequiredUserModule.d.ts.map +0 -1
  235. package/dist/build/findRequiredUserModule.js +0 -36
  236. package/dist/build/processPackage.d.ts +0 -4
  237. package/dist/build/processPackage.d.ts.map +0 -1
  238. package/dist/build/processPackage.js +0 -91
  239. package/dist/build/tallyBabelPlugins.d.ts +0 -3
  240. package/dist/build/tallyBabelPlugins.d.ts.map +0 -1
  241. package/dist/build/tallyBabelPlugins.js +0 -63
  242. package/dist/testing/loadEnvSetup.d.ts +0 -2
  243. package/dist/testing/loadEnvSetup.d.ts.map +0 -1
  244. package/dist/testing/loadEnvSetup.js +0 -7
  245. package/sxy-loader.config.js +0 -7
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=DevServerHono.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DevServerHono.d.ts","sourceRoot":"","sources":["../../../src/Servers/hono/DevServerHono.ts"],"names":[],"mappings":""}
@@ -1,423 +0,0 @@
1
- // Status/known gaps: see ./README.md
2
- // import { Context, Hono } from 'hono'
3
- // import type { BlankEnv, BlankSchema, Handler, Next } from 'hono/types'
4
- // import { serve, type ServerType } from '@hono/node-server'
5
- // import { serveStatic } from '@hono/node-server/serve-static'
6
- // import { join } from 'path'
7
- // import { allObj as promiseAllObj } from 'sxy-lib/promises.js'
8
- // import type { FrameworkConfigComplete, ServerMiddlewareInfo } from '../../FrameworkConfig.js'
9
- // import type { CompilationInfo } from '../../build/CompilationInfo.js'
10
- // import type { ApiRoutes } from '../../api/ApiRoutes.js'
11
- // import {
12
- // staticFolder, assetsFolder, publicFolder, packagesFolder, clientFolder, componentCssFolder
13
- // } from '../../settings.js'
14
- // import { rootToHtmlDev as renderRootToHtmlDev } from '../../render/rootToHtmlDev.js'
15
- // import { contentToHtmlDev as renderContentToHtmlDev } from '../../render/contentToHtmlDev.js'
16
- // import { Instance } from '../../Instance/Instance.js'
17
- // import { Framework } from '../../Framework.js'
18
- // import { TungstenError } from '../../TungstenError.js'
19
- // import { makeInstanceConfigFromFrameworkConfig } from '../../makeInstanceConfigFromFrameworkConfig.js'
20
- // import { cliNews, cliOut, cliWarn, cliLog, cliDebug, cliTodo, cliAlert } from '../../cliOutput.js' // eslint-disable-line @typescript-eslint/no-unused-vars
21
- // import { existsSync } from 'fs'
22
- // import { getApiRoutes } from '../../api/getApiRoutes.js'
23
- // import { getApiRoutesHono } from '../../api/getApiRoutesHono.js'
24
- // import { standardizeWebPath } from '../../standardizeWebPath.js'
25
- // import { log } from '../../appOutput.js'
26
- // import { throwError } from '../../throwError.js'
27
- // import { getRoutesDev } from '../../getRoutesDevs.js'
28
- // import { getComponentDev } from '../../getComponentDev.js'
29
- // import { ReqRes } from '../../ReqRes.js'
30
- // import sxyLoaderConfig from '../../../sxy-loader.config.js'
31
- // import { createLoad } from 'sxy-loader'
32
- // import { routing } from '../routing.jsx'
33
- // import { GlobalData, globalDataFunc } from '../../routing/registerGlobalData.js'
34
- // import { ServerDataLoading } from '../../Store/ServerDataLoading.js'
35
- // import { TungstenServer } from '../TungstenServer.jsx'
36
- // import { Routes } from '../../routing/Routes.js'
37
- // import { portError } from '../portError.js'
38
- // import { loadEnvsDev } from '../loadEnvsDev.js'
39
- // import { initStores } from '../initStores.js'
40
- // import { AppRoutes } from '../../routing/AppRoutes.js'
41
- // import { AnyComponentType } from '../../AnyComponentType.js'
42
- // import { MatchedRouteInfo } from '../MatchedRouteInfo.js'
43
- // import { MatchedRoute } from '../../routing/MatchedRoute.js'
44
- // import { ContentNodeIsClassComponent } from '../../ContentNode.js'
45
- // import { $props, $type } from '../../contentNodeSymbols.js'
46
- // import { Path } from '../../routing/RouteTypes.js'
47
- // import type { ApiRoutesHono } from '../../api/ApiRoutesHono.js'
48
- // import { TungstenServerHono } from './TungstenServerHono.jsx'
49
- export {};
50
- // //import cookieParser from 'cookie-parser'
51
- // function debug(...texts: any[]) { // eslint-disable-line @typescript-eslint/no-unused-vars
52
- // // console.log(...texts)
53
- // }
54
- // export class DevServerHono extends TungstenServerHono {
55
- // framework: Framework
56
- // config: FrameworkConfigComplete
57
- // compilationInfo: CompilationInfo
58
- // port: number
59
- // location: string | null = null
60
- // initialProcessEnv: Record<string, string>
61
- // app: Hono<BlankEnv, BlankSchema, '/'>
62
- // apiRoutes?: ApiRoutesHono
63
- // apiPath?: string
64
- // server?: ServerType
65
- // reqId: number
66
- // firstRender: boolean = true
67
- // iterationCount: number = 0
68
- // constructor(
69
- // framework: Framework, config: FrameworkConfigComplete, compilationInfo: CompilationInfo,
70
- // initialProcessEnv: Record<string, string> = {}/* FIX ME */
71
- // ) {
72
- // super()
73
- // try {
74
- // this.framework = framework
75
- // this.config = config
76
- // this.compilationInfo = compilationInfo
77
- // // if (tungstenPrivateEnv.TUNGSTEN_SERVER_PORT === -999) {
78
- // // throwError(
79
- // // 'DevServer',
80
- // // 'TUNGSTEN_SERVER_PORT environment variable has not been set,'
81
- // // + '\n Ensure that you have an env schema with this field, and a matching env file'
82
- // // )
83
- // // }
84
- // const proto = tungstenPublicEnv.FRONTEND_PROTO ?? 'http'
85
- // const host = tungstenPublicEnv.FRONTEND_HOST ?? 'localhost'
86
- // const port = tungstenPrivateEnv.TUNGSTEN_SERVER_PORT ?? 3000
87
- // if (isNaN(port) || port === 0) throwError('DevServer', portError(port))
88
- // this.port = port
89
- // //this.port = _port
90
- // this.location = `${proto}://${host}:${port}`
91
- // this.initialProcessEnv = initialProcessEnv
92
- // this.app = new Hono()
93
- // this.reqId = 0
94
- // //this.app.use(cookieParser)
95
- // let reqId = 0
96
- // this.app.use(async (c, next) => {
97
- // reqId++
98
- // await next()
99
- // })
100
- // //if (tungstenPrivateEnv.DEBUG === true) {
101
- // this.app.use(async (c, next) => {
102
- // const { req } = c
103
- // const urlObj = new URL(c.req.url)
104
- // //const targetOrigin = urlObj.protocol + '://' + String(req.header('host'))
105
- // const targetOrigin = urlObj.origin
106
- // const target = targetOrigin + req.url
107
- // const origin = req.header('origin')
108
- // // request log
109
- // let message = 'Received request at ' + target
110
- // if (origin !== undefined) {
111
- // message += ' from ' + String(req.header('origin'))
112
- // // should we use referrer as a backup option?
113
- // // not sure what that is
114
- // }
115
- // cliOut(message)
116
- // if ((this.config.suppressOriginMismatchWarning !== true)) {
117
- // // origin-target mismatch warning
118
- // if (origin !== undefined && origin === this.location && origin !== targetOrigin) {
119
- // cliWarn(
120
- // `Received a request from the frontend, but it's origin`
121
- // + ` is not the same as the request origin.`
122
- // + ` This may indicate a misconfiguration, and may prevent`
123
- // + ` the passing of cookies to the tungsten server.`
124
- // )
125
- // cliWarn(`source: ${targetOrigin}`)
126
- // cliWarn(`target: ${target}`)
127
- // }
128
- // }
129
- // next()
130
- // })
131
- // // this.app.use((req, res, next) => {
132
- // // cliDebug(`Received request [${res.locals.reqId}] for ${req.url}`)
133
- // // next()
134
- // // })
135
- // //}
136
- // if (config.serverMiddleware) { this.addServerMiddleware(config.serverMiddleware) }
137
- // /// CHECK: Do we need to do this with hono?
138
- // // can we set the mime type for .cjs files?
139
- // //express.static.mime.define({'application/javascript': ['cjs']})
140
- // this.app.use(
141
- // `/.tungsten.config.js`,
142
- // //express.static(join(this.compilationInfo.location, '.tungsten.config.js'))
143
- // serveStatic({ root: join(this.compilationInfo.location, '.tungsten.config.js') })
144
- // ) // config file
145
- // this.app.use(
146
- // `/${packagesFolder}/`,
147
- // //express.static(join(this.compilationInfo.location, packagesFolder))
148
- // serveStatic({ root: join(this.compilationInfo.location, packagesFolder) })
149
- // ) // compiled packages
150
- // this.app.use(
151
- // `/${clientFolder}/`,
152
- // //express.static(join(this.compilationInfo.location, clientFolder))
153
- // serveStatic({ root: join(this.compilationInfo.location, clientFolder) })
154
- // ) // ?
155
- // this.app.use(
156
- // `/${componentCssFolder}/`,
157
- // //express.static(join(this.compilationInfo.location, componentCssFolder))
158
- // serveStatic({ root: join(this.compilationInfo.location, componentCssFolder) })
159
- // ) // app component css?/s
160
- // this.app.use(
161
- // //express.static(join(this.compilationInfo.location, staticFolder))
162
- // serveStatic({ root: join(this.compilationInfo.location, staticFolder) })
163
- // ) // compiled stylesheets? -- etag: false to disable caching (from express days...)
164
- // const publicLocation = join(this.compilationInfo.location, publicFolder)
165
- // if (existsSync(publicLocation)) {
166
- // //this.app.use(express.static(publicLocation)) // files from public folder
167
- // this.app.use(serveStatic({ root: publicLocation })) // files from public folder
168
- // }
169
- // //cliWarn(`assets dir:`, this.config.assetsDir)
170
- // if (this.config.assetsDir !== undefined) {
171
- // this.app.use(
172
- // `/${this.config.assetsDir}`,
173
- // //express.static(join(this.compilationInfo.location, assetsFolder))
174
- // serveStatic({ root: join(this.compilationInfo.location, assetsFolder) })
175
- // ) // files from assets folder
176
- // }
177
- // this.app.use(
178
- // //express.static(this.compilationInfo.location, { dotfiles:'allow' })
179
- // serveStatic({ root: this.compilationInfo.location })
180
- // ) // serving the app files themselves
181
- // //this.app.use('/__server_rpc__', this.handleRpc)
182
- // // seems there was a plan to have API routes built into the main app
183
- // // can't remember this much
184
- // if (typeof config.apiRoutes === 'string' && config.apiRoutes !== '') {
185
- // const apiPath = this.apiPath = standardizeWebPath(this.config.apiPath)
186
- // cliOut(`API listening at ${this.apiPath}`)
187
- // // should not be needed with hono
188
- // // this.app.use(apiPath, express.json())
189
- // //throwError('DevServerHono', 'Support for app apiRoutes not yet implemented')
190
- // this.app.use(apiPath, this.handleRequestApi)
191
- // }
192
- // this.app.use(this.handleRequest)
193
- // // !!! obsolete?
194
- // // start hooking into require to rewrite react requires to tungsten
195
- // //addRequireResolveHooks() // we need this for server side
196
- // // we will need a server side import loader too
197
- // } catch (e) {
198
- // throw new TungstenError(`${this.constructor.name} construction error: ${e}`)
199
- // }
200
- // }
201
- // private addServerMiddleware = (serverMiddleware: ServerMiddlewareInfo): void => {
202
- // //console.log('addServerMiddleware')
203
- // const [middlewareFile, middlewareExportName, middlewarePath] = serverMiddleware
204
- // const path = middlewarePath.startsWith('/') ? middlewarePath : '/' + middlewarePath
205
- // this.app.use(path, async (c) => {
206
- // // this is going to reload the server application on each request
207
- // // will cause trouble if anything depends on memory
208
- // // but should be OK for an ordinary DB based system, including DB based sessions
209
- // // [*] We could look into replacing this with a watcher + reload based system
210
- // // we'd have to set up a watcher which triggers a reload of middleware to
211
- // // a variable that can be accessed here. Probably in a promise format so
212
- // // that a loading middleware can be awaited instead of running the outdated
213
- // // code
214
- // // [*] const middlewares = await middlewaresPromise
215
- // const load = await createLoad(import.meta.url, sxyLoaderConfig)
216
- // const fullFilePath = 'file://' + join(this.compilationInfo.codeLocation, middlewareFile)
217
- // const middlewareModule = await load(fullFilePath)
218
- // if ( ! (middlewareExportName in middlewareModule) ) {
219
- // throwError(
220
- // 'DevServer',
221
- // `export ${middlewareExportName} not found in ${middlewareFile}`
222
- // + ` when trying to load server middleware`
223
- // )
224
- // }
225
- // const middlewares = middlewareModule[middlewareExportName] as Handler[] // eslint-disable-line no-type-assertion/no-type-assertion
226
- // // TODO should we add a manual type check here?
227
- // if (!Array.isArray(middlewares)) throwError('addServerMiddleware', `Expected middlewares to be an array`)
228
- // if (!(0 in middlewares)) throwError('addServerMiddleware', `No middleware entry at index 0`)
229
- // const firstMiddleware = middlewares[0]
230
- // if (!(typeof firstMiddleware === 'function')) {
231
- // throwError('addServerMiddleware', `Expected middleware to be a function`)
232
- // }
233
- // // mimicing hono here so we can modify behaviour on each run
234
- // let i = 0
235
- // const next: Next = async () => {
236
- // i++
237
- // const m = middlewares[i]
238
- // if (m !== undefined) {
239
- // m(c, next)
240
- // }
241
- // }
242
- // firstMiddleware(c, next)
243
- // })
244
- // cliOut(`Server Middleware added to server at ${path}`)
245
- // }
246
- // // private handleRpc = async (req: Request, res: Response, next: NextFunction) => {
247
- // // //
248
- // // console.log('Server is handling server rpc')
249
- // // }
250
- // private handleRequestApi = async (c: Context, next: Next): Promise<Response> => {
251
- // const { req } = c
252
- // this.apiRoutes = await getApiRoutesHono(this.config, this.compilationInfo, 'dev')
253
- // //const requestPath = standardizeWebPath(req.baseUrl + req.path)
254
- // const subPath = standardizeWebPath(req.path)
255
- // //console.log('received an API req', req.originalUrl, res.locals.reqId)
256
- // for (const [path, route] of Object.entries(this.apiRoutes)) {
257
- // if (route.method === req.method && standardizeWebPath(path) === subPath) {
258
- // //console.log('API route matched', path)
259
- // return await route.endpoint(c, next)
260
- // }
261
- // }
262
- // // otherwise
263
- // //res.sendStatus(404)
264
- // return c.notFound()
265
- // }
266
- // private handleRequest = async (c: Context, next: Next): Promise<Response> => {
267
- // const { req } = c
268
- // if (/\.(css|scss|sass|js|jsx|png|jpg|jpeg|svg|ico)$/.test(req.path)) {
269
- // // warn(
270
- // // `Dev server received request ${req.url} which was not matched by a static file.`
271
- // // + '\nBlocking request to prevent pointless app render'
272
- // // )
273
- // cliLog(`Requested asset file ${req.url} was not found`)
274
- // return c.notFound()
275
- // //res.status(404).end()
276
- // //return
277
- // }
278
- // try {
279
- // const _firstRender = this.firstRender
280
- // this.firstRender = false
281
- // //console.log('received a frontend req', req.originalUrl, res.locals.reqId)
282
- // //// I think we need to pass req, (res?) to the app
283
- // //// so that it can set response codes
284
- // //// or
285
- // //// the app has to return some data other than response string
286
- // ////
287
- // //// perhaps, set some return data in the instance
288
- // //// then return html string + other data
289
- // const location = req.url
290
- // const instanceConfig = makeInstanceConfigFromFrameworkConfig(this.config, true)
291
- // if (this.framework.frameworkModules === undefined) {
292
- // throwError('DevServer.handleRequest()',
293
- // 'framework.frameworkModules is undefined'
294
- // )
295
- // }
296
- // if (this.framework.clientImportAliases === undefined) {
297
- // throwError('DevServer.handleRequest()',
298
- // 'framework.frameworkModules is undefined'
299
- // )
300
- // }
301
- // globalDataFunc.value = undefined
302
- // const iteration = this.iterationCount++
303
- // await loadEnvsDev(this.config, iteration, this.initialProcessEnv, false)
304
- // // ReqRes is Express-shaped ({req, res}) and Hono's Context isn't - this cast is a
305
- // // type-only bridge so the (Express-only) Instance/initStores/routing plumbing below
306
- // // still compiles. Not behaviorally correct; fine since this dev server isn't wired
307
- // // up anywhere live (see Framework.createDevServer, which only builds DevServer).
308
- // // eslint-disable-next-line no-type-assertion/no-type-assertion -- see comment above
309
- // const reqRes = c as unknown as ReqRes
310
- // // Save some state. I think this is a placeholder for later
311
- // const serverDataLoading: ServerDataLoading = { value: false }
312
- // const routingPromise = getRoutesDev(this.compilationInfo, this.config, iteration).then(
313
- // async (appRoutes) => {
314
- // const routes = (typeof appRoutes === 'function') ? appRoutes(reqRes) : appRoutes
315
- // // load data, and do routing
316
- // return promiseAllObj({
317
- // appRoutes,
318
- // routes,
319
- // globalData: (globalDataFunc.value !== undefined) ? globalDataFunc.value(reqRes) : {},
320
- // matchedRouteInfo: routing(location, routes, serverDataLoading)
321
- // })
322
- // }
323
- // )
324
- // let appRoutes: AppRoutes
325
- // let routes: Routes
326
- // let globalData: GlobalData
327
- // let matchedRouteInfo: MatchedRouteInfo
328
- // let RootComponentClass: AnyComponentType | null = null
329
- // if (this.config.useRootComponent) {
330
- // const rootComponentFileFull = join(this.compilationInfo.location, this.config.rootComponent)
331
- // ;({ routing: { appRoutes, routes, globalData, matchedRouteInfo }, RootComponentClass }
332
- // = await promiseAllObj({
333
- // routing: routingPromise,
334
- // RootComponentClass: getComponentDev(rootComponentFileFull, this.config.rootComponent, iteration)
335
- // }))
336
- // } else {
337
- // ({ appRoutes, routes, globalData, matchedRouteInfo } = await routingPromise)
338
- // //throwError('DevServer', 'useRootComponent = false not implemented yet')
339
- // }
340
- // // get routes (running the getRoutes function if needed)
341
- // //const routes = (typeof appRoutes === 'function') ? appRoutes(reqRes) : appRoutes
342
- // // load data, and do routing
343
- // // const [globalData, matchedRouteInfo] = await Promise.all([
344
- // // (globalDataFunc !== undefined) ? globalDataFunc(reqRes) : {},
345
- // // routing(location, routes, serverDataLoading)
346
- // // ])
347
- // const redirected = this.handleRedirects(c, matchedRouteInfo)
348
- // if (redirected !== false) return redirected // end early
349
- // // make stores
350
- // const { internalStore, stores, storeSubscriptions }
351
- // = initStores(location, reqRes, globalData, matchedRouteInfo, serverDataLoading)
352
- // // create the instance
353
- // const instance = new Instance(
354
- // location, instanceConfig, reqRes, appRoutes, routes, internalStore,
355
- // stores, storeSubscriptions, globalData, matchedRouteInfo
356
- // )
357
- // let html: string
358
- // if (RootComponentClass) {
359
- // html = await renderRootToHtmlDev(
360
- // this.compilationInfo, this.framework.clientImportAliases,
361
- // RootComponentClass, instance, this.config, global.tungstenPublicEnv,
362
- // '' // siteBasePathOverride
363
- // )
364
- // } else {
365
- // html = await renderRootToHtmlDev(
366
- // this.compilationInfo, this.framework.clientImportAliases,
367
- // MatchedRoute, instance, this.config, global.tungstenPublicEnv,
368
- // '' // siteBasePathOverride
369
- // )
370
- // // const { params, data } = matchedRouteInfo
371
- // // let { content } = matchedRouteInfo
372
- // // if (typeof content === 'function') {
373
- // // content = content(data, params, {} /* props */, globalData, location)
374
- // // //throwError('DevServer', 'route content is a function')
375
- // // }
376
- // // //console.log('content to render', content)
377
- // // html = await renderContentToHtmlDev(
378
- // // this.compilationInfo, this.framework.clientImportAliases,
379
- // // content, instance, this.config, global.tungstenPublicEnv,
380
- // // '' // siteBasePathOverride
381
- // // )
382
- // }
383
- // return c.html(html, (instance.matchedRouteInfo.key === '404') ? 404 : 200)
384
- // } catch(e) {
385
- // cliLog('error', e)
386
- // this.errorLog(e)
387
- // return c.html(this.errorPage(e), 500)
388
- // }
389
- // }
390
- // // private async handlePost(req: express.Request, res: express.Response): Promise<void> {
391
- // // throw new TungstenError(`Err - Dev server received a post request. Not supported yet.`)
392
- // // }
393
- // errorLog = (error: unknown) => {
394
- // log((typeof error === 'object' && error !== null && 'stack' in error) ? error.stack : error)
395
- // }
396
- // errorPage = (error: unknown) => {
397
- // return `<!DOCTYPE html>
398
- // </html>
399
- // <head>
400
- // <title>Error</title>
401
- // <style>html { font-family: arial }</style>
402
- // </head>
403
- // <body>
404
- // <h1>Application Error</h1>
405
- // <section>
406
- // <pre>${(typeof error === 'object' && error !== null && 'stack' in error) ? error.stack : error}</pre>
407
- // </section>
408
- // </body>
409
- // </html>`
410
- // }
411
- // start = (): Promise<string> => {
412
- // return new Promise( resolve => {
413
- // this.server = serve({ fetch: this.app.fetch, port: this.port }, () => {
414
- // cliNews(`Dev server ready at ${this.location}`)
415
- // resolve(this.location ?? '')
416
- // })
417
- // })
418
- // }
419
- // stop = () => {
420
- // if (this.server !== undefined) this.server.close()
421
- // }
422
- // //treeToHtml = treeToHtml
423
- // }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=ProdServerHono.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ProdServerHono.d.ts","sourceRoot":"","sources":["../../../src/Servers/hono/ProdServerHono.ts"],"names":[],"mappings":""}