tungsten 0.3.7 → 0.3.9

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.
@@ -1 +1 @@
1
- 1786060222778
1
+ 1786138356533
@@ -3,7 +3,6 @@ import express from 'express';
3
3
  import { FrameworkConfigComplete } from 'tungsten/FrameworkConfig.js';
4
4
  export declare class StaticSiteServer {
5
5
  config: FrameworkConfigComplete;
6
- port: number;
7
6
  location?: string;
8
7
  app: express.Application;
9
8
  server?: Server;
@@ -1 +1 @@
1
- {"version":3,"file":"StaticSiteServer.d.ts","sourceRoot":"","sources":["../../src/Servers/StaticSiteServer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAClC,OAAO,OAAO,MAAM,SAAS,CAAA;AAK7B,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAA;AAErE,qBAAa,gBAAgB;IACzB,MAAM,EAAE,uBAAuB,CAAA;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,GAAG,EAAE,OAAO,CAAC,WAAW,CAAA;IACxB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,kBAAkB,EAAE,MAAM,CAAA;gBAEd,MAAM,EAAE,uBAAuB;IAa3C,KAAK,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAQ3B;IACD,IAAI,aAEH;CACJ"}
1
+ {"version":3,"file":"StaticSiteServer.d.ts","sourceRoot":"","sources":["../../src/Servers/StaticSiteServer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAClC,OAAO,OAAO,MAAM,SAAS,CAAA;AAK7B,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAA;AAGrE,qBAAa,gBAAgB;IACzB,MAAM,EAAE,uBAAuB,CAAA;IAE/B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,GAAG,EAAE,OAAO,CAAC,WAAW,CAAA;IACxB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,kBAAkB,EAAE,MAAM,CAAA;gBAEd,MAAM,EAAE,uBAAuB;IAa3C,KAAK,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAW3B;IACD,IAAI,aAEH;CACJ"}
@@ -9,16 +9,18 @@ export class StaticSiteServer {
9
9
  // to do
10
10
  constructor(config) {
11
11
  _defineProperty(this, "config", void 0);
12
- _defineProperty(this, "port", void 0);
12
+ //port: number
13
13
  _defineProperty(this, "location", void 0);
14
14
  _defineProperty(this, "app", void 0);
15
15
  _defineProperty(this, "server", void 0);
16
16
  _defineProperty(this, "staticSiteLocation", void 0);
17
17
  _defineProperty(this, "start", () => {
18
- const location = this.location = `http://localhost:${this.port}${this.config.siteBasePath}`;
19
18
  return new Promise(resolve => {
20
- this.server = this.app.listen(this.port, () => {
21
- cliNews(`Static preview ready at ${this.location}`);
19
+ const staticSiteServer = this; // eslint-disable-line @typescript-eslint/no-this-alias
20
+ this.server = this.app.listen(0, function () {
21
+ const port = this.address().port; // eslint-disable-line no-type-assertion/no-type-assertion
22
+ const location = staticSiteServer.location = `http://localhost:${port}${staticSiteServer.config.siteBasePath}`;
23
+ cliNews(`Static preview ready at ${location}`);
22
24
  resolve(location);
23
25
  });
24
26
  });
@@ -27,7 +29,7 @@ export class StaticSiteServer {
27
29
  if (this.server !== undefined) this.server.close();
28
30
  });
29
31
  this.config = config;
30
- this.port = 3001;
32
+ //this.port = 3001
31
33
  this.app = express();
32
34
  this.staticSiteLocation = join(process.cwd(), staticSiteFolder);
33
35
  this.app.use(this.config.siteBasePath, express.static(this.staticSiteLocation));
@@ -65,7 +65,9 @@ export async function staticGen(framework) {
65
65
  const finalRoutes = objectFilter(appRoutes, (path, route) => {
66
66
  if (!path.startsWith('/')) {
67
67
  //cliWarn(`Static gen skipping route ${route.path}, because it does not start with /, and is not default or 404`)
68
- cliWarn(`Static gen skipping route ${path}, because it does not start with /`);
68
+ if (!['error', '404', 'default'].includes(path)) {
69
+ cliWarn(`Static gen skipping route ${path}, because it does not start with /`);
70
+ }
69
71
  return false;
70
72
  }
71
73
  if (path.includes(':')) {
@@ -96,6 +98,7 @@ export async function staticGen(framework) {
96
98
  links = findLinks(result);
97
99
  const newPaths = [];
98
100
  for (const link of links) {
101
+ if (link.startsWith('http://') || link.startsWith('https://')) continue; // ignore external links
99
102
  if (link.startsWith('#')) continue; // ignore anchors/hash links
100
103
  if (!StringIsPath(link)) {
101
104
  throwError('renderRoute', `Found a link '${link}' that did not start with /`);
@@ -104,9 +107,6 @@ export async function staticGen(framework) {
104
107
  for (const [path, dynamicRoute] of dynamicRoutes) {
105
108
  if (RouteKeyIsPath(path)) {
106
109
  if (matchPath(path, link)) {
107
- //console.log('link', link)
108
- //console.log('in?', link in rewriteMap)
109
- //console.log(`link ${link} matched dynamic route ${dynamicRoute.path}`)
110
110
  newPaths.push(link);
111
111
  rewriteMap[link] = pathToLink(link, siteBasePath);
112
112
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tungsten",
3
- "version": "0.3.7",
3
+ "version": "0.3.9",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "bin": {