tungsten 0.1.71 → 0.1.73

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 (98) hide show
  1. package/dist/Framework.d.ts.map +1 -1
  2. package/dist/Framework.js +11 -10
  3. package/dist/Instance/Instance.d.ts +3 -1
  4. package/dist/Instance/Instance.d.ts.map +1 -1
  5. package/dist/Instance/Instance.js +33 -10
  6. package/dist/Servers/DevServer.d.ts +3 -0
  7. package/dist/Servers/DevServer.d.ts.map +1 -1
  8. package/dist/Servers/DevServer.js +27 -16
  9. package/dist/Servers/ProdServer.d.ts.map +1 -1
  10. package/dist/Servers/TungstenServer.d.ts.map +1 -1
  11. package/dist/Servers/TungstenServer.js +16 -7
  12. package/dist/Servers/hono/TungstenServerHono.d.ts.map +1 -1
  13. package/dist/Servers/hono/TungstenServerHono.js +12 -7
  14. package/dist/Servers/initStores.js +1 -1
  15. package/dist/Servers/loadEnvsDev.d.ts +1 -2
  16. package/dist/Servers/loadEnvsDev.d.ts.map +1 -1
  17. package/dist/Servers/loadEnvsDev.js +5 -2
  18. package/dist/Store/InternalStoreSchema.d.ts +3 -1
  19. package/dist/Store/InternalStoreSchema.d.ts.map +1 -1
  20. package/dist/Store/InternalStoreSchema.js +3 -1
  21. package/dist/_client/client.js +0 -1
  22. package/dist/api/getApiRoutes.d.ts.map +1 -1
  23. package/dist/api/getApiRoutes.js +3 -1
  24. package/dist/api/getExport.d.ts +2 -1
  25. package/dist/api/getExport.d.ts.map +1 -1
  26. package/dist/api/getExport.js +6 -6
  27. package/dist/api/getExportDev.js +1 -1
  28. package/dist/babelPlugins/BabelFakeType.d.ts +6 -0
  29. package/dist/babelPlugins/BabelFakeType.d.ts.map +1 -0
  30. package/dist/babelPlugins/BabelFakeType.js +3 -0
  31. package/dist/babelPlugins/BabelTransformBindDirect.d.ts +2 -2
  32. package/dist/babelPlugins/BabelTransformBindDirect.d.ts.map +1 -1
  33. package/dist/babelPlugins/BabelTransformBindDirect.js +32 -7
  34. package/dist/babelPlugins/BabelTransformBindVar.d.ts +2 -2
  35. package/dist/babelPlugins/BabelTransformBindVar.d.ts.map +1 -1
  36. package/dist/babelPlugins/BabelTransformBindVar.js +11 -6
  37. package/dist/babelPlugins/BabelTransformCjsToEsm.d.ts +2 -2
  38. package/dist/babelPlugins/BabelTransformCjsToEsm.d.ts.map +1 -1
  39. package/dist/babelPlugins/BabelTransformCjsToEsm.js +10 -0
  40. package/dist/babelPlugins/BabelTransformCjsToFunction.d.ts +2 -2
  41. package/dist/babelPlugins/BabelTransformCjsToFunction.d.ts.map +1 -1
  42. package/dist/babelPlugins/BabelTransformCjsToFunction.js +3 -1
  43. package/dist/babelPlugins/BabelTransformCjsToFunction2.d.ts +2 -1
  44. package/dist/babelPlugins/BabelTransformCjsToFunction2.d.ts.map +1 -1
  45. package/dist/babelPlugins/BabelTransformComponentState.d.ts +2 -2
  46. package/dist/babelPlugins/BabelTransformComponentState.d.ts.map +1 -1
  47. package/dist/babelPlugins/BabelTransformDeproxyState.d.ts +2 -2
  48. package/dist/babelPlugins/BabelTransformDeproxyState.d.ts.map +1 -1
  49. package/dist/babelPlugins/BabelTransformReactive.d.ts +2 -2
  50. package/dist/babelPlugins/BabelTransformReactive.d.ts.map +1 -1
  51. package/dist/babelPlugins/BabelTransformReactiveSvelteStyle.d.ts +2 -2
  52. package/dist/babelPlugins/BabelTransformReactiveSvelteStyle.d.ts.map +1 -1
  53. package/dist/babelPlugins/BabelTransformUniqueComponents.d.ts +2 -2
  54. package/dist/babelPlugins/BabelTransformUniqueComponents.d.ts.map +1 -1
  55. package/dist/bin/commands/build.d.ts.map +1 -1
  56. package/dist/bin/commands/build.js +1 -1
  57. package/dist/components/RouteRedirectComponent.d.ts +12 -0
  58. package/dist/components/RouteRedirectComponent.d.ts.map +1 -0
  59. package/dist/components/RouteRedirectComponent.js +15 -0
  60. package/dist/components/{RedirectComponent.d.ts → WebRedirectComponent.d.ts} +4 -5
  61. package/dist/components/WebRedirectComponent.d.ts.map +1 -0
  62. package/dist/components/{RedirectComponent.js → WebRedirectComponent.js} +2 -2
  63. package/dist/env/getEnvSchemas.d.ts +3 -4
  64. package/dist/env/getEnvSchemas.d.ts.map +1 -1
  65. package/dist/env/getEnvSchemas.js +11 -7
  66. package/dist/getComponent.d.ts +2 -2
  67. package/dist/getComponent.d.ts.map +1 -1
  68. package/dist/getComponent.js +10 -3
  69. package/dist/getComponentDev.d.ts +1 -2
  70. package/dist/getComponentDev.d.ts.map +1 -1
  71. package/dist/getComponentDev.js +4 -2
  72. package/dist/getRoutes.d.ts +2 -2
  73. package/dist/getRoutes.d.ts.map +1 -1
  74. package/dist/getRoutes.js +9 -3
  75. package/dist/getRoutesDevs.d.ts +1 -2
  76. package/dist/getRoutesDevs.d.ts.map +1 -1
  77. package/dist/getRoutesDevs.js +4 -2
  78. package/dist/indexInner.d.ts +3 -2
  79. package/dist/indexInner.d.ts.map +1 -1
  80. package/dist/indexInner.js +2 -1
  81. package/dist/iterationQueryString.d.ts +2 -0
  82. package/dist/iterationQueryString.d.ts.map +1 -0
  83. package/dist/iterationQueryString.js +3 -0
  84. package/dist/makeFinalConfig.d.ts.map +1 -1
  85. package/dist/makeFinalConfig.js +3 -5
  86. package/dist/routing/Routes.d.ts +5 -0
  87. package/dist/routing/Routes.d.ts.map +1 -1
  88. package/dist/settings.d.ts +2 -1
  89. package/dist/settings.d.ts.map +1 -1
  90. package/dist/settings.js +2 -1
  91. package/dist/staticGen/getAppRoutes.d.ts.map +1 -1
  92. package/dist/staticGen/getAppRoutes.js +15 -6
  93. package/package.json +2 -1
  94. package/types/modules.d.ts +7 -7
  95. package/dist/babelPlugins/Babel.type.d.ts +0 -2
  96. package/dist/babelPlugins/Babel.type.d.ts.map +0 -1
  97. package/dist/babelPlugins/Babel.type.js +0 -8
  98. package/dist/components/RedirectComponent.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"Framework.d.ts","sourceRoot":"","sources":["../src/Framework.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AAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAEpD,OAAO,EAA+B,qBAAqB,EAAE,MAAM,mCAAmC,CAAA;AAEtG,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AA4BxD,qBAAa,SAAS;IAClB,MAAM,CAAC,EAAE,uBAAuB,CAAA;IAChC,eAAe,CAAC,EAAE,eAAe,CAAA;IACjC,gBAAgB,CAAC,EAAE,qBAAqB,CAAA;IACxC,mBAAmB,CAAC,EAAE,aAAa,CAAA;IACnC,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,UAAU,CAAC,EAAE,UAAU,CAAA;IAEjB,IAAI,IAAI,OAAO,CAAC,uBAAuB,CAAC;IAQxC,KAAK,CAAC,IAAI,EAAE,IAAI;IAmBhB,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,GAAG,YAAY;IAwBhC,SAAS;YAID,aAAa;YAab,cAAc;YASd,mBAAmB;YAcnB,MAAM;IAKd,eAAe,IAAI,OAAO,CAAC,SAAS,CAAC;IAyBrC,aAAa,CAAC,MAAM,EAAE,uBAAuB;IAwH7C,gBAAgB,IAAI,OAAO,CAAC,UAAU,CAAC;CAyDhD"}
package/dist/Framework.js CHANGED
@@ -21,8 +21,6 @@ import { throwError } from "./throwError.js";
21
21
  //import { devBundle } from './build/devBundle.jsx'
22
22
  import { existsSync, readFileSync, openSync, closeSync, writeFileSync, copyFileSync } from 'fs';
23
23
  import { parseIni } from "./parseIni.js";
24
- import sxyLoaderConfig from "../sxy-loader.config.js";
25
- import { createLoad } from 'sxy-loader';
26
24
  import { getEnvSchemas } from "./env/getEnvSchemas.js";
27
25
  import { injectEnv } from "./env/injectEnv.js";
28
26
  //import { ValueOf } from 'sxy-lib'
@@ -42,11 +40,12 @@ export class Framework {
42
40
  _defineProperty(this, "prodServer", void 0);
43
41
  }
44
42
  async init() {
45
- const configOrUndefined = await this.getUserConfig();
46
- if (configOrUndefined === undefined) {
47
- throwError('Framework.init()', 'config is undefined');
48
- }
49
- return configOrUndefined;
43
+ // const configOrUndefined = await this.getUserConfig()
44
+ // if (configOrUndefined === undefined) {
45
+ // throwError('Framework.init()', 'config is undefined')
46
+ // }
47
+ // return configOrUndefined
48
+ return this.getUserConfig();
50
49
  }
51
50
  async build(mode) {
52
51
  if (mode === 'dev') {
@@ -140,8 +139,10 @@ export class Framework {
140
139
  const initialProcessEnv = {
141
140
  ...process.env
142
141
  };
143
- const load = await createLoad(import.meta.url, sxyLoaderConfig);
144
- await loadEnvsDev(this.config, load, initialProcessEnv, false);
142
+ //const load = await createLoad(import.meta.url, sxyLoaderConfig)
143
+ // !REVIEW! why do we need to load envs here?
144
+ //await loadEnvsDev(this.config, load, initialProcessEnv, false)
145
+ await loadEnvsDev(this.config, -1, initialProcessEnv, false);
145
146
  this.devServer = new DevServer(this, this.config, this.compilationInfo);
146
147
  return this.devServer;
147
148
  }
@@ -163,7 +164,7 @@ export class Framework {
163
164
  global.tungstenPrivateEnv = {/*TUNGSTEN_SERVER_PORT: -999*/};
164
165
  // Load schemas
165
166
  const envSchemas = await getEnvSchemas(config);
166
- let someEnvLoaded = false;
167
+ let someEnvLoaded = false; // eslint-disable-line no-type-assertion/no-type-assertion -- widening
167
168
  //const envsLoadedMessages: string[] = []
168
169
  function loadEnv(fileName, filePath, prefix = '') {
169
170
  const env = parseIni(readFileSync(filePath, 'utf-8'));
@@ -8,6 +8,7 @@ import { MatchedRouteInfo } from '../Servers/MatchedRouteInfo.js';
8
8
  import { type RouteKey } from '../routing/RouteTypes.js';
9
9
  import type { Routes } from '../routing/Routes.js';
10
10
  import { StoreSubscriptionsMap } from 'tungsten/Store/StoreSubscriptions.types.js';
11
+ import { RedirectCode } from '../routing/RedirectCode.js';
11
12
  export declare class Instance {
12
13
  location: string;
13
14
  reqRes: ReqRes | null;
@@ -30,7 +31,8 @@ export declare class Instance {
30
31
  constructor(location: string, instanceConfig: InstanceConfig, reqRes: ReqRes | null, appRoutes: AppRoutes, routes: Routes, internalStore: TrueStore<InternalStoreSchema>, stores: TrueStore<any>[], storeSubscriptions: StoreSubscriptionsMap, globalData: GlobalData, matchedRouteInfo: MatchedRouteInfo);
31
32
  getRoutes: () => Routes;
32
33
  updateLocation: (location: string) => void;
33
- goto: (location: RouteKey) => Promise<void>;
34
+ goto: (routeKey: RouteKey) => Promise<void>;
35
+ redirect: (url: string, code?: RedirectCode) => void;
34
36
  setDefaultTitle: (defaultTitle: string) => void;
35
37
  setTitle: (title: string) => void;
36
38
  setTitleToDefault: () => void;
@@ -1 +1 @@
1
- {"version":3,"file":"Instance.d.ts","sourceRoot":"","sources":["../../src/Instance/Instance.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AACnE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAA;AAElE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAA;AACrE,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AAIjE,OAAO,EAAyB,KAAK,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AAC/E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4CAA4C,CAAA;AAOlF,qBAAa,QAAQ;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,SAAS,EAAE,SAAS,CAAA;IACpB,MAAM,EAAE,MAAM,CAAA;IACd,iBAAiB,UAAQ;IACzB,aAAa,EAAE,SAAS,CAAC,mBAAmB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CAAC,EAC7C,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EAAE,EACxB,kBAAkB,EAAE,qBAAqB,EACzC,UAAU,EAAE,UAAU,EACtB,gBAAgB,EAAE,gBAAgB;IAgCtC,SAAS,eAER;IACD,cAAc,GAAI,UAAU,MAAM,UAMjC;IACD,IAAI,GAAU,UAAU,QAAQ,mBA6D/B;IASD,QAAQ,GAAI,KAAK,MAAM,EAAE,OAAM,YAAkB,UAQhD;IACD,eAAe,GAAI,cAAc,MAAM,UAEtC;IACD,QAAQ,GAAI,OAAO,MAAM,UAIxB;IACD,iBAAiB,aAEhB;CAIJ"}
@@ -8,7 +8,11 @@ import { throwError } from "../throwError.js";
8
8
  import { StringIsValidRouteKey } from "../routing/RouteTypes.js";
9
9
  import { isProd } from "../isProd.js";
10
10
  import { WebRedirect } from "../routing/WebRedirect.js";
11
- import { RedirectComponent } from "../components/RedirectComponent.js";
11
+ import { RouteRedirectComponent } from "../components/RouteRedirectComponent.js";
12
+ import { WebRedirectComponent } from "../components/WebRedirectComponent.js";
13
+ import { isServer } from "../isServer.js";
14
+ import { ContentNodeIsClassComponent } from "../ContentNode.js";
15
+ import { $props, $type } from "../contentNodeSymbols.js";
12
16
  export class Instance {
13
17
  constructor(_location, instanceConfig, reqRes, appRoutes, routes,
14
18
  //globalData: GlobalData,
@@ -45,10 +49,10 @@ export class Instance {
45
49
  this.location = location;
46
50
  this.internalStore.location.set(location);
47
51
  });
48
- _defineProperty(this, "goto", async location => {
52
+ _defineProperty(this, "goto", async routeKey => {
49
53
  // get route data
50
54
  this.navigating = true;
51
- const matchedRouteInfo = await routing(location, this.getRoutes());
55
+ const matchedRouteInfo = await routing(routeKey, this.getRoutes());
52
56
  //console.log('matchedRouteInfo', location, matchedRouteInfo)
53
57
  //console.log('matched route info', this.matchedRouteInfo)
54
58
  // data here is the result of the route data function
@@ -58,27 +62,37 @@ export class Instance {
58
62
  return;
59
63
  } else if (matchedRouteInfo.data instanceof WebRedirect) {
60
64
  throwError('Instance.goto', 'WebRedirect not yet implemented');
65
+ this.redirect;
61
66
  //const redirect = matchedRouteInfo.data
62
67
  //this.goto(redirect.to)
63
68
  //return
64
69
  }
65
70
  // handle Redirect components
66
- if (matchedRouteInfo.content instanceof RedirectComponent
67
- //&& matchedRouteInfo.content.__tungstenComponentType === 'redirect'
68
- ) {
69
- this.goto(matchedRouteInfo.content.props.to);
70
- return;
71
+ // if (
72
+ // matchedRouteInfo.content instanceof RedirectComponent
73
+ // //&& matchedRouteInfo.content.__tungstenComponentType === 'redirect'
74
+ // ) {
75
+ if (typeof matchedRouteInfo.content !== 'function' && ContentNodeIsClassComponent(matchedRouteInfo.content)) {
76
+ if (matchedRouteInfo.content[$type] === RouteRedirectComponent || matchedRouteInfo.content[$type].prototype instanceof RouteRedirectComponent) {
77
+ this.goto(matchedRouteInfo.content[$props].to);
78
+ return;
79
+ } else if (matchedRouteInfo.content[$type] === WebRedirectComponent || matchedRouteInfo.content[$type].prototype instanceof WebRedirectComponent) {
80
+ console.log('Content is a WebRedirectComponent - perform a hard redirect');
81
+ this.redirect(matchedRouteInfo.content[$props].to);
82
+ return;
83
+ }
71
84
  }
85
+ console.log('updating route info to', matchedRouteInfo);
72
86
  //console.log('instance goto')
73
87
  //console.log('siteBasePath', this.config.siteBasePath)
74
88
  //console.log('location', location)
75
89
  //console.log('final dest', this.config.siteBasePath + location)
76
90
  this.matchedRouteInfo = matchedRouteInfo;
77
91
  const publicUrl = isProd && this.config.staticSite === true // add .html suffix for static sites
78
- ? location === '/' ? '/' : location + '.html' : location;
92
+ ? routeKey === '/' ? '/' : routeKey + '.html' : routeKey;
79
93
  if (isClient) window.history.pushState(null, '', this.config.siteBasePath + publicUrl);
80
94
  this.setTitleToDefault();
81
- this.updateLocation(location); // this.internalStore.set('location', to)
95
+ this.updateLocation(routeKey); // this.internalStore.set('location', to)
82
96
  //this.finishedNavigating()
83
97
  });
84
98
  // postNavigationQueue: (() => void)[] = []
@@ -89,6 +103,15 @@ export class Instance {
89
103
  // func()
90
104
  // }
91
105
  // }
106
+ _defineProperty(this, "redirect", (url, code = 302) => {
107
+ if (this.reqRes) {
108
+ console.assert(isServer, 'reqRes is set, expected isServer to be truth');
109
+ this.reqRes.res.redirect(code, url);
110
+ } else {
111
+ console.assert(isClient, 'reqRes is not set, expected isClient to be truthy');
112
+ window.location.replace(url);
113
+ }
114
+ });
92
115
  _defineProperty(this, "setDefaultTitle", defaultTitle => {
93
116
  this.defaultTitle = defaultTitle;
94
117
  });
@@ -1,5 +1,6 @@
1
1
  import type { Server } from 'http';
2
2
  import express from 'express';
3
+ import 'esm-reload';
3
4
  import type { FrameworkConfigComplete } from '../FrameworkConfig.js';
4
5
  import type { CompilationInfo } from '../build/CompilationInfo.js';
5
6
  import type { ApiRoutes } from '../api/ApiRoutes.js';
@@ -20,6 +21,8 @@ export declare class DevServer extends TungstenServer {
20
21
  server?: Server;
21
22
  reqId: number;
22
23
  firstRender: boolean;
24
+ iterationCount: number;
25
+ serverIterationCount: number;
23
26
  constructor(framework: Framework, config: FrameworkConfigComplete, compilationInfo: CompilationInfo, initialProcessEnv?: Record<string, string>);
24
27
  private addServerMiddleware;
25
28
  private handleRequestApi;
@@ -1 +1 @@
1
- {"version":3,"file":"DevServer.d.ts","sourceRoot":"","sources":["../../src/Servers/DevServer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAClC,OAAO,OAA4D,MAAM,SAAS,CAAA;AAGlF,OAAO,KAAK,EAAE,uBAAuB,EAAwB,MAAM,uBAAuB,CAAA;AAC1F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAOpD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAW3C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAIrC,OAAO,EAAE,UAAU,EAAkB,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AAI,OAAO,OAAO,UAIzB;IACD,SAAS,GAAI,OAAO,OAAO,EAAE,YAAY,MAAM,EAAE,YAehD;IACD,KAAK,QAAO,OAAO,CAAC,MAAM,CAAC,CAO1B;IACD,IAAI,aAEH;CAGJ"}
@@ -3,6 +3,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
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
  import express from 'express';
5
5
  import { join } from 'path';
6
+ import 'esm-reload'; // V important ES module cache control
6
7
  import { allObj as promiseAllObj } from 'sxy-lib/promises.js';
7
8
  import { staticFolder, assetsFolder, publicFolder, packagesFolder, clientFolder, componentCssFolder } from "../settings.js";
8
9
  import { rootToHtmlDev as renderRootToHtmlDev } from "../render/rootToHtmlDev.js";
@@ -17,8 +18,6 @@ import { log } from "../appOutput.js";
17
18
  import { throwError } from "../throwError.js";
18
19
  import { getRoutesDev } from "../getRoutesDevs.js";
19
20
  import { getComponentDev } from "../getComponentDev.js";
20
- import sxyLoaderConfig from "../../sxy-loader.config.js";
21
- import { createLoad } from 'sxy-loader';
22
21
  import { routing } from "./routing.js";
23
22
  import { globalDataFunc } from "../routing/registerGlobalData.js";
24
23
  import { TungstenServer } from "./TungstenServer.js";
@@ -26,6 +25,7 @@ import { portError } from "./portError.js";
26
25
  import { loadEnvsDev } from "./loadEnvsDev.js";
27
26
  import { initStores } from "./initStores.js";
28
27
  import { MatchedRoute } from "../routing/MatchedRoute.js";
28
+ import { iterationQueryString } from "../iterationQueryString.js";
29
29
  //import cookieParser from 'cookie-parser'
30
30
  function debug(...texts) {
31
31
  // console.log(...texts)
@@ -46,6 +46,8 @@ export class DevServer extends TungstenServer {
46
46
  _defineProperty(this, "server", void 0);
47
47
  _defineProperty(this, "reqId", void 0);
48
48
  _defineProperty(this, "firstRender", true);
49
+ _defineProperty(this, "iterationCount", 0);
50
+ _defineProperty(this, "serverIterationCount", 0);
49
51
  _defineProperty(this, "addServerMiddleware", serverMiddleware => {
50
52
  //console.log('addServerMiddleware')
51
53
  const [middlewareFile, middlewareExportName, middlewarePath] = serverMiddleware;
@@ -75,14 +77,17 @@ export class DevServer extends TungstenServer {
75
77
  // code
76
78
  // [*] const middlewares = await middlewaresPromise
77
79
  try {
78
- const load = await createLoad(import.meta.url, sxyLoaderConfig);
80
+ //const load = await createLoad(import.meta.url, sxyLoaderConfig)
79
81
  const fullFilePath = 'file://' + join(this.compilationInfo.codeLocation, middlewareFile);
80
- const middlewareModule = await load(fullFilePath);
82
+ //const middlewareModule = await load(fullFilePath)
83
+ const middlewareModule = await import(iterationQueryString(fullFilePath, this.serverIterationCount++));
81
84
  if (!(middlewareExportName in middlewareModule)) {
82
85
  throwError('DevServer', `export ${middlewareExportName} not found in ${middlewareFile}` + ` when trying to load server middleware`);
83
86
  }
84
87
  const middlewares = middlewareModule[middlewareExportName]; // eslint-disable-line no-type-assertion/no-type-assertion
85
- if (!Array.isArray(middlewares)) throwError('addServerMiddleware', `Expected middlewares to be an array`);
88
+ if (!Array.isArray(middlewares)) {
89
+ throwError('addServerMiddleware', `Expected middlewares to be an array`);
90
+ }
86
91
  if (!(0 in middlewares)) throwError('addServerMiddleware', `No middleware entry at index 0`);
87
92
  const firstMiddleware = middlewares[0];
88
93
  if (!(typeof firstMiddleware === 'function')) {
@@ -137,6 +142,7 @@ export class DevServer extends TungstenServer {
137
142
  try {
138
143
  const _firstRender = this.firstRender;
139
144
  this.firstRender = false;
145
+ const iteration = this.iterationCount++;
140
146
  //console.log('received a frontend req', req.originalUrl, res.locals.reqId)
141
147
  //// I think we need to pass req, (res?) to the app
142
148
  //// so that it can set response codes
@@ -154,8 +160,9 @@ export class DevServer extends TungstenServer {
154
160
  throwError('DevServer.handleRequest()', 'framework.frameworkModules is undefined');
155
161
  }
156
162
  globalDataFunc.value = undefined;
157
- const load = await createLoad(import.meta.url, sxyLoaderConfig);
158
- await loadEnvsDev(this.config, load, this.initialProcessEnv, false);
163
+ //const load = await createLoad(import.meta.url, sxyLoaderConfig)
164
+ //await loadEnvsDev(this.config, load, this.initialProcessEnv, false)
165
+ await loadEnvsDev(this.config, iteration, this.initialProcessEnv, false);
159
166
  // we are delaying instance creation until after we load the app code, to lets things initialise?
160
167
  const reqRes = {
161
168
  req,
@@ -165,7 +172,8 @@ export class DevServer extends TungstenServer {
165
172
  const serverDataLoading = {
166
173
  value: false
167
174
  };
168
- const routingPromise = getRoutesDev(this.compilationInfo, this.config, load).then(async appRoutes => {
175
+ //const routingPromise = getRoutesDev(this.compilationInfo, this.config, load).then(
176
+ const routingPromise = getRoutesDev(this.compilationInfo, this.config, iteration).then(async appRoutes => {
169
177
  const routes = typeof appRoutes === 'function' ? appRoutes(reqRes) : appRoutes;
170
178
  // load data, and do routing
171
179
  return promiseAllObj({
@@ -215,7 +223,8 @@ export class DevServer extends TungstenServer {
215
223
  RootComponentClass
216
224
  } = await promiseAllObj({
217
225
  routing: routingPromise,
218
- RootComponentClass: getComponentDev(rootComponentFileFull, this.config.rootComponent, load)
226
+ //RootComponentClass: getComponentDev(rootComponentFileFull, this.config.rootComponent, load)
227
+ RootComponentClass: getComponentDev(rootComponentFileFull, this.config.rootComponent, iteration)
219
228
  })
220
229
  // .catch(e => {
221
230
  // cliError('ROUTING AND ROOT ERR')
@@ -359,14 +368,16 @@ export class DevServer extends TungstenServer {
359
368
  const targetOrigin = req.protocol + '://' + String(req.header('host'));
360
369
  const target = targetOrigin + req.url;
361
370
  const origin = req.header('origin');
362
- // request log
363
- let message = 'Received request at ' + target;
364
- if (origin !== undefined) {
365
- message += ' from ' + String(req.header('origin'));
366
- // should we use referrer as a backup option?
367
- // not sure what that is
371
+ if (tungstenPrivateEnv.DEBUG === true) {
372
+ // request log
373
+ let message = 'Received request at ' + target;
374
+ if (origin !== undefined) {
375
+ message += ' from ' + String(req.header('origin'));
376
+ // should we use referrer as a backup option?
377
+ // not sure what that is
378
+ }
379
+ cliOut(message);
368
380
  }
369
- cliOut(message);
370
381
  if (this.config.suppressOriginMismatchWarning !== true) {
371
382
  // origin-target mismatch warning
372
383
  if (origin !== undefined && origin === this.location && origin !== targetOrigin) {
@@ -1 +1 @@
1
- {"version":3,"file":"ProdServer.d.ts","sourceRoot":"","sources":["../../src/Servers/ProdServer.ts"],"names":[],"mappings":"AAEA,OAAO,OAAO,MAAM,SAAS,CAAA;AAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAI7B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAMpD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAM3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAKnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAWrD,qBAAa,UAAW,SAAQ,cAAc;IAC1C,SAAS,EAAE,SAAS,CAAA;IACpB,MAAM,EAAE,uBAAuB,CAAA;IAC/B,eAAe,EAAE,eAAe,CAAA;IAChC,SAAS,EAAE,SAAS,CAAA;IACpB,mBAAmB,EAAE,gBAAgB,GAAG,IAAI,CAAA;IAK5C,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAO;IAC9B,GAAG,EAAE,OAAO,CAAC,WAAW,CAAA;IACxB,gBAAgB,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,CAAA;IACrC,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,MAAM,CAAC,EAAE,MAAM,CA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AA;IACpB,mBAAmB,EAAE,gBAAgB,GAAG,IAAI,CAAA;IAK5C,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAO;IAC9B,GAAG,EAAE,OAAO,CAAC,WAAW,CAAA;IACxB,gBAAgB,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,CAAA;IACrC,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,MAAM,CAAC,EAAE,MAAM,CAAA;gBAEX,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,uBAAuB,EAC/B,eAAe,EAAE,eAAe,EAChC,SAAS,EAAE,SAAS,EACpB,mBAAmB,EAAE,gBAAgB,GAAG,IAAI,EAC5C,gBAAgB,EAAE,gBAAgB,GAAG,IAAI;IAuH7C,OAAO,CAAC,gBAAgB,CAgBvB;IACD,aAAa,GAAU,KAAK,OAAO,CAAC,OAAO,EAAE,KAAK,OAAO,CAAC,QAAQ,KAAG,OAAO,CAAC,IAAI,CAAC,CA6GjF;IACD,SAAS,eASR;IAMD,KAAK,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,IAAI,UAAQ,GAAG,OAAO,CAAC,MAAM,CAAC;IAwBlE,IAAI;CAKP"}
@@ -1 +1 @@
1
- {"version":3,"file":"TungstenServer.d.ts","sourceRoot":"","sources":["../../src/Servers/TungstenServer.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAE7D,OAAO,KAAK,EAAE,QAAQ,IAAI,eAAe,EAAE,MAAM,SAAS,CAAA;AAgB1D,qBAAa,cAAc;IACvB,SAAS,CAAC,eAAe,CAAC,GAAG,EAAE,eAAe,EAAE,gBAAgB,EAAE,gBAAgB,GAAG,OAAO;CAyC/F"}
1
+ {"version":3,"file":"TungstenServer.d.ts","sourceRoot":"","sources":["../../src/Servers/TungstenServer.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAE7D,OAAO,KAAK,EAAE,QAAQ,IAAI,eAAe,EAAE,MAAM,SAAS,CAAA;AAiB1D,qBAAa,cAAc;IACvB,SAAS,CAAC,eAAe,CAAC,GAAG,EAAE,eAAe,EAAE,gBAAgB,EAAE,gBAAgB,GAAG,OAAO;CAoD/F"}
@@ -1,7 +1,8 @@
1
1
  import { ContentNodeIsClassComponent } from "../ContentNode.js";
2
2
  import { RoutingRedirect } from "../routing/RoutingRedirect.js";
3
3
  import { cliTodo } from "../cliOutput.js";
4
- import { RedirectComponent } from "../components/RedirectComponent.js";
4
+ import { RouteRedirectComponent } from "../components/RouteRedirectComponent.js";
5
+ import { WebRedirectComponent } from "../components/WebRedirectComponent.js";
5
6
  import { $props, $type } from "../contentNodeSymbols.js";
6
7
  import { WebRedirect } from "../routing/WebRedirect.js";
7
8
  function debug(...texts) {
@@ -28,12 +29,20 @@ export class TungstenServer {
28
29
  // console.log('$type', (matchedRouteInfo as any).content[$type])
29
30
  //console.log('content[$type]', matchedRouteInfo.content[$type])
30
31
  //console.log('instanceof', matchedRouteInfo.content instanceof RedirectComponent)
31
- if (typeof matchedRouteInfo.content !== 'function' && ContentNodeIsClassComponent(matchedRouteInfo.content) && (matchedRouteInfo.content[$type] === RedirectComponent || matchedRouteInfo.content[$type].prototype instanceof RedirectComponent)) {
32
- cliTodo('consider type of RedirectComponent props');
33
- const code = matchedRouteInfo.content[$props].code || 302;
34
- const to = matchedRouteInfo.content[$props].to;
35
- res.redirect(code, to);
36
- return true;
32
+ if (typeof matchedRouteInfo.content !== 'function' && ContentNodeIsClassComponent(matchedRouteInfo.content)) {
33
+ if (matchedRouteInfo.content[$type] === RouteRedirectComponent || matchedRouteInfo.content[$type].prototype instanceof RouteRedirectComponent) {
34
+ cliTodo('consider type of RedirectComponent props');
35
+ const code = matchedRouteInfo.content[$props].code || 302;
36
+ const to = matchedRouteInfo.content[$props].to;
37
+ res.redirect(code, to);
38
+ return true;
39
+ } else if (matchedRouteInfo.content[$type] === WebRedirectComponent || matchedRouteInfo.content[$type].prototype instanceof WebRedirectComponent) {
40
+ cliTodo('consider type of RedirectComponent props');
41
+ const code = matchedRouteInfo.content[$props].code || 302;
42
+ const to = matchedRouteInfo.content[$props].to;
43
+ res.redirect(code, to);
44
+ return true;
45
+ }
37
46
  }
38
47
  return false;
39
48
  }
@@ -1 +1 @@
1
- {"version":3,"file":"TungstenServerHono.d.ts","sourceRoot":"","sources":["../../../src/Servers/hono/TungstenServerHono.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAG9D,OAAO,EAAQ,OAAO,EAAE,MAAM,MAAM,CAAA;AAsBpC,qBAAa,kBAAkB;IAC3B,SAAS,CAAC,eAAe,CAAC,CAAC,EAAE,OAAO,EAAY,gBAAgB,EAAE,gBAAgB,GAAG,OAAO;CAyC/F"}
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"}
@@ -3,9 +3,10 @@ import { Hono } from 'hono';
3
3
  import { ContentNodeIsClassComponent } from "../../ContentNode.js";
4
4
  import { RoutingRedirect } from "../../routing/RoutingRedirect.js";
5
5
  import { cliTodo } from "../../cliOutput.js";
6
- import { RedirectComponent } from "../../components/RedirectComponent.js";
6
+ import { RouteRedirectComponent } from "../../components/RouteRedirectComponent.js";
7
7
  import { $props, $type } from "../../contentNodeSymbols.js";
8
8
  import { WebRedirect } from "../../routing/WebRedirect.js";
9
+ import { throwError } from "../../throwError.js";
9
10
  const app = new Hono();
10
11
  app.get(async c => {
11
12
  const id = c.req.param('id');
@@ -36,12 +37,16 @@ export class TungstenServerHono {
36
37
  // console.log('$type', (matchedRouteInfo as any).content[$type])
37
38
  //console.log('content[$type]', matchedRouteInfo.content[$type])
38
39
  //console.log('instanceof', matchedRouteInfo.content instanceof RedirectComponent)
39
- if (typeof matchedRouteInfo.content !== 'function' && ContentNodeIsClassComponent(matchedRouteInfo.content) && (matchedRouteInfo.content[$type] === RedirectComponent || matchedRouteInfo.content[$type].prototype instanceof RedirectComponent)) {
40
- cliTodo('consider type of RedirectComponent props');
41
- const code = matchedRouteInfo.content[$props].code || 302;
42
- const to = matchedRouteInfo.content[$props].to;
43
- c.redirect(to, code);
44
- return true;
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
+ }
45
50
  }
46
51
  return false;
47
52
  }
@@ -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,9 +1,8 @@
1
- import type { Load } from 'sxy-loader';
2
1
  import type { FrameworkConfigComplete } from '../FrameworkConfig.js';
3
2
  type ProcessEnv = {
4
3
  [x: string]: string | undefined;
5
4
  TZ?: string;
6
5
  };
7
- export declare function loadEnvsDev(config: FrameworkConfigComplete, load: Load, initialProcessEnv: ProcessEnv, _firstLoad: boolean): Promise<void>;
6
+ export declare function loadEnvsDev(config: FrameworkConfigComplete, iteration: number, initialProcessEnv: ProcessEnv, _firstLoad: boolean): Promise<void>;
8
7
  export {};
9
8
  //# sourceMappingURL=loadEnvsDev.d.ts.map
@@ -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;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"}
1
+ {"version":3,"file":"loadEnvsDev.d.ts","sourceRoot":"","sources":["../../src/Servers/loadEnvsDev.ts"],"names":[],"mappings":"AAKA,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,EAE/B,SAAS,EAAE,MAAM,EACjB,iBAAiB,EAAE,UAAU,EAC7B,UAAU,EAAE,OAAO,iBAmGtB"}
@@ -7,12 +7,15 @@ import { cliLog, cliOut } from "../cliOutput.js";
7
7
  import { injectEnv } from "../env/injectEnv.js";
8
8
  import { throwError } from 'tungsten/throwError.js';
9
9
  import { tungstenCorePrivateEnvSchema } from "./tungstenCorePrivateEnvSchema.js";
10
- export async function loadEnvsDev(config, load, initialProcessEnv, _firstLoad) {
10
+ export async function loadEnvsDev(config,
11
+ //load: Load,
12
+ iteration, initialProcessEnv, _firstLoad) {
11
13
  //console.log('loadEnvsDev')
12
14
  const tempEnv = {
13
15
  ...initialProcessEnv
14
16
  };
15
- const envSchemas = await getEnvSchemasDev(config, load);
17
+ // const envSchemas = await getEnvSchemasDev(config, load)
18
+ const envSchemas = await getEnvSchemasDev(config, iteration);
16
19
  const projectDir = process.cwd();
17
20
  const envLocation = join(projectDir, '.env');
18
21
  const privateEnvLocation = join(projectDir, '.env.private');
@@ -1,5 +1,7 @@
1
+ import type { MatchedRouteInfo } from '../Servers/MatchedRouteInfo.js';
1
2
  export declare class InternalStoreSchema {
2
3
  location: string;
3
- constructor(location: string);
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;gBACJ,QAAQ,EAAE,MAAM;CAG/B"}
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
  }
@@ -2,7 +2,6 @@
2
2
  import { hydrate } from 'tungsten';
3
3
  // @ts-ignore -- ignore module not found, will be generated later
4
4
  import instanceConfig from "../.tungsten.config.js";
5
- console.log('app config', instanceConfig);
6
5
  // wrap the async code in an async IIFE to help rollup
7
6
  const clientPromise = (async () => {
8
7
  //const isProd = window.__tungsten_prod__ = appConfig.prod
@@ -1 +1 @@
1
- {"version":3,"file":"getApiRoutes.d.ts","sourceRoot":"","sources":["../../src/api/getApiRoutes.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAEjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD,OAAO,EAAE,eAAe,EAAC,MAAM,6BAA6B,CAAA;AAK5D,wBAAsB,YAAY,CAAC,MAAM,EAAE,eAAe,EAAE,eAAe,EAAE,eAAe,EAAE,IAAI,EAAE,IAAI,sBAavG"}
1
+ {"version":3,"file":"getApiRoutes.d.ts","sourceRoot":"","sources":["../../src/api/getApiRoutes.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAEjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD,OAAO,EAAE,eAAe,EAAC,MAAM,6BAA6B,CAAA;AAK5D,wBAAsB,YAAY,CAAC,MAAM,EAAE,eAAe,EAAE,eAAe,EAAE,eAAe,EAAE,IAAI,EAAE,IAAI,sBAevG"}
@@ -3,7 +3,9 @@ import { TungstenError } from "../TungstenError.js";
3
3
  import { getExportDev } from "./getExportDev.js";
4
4
  import { getExport } from "./getExport.js";
5
5
  export async function getApiRoutes(config, compilationInfo, mode) {
6
- if (typeof config.apiRoutes !== 'string') throw new TungstenError(`getApiRoutes() error - config.apiRoutes is not valid`);
6
+ if (typeof config.apiRoutes !== 'string') {
7
+ throw new TungstenError(`getApiRoutes() error - config.apiRoutes is not valid`);
8
+ }
7
9
  const apiRoutesFileFull = join(compilationInfo.location, config.apiRoutes);
8
10
  //console.log('rootComponentFileFull', 'xxx', 'config.rootComponent', config.rootComponent)
9
11
  //console.log('rootComponentFileFull', apiRoutesFileFull, 'config.rootComponent', config.apiRoutes)
@@ -1,2 +1,3 @@
1
- export declare function getExport(filePath: string, relFile: string, dev?: boolean): Promise<any>;
1
+ import { Mode } from '../Mode.js';
2
+ export declare function getExport(filePath: string, relFile: string, mode?: Mode): Promise<any>;
2
3
  //# sourceMappingURL=getExport.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getExport.d.ts","sourceRoot":"","sources":["../../src/api/getExport.ts"],"names":[],"mappings":"AAUA,wBAAsB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,UAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,CAuB5F"}
1
+ {"version":3,"file":"getExport.d.ts","sourceRoot":"","sources":["../../src/api/getExport.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAOjC,wBAAsB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,IAAa,GAAG,OAAO,CAAC,GAAG,CAAC,CAuBpG"}
@@ -1,18 +1,18 @@
1
- import { createLoad } from 'sxy-loader';
2
1
  import { basename } from 'path';
3
2
  import { fixExtension } from "../fixExtension.js";
4
3
  import { TungstenError } from "../TungstenError.js";
5
- import sxyLoaderConfig from "../../sxy-loader.config.js";
4
+ import { iterationQueryString } from "../iterationQueryString.js";
6
5
  //let load //// !! future improvement
7
- export async function getExport(filePath, relFile, dev = false) {
6
+ let exportIteration = 0;
7
+ export async function getExport(filePath, relFile, mode = 'prod') {
8
8
  const fileName = basename(relFile);
9
9
  filePath = 'file://' + fixExtension(filePath);
10
10
  //console.log(filePath)
11
11
  let module;
12
- if (dev) {
12
+ if (mode === 'dev') {
13
13
  //if ( ! load ) load = await createLoad(import.meta.url, sxyLoaderConfig) //// !! future improvement
14
- const load = await createLoad(import.meta.url, sxyLoaderConfig);
15
- module = await load(filePath);
14
+ //const load = await createLoad(import.meta.url, sxyLoaderConfig)
15
+ module = await import(iterationQueryString(filePath, exportIteration++));
16
16
  } else {
17
17
  module = await import(filePath); // import the module
18
18
  }
@@ -1,4 +1,4 @@
1
1
  import { getExport } from "./getExport.js";
2
2
  export function getExportDev(filePathFull, relFile) {
3
- return getExport(filePathFull, relFile, true);
3
+ return getExport(filePathFull, relFile, 'dev');
4
4
  }
@@ -0,0 +1,6 @@
1
+ import { parse } from '@babel/core';
2
+ export type BabelFake = {
3
+ types: any;
4
+ parse: typeof parse;
5
+ };
6
+ //# sourceMappingURL=BabelFakeType.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BabelFakeType.d.ts","sourceRoot":"","sources":["../../src/babelPlugins/BabelFakeType.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAEnC,MAAM,MAAM,SAAS,GAAG;IACpB,KAAK,EAAE,GAAG,CAAA;IACV,KAAK,EAAE,OAAO,KAAK,CAAA;CACtB,CAAA"}
@@ -0,0 +1,3 @@
1
+ // //import { } from '@babel/types/lib/builders/generated/index.js'
2
+ // //import { type } from '@babel/generator'
3
+ export {};
@@ -1,6 +1,6 @@
1
- import type { Babel } from './Babel.type.js';
2
1
  import { NodePath, types } from '@babel/core';
3
- export declare function MakeBabelTransformBindDirect(): (babel: Babel) => {
2
+ import { BabelFake } from './BabelFakeType.js';
3
+ export declare function MakeBabelTransformBindDirect(): (babel: BabelFake) => {
4
4
  name: string;
5
5
  visitor: {
6
6
  JSXAttribute(path: NodePath<types.JSXAttribute>, state: any): void;
@@ -1 +1 @@
1
- {"version":3,"file":"BabelTransformBindDirect.d.ts","sourceRoot":"","sources":["../../src/babelPlugins/BabelTransformBindDirect.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AA2C7C,wBAAgB,4BAA4B,KACC,OAAO,KAAK;;;2BAKtB,QAAQ,CAAC,KAAK,CAAC,YAAY,CAAC,SAAS,GAAG;;EAkS1E"}
1
+ {"version":3,"file":"BabelTransformBindDirect.d.ts","sourceRoot":"","sources":["../../src/babelPlugins/BabelTransformBindDirect.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAG7C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AA0C9C,wBAAgB,4BAA4B,KACC,OAAO,SAAS;;;2BAK1B,QAAQ,CAAC,KAAK,CAAC,YAAY,CAAC,SAAS,GAAG;;EAmT1E"}