@tremho/mist-lift 2.4.0 → 2.5.2

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 (103) hide show
  1. package/README.md +5 -0
  2. package/build/commands/actions/initQuestions.js +18 -9
  3. package/build/commands/actions/initQuestions.js.map +1 -1
  4. package/build/commands/actions/setupPackageJson.js +20 -11
  5. package/build/commands/actions/setupPackageJson.js.map +1 -1
  6. package/build/commands/actions/updateDeployedPermissions.js +22 -13
  7. package/build/commands/actions/updateDeployedPermissions.js.map +1 -1
  8. package/build/commands/build.js +18 -9
  9. package/build/commands/build.js.map +1 -1
  10. package/build/commands/builtin/ApiDocMaker.js +3 -4
  11. package/build/commands/builtin/ApiDocMaker.js.map +1 -1
  12. package/build/commands/builtin/BuiltInHandler.js +20 -11
  13. package/build/commands/builtin/BuiltInHandler.js.map +1 -1
  14. package/build/commands/builtin/DeployBuiltInZip.js +1 -2
  15. package/build/commands/builtin/DeployBuiltInZip.js.map +1 -1
  16. package/build/commands/builtin/ExportWebroot.js +24 -13
  17. package/build/commands/builtin/ExportWebroot.js.map +1 -1
  18. package/build/commands/builtin/StageWebrootZip.js +18 -9
  19. package/build/commands/builtin/StageWebrootZip.js.map +1 -1
  20. package/build/commands/builtin/webroot-export/s3webroot.js +21 -10
  21. package/build/commands/builtin/webroot-export/s3webroot.js.map +1 -1
  22. package/build/commands/create.js +18 -9
  23. package/build/commands/create.js.map +1 -1
  24. package/build/commands/deploy.js +19 -10
  25. package/build/commands/deploy.js.map +1 -1
  26. package/build/commands/doctor.js +19 -10
  27. package/build/commands/doctor.js.map +1 -1
  28. package/build/commands/help.js +34 -24
  29. package/build/commands/help.js.map +1 -1
  30. package/build/commands/info.js +18 -9
  31. package/build/commands/info.js.map +1 -1
  32. package/build/commands/init.js +67 -18
  33. package/build/commands/init.js.map +1 -1
  34. package/build/commands/package.js +21 -10
  35. package/build/commands/package.js.map +1 -1
  36. package/build/commands/publish.js +19 -10
  37. package/build/commands/publish.js.map +1 -1
  38. package/build/commands/settings.js +18 -9
  39. package/build/commands/settings.js.map +1 -1
  40. package/build/commands/start.js +18 -9
  41. package/build/commands/start.js.map +1 -1
  42. package/build/commands/test.js +18 -9
  43. package/build/commands/test.js.map +1 -1
  44. package/build/commands/update.js +18 -9
  45. package/build/commands/update.js.map +1 -1
  46. package/build/expressRoutes/all.js +18 -9
  47. package/build/expressRoutes/all.js.map +1 -1
  48. package/build/expressRoutes/functionBinder.js +28 -15
  49. package/build/expressRoutes/functionBinder.js.map +1 -1
  50. package/build/integration-tests/quickstart-scenario.test.js +5 -4
  51. package/build/integration-tests/quickstart-scenario.test.js.map +1 -1
  52. package/build/lib/CaseUtils.js +5 -6
  53. package/build/lib/CaseUtils.js.map +1 -1
  54. package/build/lib/DirectoryUtils.js +2 -3
  55. package/build/lib/DirectoryUtils.js.map +1 -1
  56. package/build/lib/ESBuild.js +19 -10
  57. package/build/lib/ESBuild.js.map +1 -1
  58. package/build/lib/IdSrc.js +6 -6
  59. package/build/lib/IdSrc.js.map +1 -1
  60. package/build/lib/LiftConfig.js +7 -7
  61. package/build/lib/LiftConfig.js.map +1 -1
  62. package/build/lib/LiftVersion.js +21 -11
  63. package/build/lib/LiftVersion.js.map +1 -1
  64. package/build/lib/Tests/fileCompare.test.js +17 -7
  65. package/build/lib/Tests/fileCompare.test.js.map +1 -1
  66. package/build/lib/TypeCheck.js +8 -6
  67. package/build/lib/TypeCheck.js.map +1 -1
  68. package/build/lib/askQuestion.js +18 -9
  69. package/build/lib/askQuestion.js.map +1 -1
  70. package/build/lib/executeCommand.js +1 -2
  71. package/build/lib/executeCommand.js.map +1 -1
  72. package/build/lib/fileCompare.js +2 -3
  73. package/build/lib/fileCompare.js.map +1 -1
  74. package/build/lib/openAPI/ApiBuildCollector.js +1 -2
  75. package/build/lib/openAPI/ApiBuildCollector.js.map +1 -1
  76. package/build/lib/openAPI/WebrootFileSupport.js +18 -9
  77. package/build/lib/openAPI/WebrootFileSupport.js.map +1 -1
  78. package/build/lib/openAPI/openApiConstruction.js +46 -32
  79. package/build/lib/openAPI/openApiConstruction.js.map +1 -1
  80. package/build/lib/pathResolve.js +1 -2
  81. package/build/lib/pathResolve.js.map +1 -1
  82. package/build/lib/utils.js +20 -11
  83. package/build/lib/utils.js.map +1 -1
  84. package/build/lift.js +18 -8
  85. package/build/lift.js.map +1 -1
  86. package/package.json +3 -4
  87. package/src/commands/actions/updateDeployedPermissions.ts +1 -1
  88. package/src/commands/builtin/ExportWebroot.ts +5 -5
  89. package/src/commands/builtin/webroot-export/s3webroot.ts +4 -0
  90. package/src/commands/help.ts +4 -2
  91. package/src/commands/init.ts +51 -8
  92. package/src/commands/package.ts +3 -1
  93. package/src/commands/publish.ts +5 -4
  94. package/src/expressRoutes/functionBinder.ts +14 -10
  95. package/src/integration-tests/quickstart-scenario.test.ts +5 -4
  96. package/src/lib/IdSrc.ts +2 -2
  97. package/src/lib/TypeCheck.ts +3 -0
  98. package/src/lib/openAPI/openApiConstruction.ts +37 -32
  99. package/src/lift.ts +1 -1
  100. package/templateData/app/MainPage.tsx +10 -0
  101. package/templateData/app/app.tsx +39 -0
  102. package/templateData/webroot/app.js +7 -7
  103. package/tsconfig.json +2 -2
@@ -25,7 +25,7 @@ import { resolvePaths } from '../lib/pathResolve'
25
25
  import { gatherFunctionDefinitions } from '../lib/openAPI/ApiBuildCollector'
26
26
  import { delay } from '../lib/utils'
27
27
  import { addBuiltInDefinitions, MakeBuiltinApiDoc } from './builtin/ApiDocMaker'
28
- import { DeployApiBuiltin, DeployRootFileserves, DeployWebrootBuiltIn } from './builtin/BuiltInHandler'
28
+ import { DeployApiBuiltin /*, DeployRootFileserves, DeployWebrootBuiltIn */ } from './builtin/BuiltInHandler'
29
29
  import { esbuilder } from '../lib/ESBuild'
30
30
  import { getIdSrc, getIdDelimiter } from '../lib/IdSrc'
31
31
  import { ExportWebroot, getWebrootSettings } from './builtin/ExportWebroot'
@@ -35,9 +35,10 @@ import updateDeployedPermissions from './actions/updateDeployedPermissions'
35
35
  let projectPaths: any
36
36
 
37
37
  export async function doPublishAsync (args: string[] = []): Promise<number> {
38
- const stageName = 'Dev'
39
- const retCode = await doDeployAsync(args)
40
- if (retCode) return retCode
38
+ const stageName: string = 'Dev'
39
+ const retCode: number | undefined = await doDeployAsync(args)
40
+
41
+ if (retCode !== 0) return retCode
41
42
  // const retCode = 0
42
43
 
43
44
  projectPaths = resolvePaths()
@@ -7,7 +7,7 @@ import { resolvePaths } from '../lib/pathResolve'
7
7
  import express from 'express'
8
8
  import { gatherFunctionDefinitions } from '../lib/openAPI/ApiBuildCollector'
9
9
  import { buildOpenApi } from '../lib/openAPI/openApiConstruction'
10
- import { BadRequest, Log } from '@tremho/inverse-y'
10
+ import { Log } from '@tremho/inverse-y'
11
11
  import { parseConstraints } from '../lib/TypeCheck'
12
12
 
13
13
  const clearModule = require('clear-module')
@@ -46,14 +46,16 @@ export function functionBinder (): void {
46
46
  if (n !== -1) entryRoot = entryRoot.substring(0, n) + '/*'
47
47
 
48
48
  const callHandler = (def: any, req: any, res: any): void => {
49
- console.log('>>>>>>> YES WE ARE HERE<<<<<<<<<')
49
+ // console.log('>>>>>>> YES WE ARE HERE<<<<<<<<<')
50
50
  if (Buffer.isBuffer(req.body)) {
51
51
  const buffer: Buffer = req.body
52
+ /* eslint-disable */
52
53
  console.log('body is a buffer at callHandler. Length is ' + buffer.byteLength)
53
54
  console.log('First 16 bytes:', buffer.subarray(0, 16).toString('hex'))
55
+ /* eslint-enable */
54
56
  }
55
57
  const message = testPathRoute(def, req)
56
- if (message) {
58
+ if (message !== '') {
57
59
  return handleResponse(res, { statusCode: 403, body: { error: message } })
58
60
  }
59
61
  const event = requestToEvent(def, req)
@@ -91,11 +93,11 @@ export function functionBinder (): void {
91
93
  }
92
94
 
93
95
  // compare request route to the definition of this function to see if it matches
94
- function testPathRoute (def: any, req: any) {
96
+ function testPathRoute (def: any, req: any): string {
95
97
  let path = req.path
96
98
  let pathMap = def.pathMap
97
- if (path.endsWith('/')) path = path.substring(0, path.length - 1)
98
- if (pathMap.endsWith('/')) pathMap = pathMap.substring(0, path.length - 1)
99
+ if (path.endsWith('/') === true) path = path.substring(0, path.length - 1)
100
+ if (pathMap.endsWith('/') === true) pathMap = pathMap.substring(0, path.length - 1)
99
101
  const defParts = pathMap.split('/')
100
102
  const pathParts = path.split('/')
101
103
 
@@ -109,7 +111,7 @@ function testPathRoute (def: any, req: any) {
109
111
  return message
110
112
  }
111
113
 
112
- function performParameterTesting (def: any, event: any) {
114
+ function performParameterTesting (def: any, event: any): void {
113
115
  // for every parameter defined in def
114
116
  // find the corresponding value in event.parameters (by name)
115
117
  // find the constraints for that parameter in def
@@ -118,7 +120,7 @@ function performParameterTesting (def: any, event: any) {
118
120
  const constraints = Array.isArray(pdef.constraints) ? parseConstraints(pdef.type, pdef.constraints.join('\n'), '\n') : undefined
119
121
  let value: any = event.parameters[pdef.name]
120
122
  if (value === undefined) {
121
- if (!pdef.required) return // okay to be undefined
123
+ if (pdef.required !== true) return // okay to be undefined
122
124
  }
123
125
  if (pdef.type === 'number') value = Number(value) // TODO: Type coercion for all types
124
126
  constraints?.test(value)
@@ -126,13 +128,13 @@ function performParameterTesting (def: any, event: any) {
126
128
  }
127
129
 
128
130
  // returns 'text', 'json', or undefined
129
- function bodyTypeCollapse (type: string) {
131
+ function bodyTypeCollapse (type: string): string | undefined {
130
132
  const options: any = {
131
133
  text: 'text',
132
134
  json: 'json',
133
135
  'application/json': 'json'
134
136
  }
135
- if (type) {
137
+ if (type !== '') {
136
138
  type = type.toLowerCase().trim()
137
139
  if (type.substring(0, 5) === 'text/') return 'text'
138
140
  return options[type]
@@ -189,11 +191,13 @@ function requestToEvent (def: any, req: any): any {
189
191
  req.body = Buffer.from(req.body)
190
192
  }
191
193
  }
194
+ /* eslint-disable */
192
195
  if (Buffer.isBuffer(req.body)) {
193
196
  const buffer: Buffer = req.body
194
197
  console.log('body is buffer eventToRequest, Length = ' + buffer.byteLength)
195
198
  console.log('First 16 bytes:', buffer.subarray(0, 16).toString('hex'))
196
199
  }
200
+ /* eslint-enable */
197
201
  const template = def.pathMap
198
202
 
199
203
  // unpack weird choice of express when passed from curl.
@@ -23,7 +23,7 @@ async function test (t: any): Promise<void> {
23
23
  fs.rmSync('QSTest', { recursive: true })
24
24
  }
25
25
  // init
26
- await doInit('QSTest', true)
26
+ await doInit('QSTest', '', true)
27
27
 
28
28
  // verify project got made
29
29
  assert.isTrue(fs.existsSync('QSTest'), 'created test project')
@@ -73,13 +73,14 @@ async function test (t: any): Promise<void> {
73
73
  const data: string = resp.data.toString()
74
74
  assert.isEqual(data, testMessage, 'saw expected data')
75
75
 
76
- // clean up
77
- process.chdir('..')
78
- fs.rmSync('QSTest', { recursive: true })
76
+ console.log(' ---------- test is complete --------')
79
77
 
78
+ // This should end the test, but for some reason doesn;t
80
79
  t.end()
81
80
  }
82
81
 
83
82
  Tap.test('Integration Quickstart', async t => {
84
83
  await test(t)
84
+ console.log(' ---------- test ended --------')
85
+ process.exit(0) // force exit of test harness
85
86
  })
package/src/lib/IdSrc.ts CHANGED
@@ -39,9 +39,9 @@ export function decoratedName (name: string): string {
39
39
  return dname
40
40
  }
41
41
 
42
- export async function getAccountId () {
42
+ export async function getAccountId (): Promise<string | undefined> {
43
43
  const client = new STSClient({} as any)
44
44
  const command: any = new GetCallerIdentityCommand({})
45
45
  const response: any = await client.send(command)
46
- return response.Account // This is your AWS account ID
46
+ return response.Account ?? '' // This is your AWS account ID
47
47
  }
@@ -2,6 +2,7 @@
2
2
  Module for Constraint definitions and TypeCheck support
3
3
  */
4
4
 
5
+ /* eslint-disable */ // too screwed up. This file originated in an old JS project and was converted to TS quickly. TS-Standard is too restrictive for the style.
5
6
  /**
6
7
  * Enumeration of basic types
7
8
  *
@@ -1166,3 +1167,5 @@ export function validate (
1166
1167
  }
1167
1168
  return ok
1168
1169
  }
1170
+
1171
+ /* eslint-enable */
@@ -7,8 +7,8 @@ import path from 'path'
7
7
  import { resolvePaths } from '../pathResolve'
8
8
  import * as ac from 'ansi-colors'
9
9
  import { decoratedName, getAccountId } from '../IdSrc'
10
- import { getAWSCredentials, getSettings } from '../LiftConfig'
11
- import { parseConstraints, TypeConstraint } from '../TypeCheck'
10
+ import { getSettings } from '../LiftConfig'
11
+ import { parseConstraints } from '../TypeCheck'
12
12
  import yaml from 'js-yaml'
13
13
 
14
14
  export async function buildOpenApi (
@@ -117,14 +117,15 @@ export async function buildOpenApi (
117
117
  }
118
118
 
119
119
  function addTypeSchema (builder: any, schemaName: string, schema: any): void {
120
- let primType = ''
121
- let type = schema?.type ?? 'Empty'
120
+ let primType: string = ''
121
+ let type: string = schema?.type ?? 'Empty'
122
122
  if (type === 'empty') type = 'Empty' // fix case
123
- const isArray = (type.endsWith('[]'))
123
+ const isArray: boolean = (type.endsWith('[]'))
124
124
  if (isArray) type = type.substring(0, type.length - 2)
125
125
  if (type === 'string' || type === 'number' || type === 'object') primType = type
126
- const mime = schema?.mime ?? primType ? 'text/plain' : 'application/json'
127
- const sref = primType ? { type: primType } : { $ref: '#/components/schemas/' + type }
126
+ // const sm: string = schema?.mime
127
+ // const mime: string = sm !== '' ?? primType !== '' ? 'text/plain' : 'application/json'
128
+ const sref: any = primType !== '' ? { type: primType } : { $ref: '#/components/schemas/' + type }
128
129
  let ref: any = {}
129
130
  if (isArray) {
130
131
  ref = { type: 'array', items: sref }
@@ -139,21 +140,22 @@ function addTypeSchema (builder: any, schemaName: string, schema: any): void {
139
140
  const constraints = schema.type !== 'object' && Array.isArray(schema?.constraints) ? parseConstraints(schema.type, schema.constraints.join('\n'), '\n') : undefined
140
141
 
141
142
  const cdesc = (constraints != null) ? '\n - ' + (constraints.describe() ?? '').split('\n').join('\n - ') : ''
142
- let description = schema.description
143
- if (cdesc) description += cdesc
143
+ let description: string = schema.description
144
+ if (cdesc !== '') description += cdesc
144
145
 
145
146
  ref.description = description
146
147
 
147
148
  const required: string[] = []
148
149
 
149
- if (ref.properties) {
150
- for (const [propName, propDef] of Object.entries(schema.properties || {})) {
150
+ if ((ref.properties as boolean)) {
151
+ const sp: any = schema.properties ?? {}
152
+ for (const [propName, propDef] of Object.entries(sp)) {
151
153
  const pda = propDef as any
152
154
  const constraints = Array.isArray(pda?.constraints) ? parseConstraints(pda.type, pda.constraints.join('\n'), '\n') : undefined
153
155
 
154
156
  const cdesc = (constraints != null) ? '\n - ' + (constraints.describe() ?? '').split('\n').join('\n - ') : ''
155
- let description = (propDef as any).description
156
- if (cdesc) description += cdesc
157
+ let description: string = (propDef as any).description
158
+ if (cdesc !== '') description += cdesc
157
159
 
158
160
  // if(constraints) {
159
161
  // console.log("schema definition for "+schemaName+', prop '+propName)
@@ -169,7 +171,8 @@ function addTypeSchema (builder: any, schemaName: string, schema: any): void {
169
171
  ref.properties[propName] = propSchema
170
172
 
171
173
  // Only mark as required if declared explicitly
172
- if (schema.required && schema.required.includes(propName)) {
174
+ const sr: string = schema.required ?? ''
175
+ if (sr !== '' && sr.includes(propName)) {
173
176
  required.push(propName)
174
177
  }
175
178
  }
@@ -185,13 +188,14 @@ async function addFunctionMethod (pathDef: any, method: string, def: any, includ
185
188
  const retDef: any = (def.returns)['200']
186
189
  const content: any = {}
187
190
  let primType = ''
188
- let type = retDef?.type ?? 'Empty'
191
+ let type: string = retDef?.type ?? 'Empty'
189
192
  if (type === 'empty') type = 'Empty' // fix case
190
- const isArray = (type.endsWith('[]'))
193
+ const isArray: boolean = (type.endsWith('[]'))
191
194
  if (isArray) type = type.substring(0, type.length - 2)
192
195
  if (type === 'string' || type === 'number' || type === 'object') primType = type
193
- const mime = retDef?.mime ?? primType ? 'text/plain' : 'application/json'
194
- const ref = primType ? { type: primType } : { $ref: '#/components/schemas/' + type }
196
+ const rdm: string = retDef?.mime ?? ''
197
+ const mime: string = rdm !== '' ? rdm : primType !== '' ? 'text/plain' : 'application/json'
198
+ const ref: any = primType !== '' ? { type: primType } : { $ref: '#/components/schemas/' + type }
195
199
  let schema: any
196
200
  if (isArray) {
197
201
  schema = { type: 'array', items: ref }
@@ -202,11 +206,12 @@ async function addFunctionMethod (pathDef: any, method: string, def: any, includ
202
206
  schema
203
207
  }
204
208
 
205
- const region = getSettings()?.awsPreferredRegion ?? ''
206
- const accountId = await getAccountId()
207
- const decName = decoratedName(def.name)
209
+ const region: string = getSettings()?.awsPreferredRegion ?? ''
210
+ const accountId: string = await getAccountId() ?? ''
211
+ const decName: string = decoratedName(def.name) ?? ''
208
212
 
209
- const isBinary = def.bodyType && !def.bodyType.startsWith('text') && !def.bodyType.endsWith('json')
213
+ const bodyType: string = def.bodyType ?? ''
214
+ const isBinary: boolean = bodyType.startsWith('text') && bodyType.endsWith('json')
210
215
 
211
216
  const methData = {
212
217
  summary: def.name,
@@ -251,18 +256,18 @@ async function addFunctionMethod (pathDef: any, method: string, def: any, includ
251
256
  if (!includeCORS) {
252
257
  // get the other response code declarations
253
258
  for (const rcode of Object.getOwnPropertyNames(def.returns)) {
254
- if (rcode != '200') {
259
+ if (rcode !== '200') {
255
260
  const retDef = def.returns[rcode] ?? {}
256
261
 
257
262
  const content: any = {}
258
- let primType = ''
259
- let type = retDef?.type ?? 'Empty'
263
+ let primType: string = ''
264
+ let type: string = retDef?.type ?? 'Empty'
260
265
  if (type === 'empty') type = 'Empty' // fix case
261
- const isArray = (type.endsWith('[]'))
266
+ const isArray: boolean = (type.endsWith('[]'))
262
267
  if (isArray) type = type.substring(0, type.length - 2)
263
268
  if (type === 'string' || type === 'number' || type === 'object') primType = type
264
- const mime = retDef?.mime ?? primType ? 'text/plain' : 'application/json'
265
- const ref = primType ? { type: primType } : { $ref: '#/components/schemas/' + type }
269
+ const mime: string = retDef?.mime !== undefined ? primType?.length > 0 ? 'text/plain' : 'application/json' : ''
270
+ const ref: any = primType !== '' ? { type: primType } : { $ref: '#/components/schemas/' + type }
266
271
  let schema: any
267
272
  if (isArray) {
268
273
  schema = { type: 'array', items: ref }
@@ -347,8 +352,8 @@ function addParameter (pathDef: any, param: any): void {
347
352
  const constraints = Array.isArray(param.constraints) ? parseConstraints(param.type, param.constraints.join('\n'), '\n') : undefined
348
353
 
349
354
  const cdesc = (constraints != null) ? '\n - ' + (constraints.describe() ?? '').split('\n').join('\n - ') : ''
350
- let description = param.description
351
- if (cdesc) description += cdesc
355
+ let description: string = param.description
356
+ if (cdesc !== '') description += cdesc
352
357
 
353
358
  // don't declare parameters marked as 'body'. OpenAPI doesn't support that.
354
359
  if (param.in === 'path' || param.in === 'query') {
@@ -356,7 +361,7 @@ function addParameter (pathDef: any, param: any): void {
356
361
  in: param.in,
357
362
  name: param.name,
358
363
  description,
359
- example: example || undefined,
364
+ example: example ?? undefined,
360
365
  required,
361
366
  schema: schemaType(deflt, type, true)
362
367
  })
@@ -387,6 +392,6 @@ function schemaType (deflt: string | undefined, namedType: string, innerOnly: bo
387
392
  }
388
393
  if (type === 'int') type = 'integer'
389
394
  if (type === 'bool') type = 'boolean'
390
- if (!deflt) deflt = undefined
395
+ if (deflt === null || deflt === '') deflt = undefined
391
396
  return innerOnly ? { type, format, example: deflt } : { schema: { type, format, example: deflt } }
392
397
  }
package/src/lift.ts CHANGED
@@ -37,7 +37,7 @@ async function processCommand (): Promise<void> {
37
37
  await doDoctor()
38
38
  return
39
39
  case 'init':
40
- return await doInit(args[0] ?? '')
40
+ return await doInit(args[0] ?? '', args[1]) // folder, clientType (react or js default js)
41
41
  case 'create':
42
42
  return doCreate(args[0] ?? '')
43
43
  case 'build': {
@@ -0,0 +1,10 @@
1
+ import React from 'react'
2
+
3
+ export default function MainPage() {
4
+ return (
5
+ <>
6
+ <h2>Hello MistLift</h2>
7
+ <p>from the default React app/MainPage.tsx created by MistLift</p>
8
+ </>
9
+ )
10
+ }
@@ -0,0 +1,39 @@
1
+ import React from 'react'
2
+ import {createRoot} from 'react-dom/client'
3
+ import { BrowserRouter, Route, Routes } from 'react-router-dom'
4
+
5
+ import MainPage from './MainPage'
6
+
7
+ let pageComp = <MainPage />
8
+
9
+ const routes = {
10
+ home: <MainPage />
11
+ }
12
+
13
+ // route to the page directed by the ?page= query parameter
14
+ const params = new URLSearchParams(document.location.search)
15
+ // console.log('search params', params)
16
+ let page = params.get("page")?.toLowerCase().trim()
17
+ // console.log('page='+page)
18
+ // if(!page && document.cookie.indexOf("idtbd=") !== -1) {
19
+ // (IDTBD as any).hasCookie = true
20
+ // }
21
+ pageComp = routes[page] ?? <MainPage />
22
+
23
+ const container = document.getElementById('root')
24
+ const root = createRoot(container)
25
+
26
+ root.render(
27
+ <>
28
+ <BrowserRouter>
29
+ <Routes>
30
+ <Route path = '/index.html' element= {pageComp} />
31
+ <Route path = '/' element= {pageComp} />
32
+ <Route path = '/Dev/index.html' element= {pageComp} />
33
+ <Route path = '/Dev/+' element= {pageComp} />
34
+ <Route path = '/vod/index.html' element= {pageComp} />
35
+ <Route path = '/vod/+' element= {pageComp} />
36
+ </Routes>
37
+ </BrowserRouter>
38
+ </>
39
+ )
@@ -1,9 +1,9 @@
1
- /*
2
- empty template file
1
+ const root = document.getElementById('root')
2
+ const label = document.createElement('H1');
3
+ const message = document.createElement('p');
3
4
 
4
- loaded by template index.html
5
+ label.innerText = 'Hello MistLift'
6
+ message.innerText = "This page content is generated from the default javascript MistLift page in webroot/app.js"
5
7
 
6
- Could be the output of an ESBuild bundle, for example.
7
- See docs/ESBuild and React support.md
8
-
9
- */
8
+ root.appendChild(label);
9
+ root.appendChild(message)
package/tsconfig.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "sourceMap": true,
4
+ "rootDir": "./src",
4
5
  "outDir": "./build",
5
6
  "allowJs": true,
6
7
  "target": "ES2015", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
@@ -21,8 +22,7 @@
21
22
  "./node_modules/"
22
23
  ],
23
24
  "include": [
24
- "**/*.ts",
25
- "src/preload.js"
25
+ "src/**/*.ts"
26
26
  ]
27
27
  }
28
28