tungsten 0.5.7 → 0.5.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.
- package/dist/.build-complete +1 -1
- package/dist/Instance/Instance.d.ts +6 -2
- package/dist/Instance/Instance.d.ts.map +1 -1
- package/dist/Instance/Instance.js +19 -12
- package/dist/Store/InternalStoreSchema.d.ts +1 -1
- package/dist/Store/InternalStoreSchema.d.ts.map +1 -1
- package/dist/components/Link.d.ts.map +1 -1
- package/dist/components/Link.js +1 -2
- package/dist/hydrate/hydrate.d.ts.map +1 -1
- package/dist/hydrate/hydrate.js +3 -1
- package/dist/routing/RouteTypes.d.ts +0 -2
- package/dist/routing/RouteTypes.d.ts.map +1 -1
- package/dist/routing/RouteTypes.js +0 -3
- package/dist/routing/routeUrl.d.ts +4 -0
- package/dist/routing/routeUrl.d.ts.map +1 -0
- package/dist/routing/routeUrl.js +23 -0
- package/dist/staticGen/staticGenFunctions.d.ts.map +1 -1
- package/dist/staticGen/staticGenFunctions.js +2 -4
- package/dist/testing/host.js +3 -1
- package/dist/testing/testingComponentPackage.d.ts.map +1 -1
- package/dist/testing/testingComponentPackage.js +12 -0
- package/package.json +5 -5
- package/vendor/manifest.json +2 -2
package/dist/.build-complete
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
1789636071115
|
|
@@ -9,7 +9,7 @@ import type { MatchedRouteInfo } from '../Servers/MatchedRouteInfo.js';
|
|
|
9
9
|
import type { Routes } from '../routing/Routes.js';
|
|
10
10
|
import type { RedirectCode } from '../routing/RedirectCode.js';
|
|
11
11
|
import type { ClientRuntimeContext } from './ClientRuntimeContext.js';
|
|
12
|
-
import {
|
|
12
|
+
import type { RouteKey } from '../routing/RouteTypes.js';
|
|
13
13
|
type DisposableComponent = {
|
|
14
14
|
__delete: () => void;
|
|
15
15
|
__deleted: () => void;
|
|
@@ -36,9 +36,13 @@ export declare class Instance {
|
|
|
36
36
|
runtimeContext: ClientRuntimeContext | undefined;
|
|
37
37
|
registeredComponents: DisposableComponent[];
|
|
38
38
|
constructor(location: string, instanceConfig: InstanceConfig, reqRes: ReqRes | null, appRoutes: AppRoutes, routes: Routes, internalStore: TrueStore<InternalStoreSchema>, stores: TrueStore<any>[], storeSubscriptions: StoreSubscriptionsMap, globalData: GlobalData, matchedRouteInfo: MatchedRouteInfo, runtimeContext?: ClientRuntimeContext);
|
|
39
|
+
routeKeyToUrl: (routeKey: RouteKey) => string;
|
|
40
|
+
urlToRouteKey: (pathname: string) => RouteKey;
|
|
39
41
|
getRoutes: () => Routes;
|
|
40
42
|
updateLocation: (location: string) => void;
|
|
41
|
-
goto: (routeKey: RouteKey
|
|
43
|
+
goto: (routeKey: RouteKey, { pushHistory }?: {
|
|
44
|
+
pushHistory?: boolean;
|
|
45
|
+
}) => Promise<void>;
|
|
42
46
|
redirect: (url: string, code?: RedirectCode) => void;
|
|
43
47
|
setDefaultTitle: (defaultTitle: string) => void;
|
|
44
48
|
setTitle: (title: string) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Instance.d.ts","sourceRoot":"","sources":["../../src/Instance/Instance.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4CAA4C,CAAA;AAEvF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACzD,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;AAClE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAA;AAC1E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AACtE,OAAO,KAAK,EAAE,MAAM,EAAE,M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,UAIxB;IACD,iBAAiB,aAEhB;IAKD,WAAW,GAAI,WAAW,MAAM,GAAG;QAC/B,QAAQ,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAA;QAChC,gBAAgB,CAAC,EAAE,OAAO,CAAA;KAC7B,aAYA;IAED,SAAS,GAAI,MAAM,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EAAE,aAAa,MAAM,aAKjE;IAED,SAAS,GAAI,MAAM,MAAM,OAAO,EAAE,aAAa,MAAM,UAIpD;IAED,iBAAiB,GAAI,WAAW,mBAAmB,UAElD;IAED,mBAAmB,GAAI,WAAW,mBAAmB,UAGpD;IAED,2BAA2B,aAM1B;CACJ;AAID,wBAAgB,cAAc,CAC1B,IAAI,EAAE,MAAM,OAAO,EACnB,WAAW,EAAE,MAAM,EACnB,MAAM,GAAE,CAAC,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,KAAK,IAA6B,QAejF"}
|
|
@@ -4,8 +4,7 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
4
4
|
import { isClient } from '../isClient.js';
|
|
5
5
|
import { routing } from "../Servers/routing.js";
|
|
6
6
|
import { RoutingRedirect } from '../routing/RoutingRedirect.js';
|
|
7
|
-
import {
|
|
8
|
-
import { StringIsValidRouteKey } from '../routing/RouteTypes.js';
|
|
7
|
+
import { routeKeyToUrl, urlToRouteKey } from '../routing/routeUrl.js';
|
|
9
8
|
import { isProd } from '../isProd.js';
|
|
10
9
|
import { WebRedirect } from '../routing/WebRedirect.js';
|
|
11
10
|
import { RouteRedirectComponent } from "../components/RouteRedirectComponent.js";
|
|
@@ -43,6 +42,14 @@ export class Instance {
|
|
|
43
42
|
_defineProperty(this, "navigating", false);
|
|
44
43
|
_defineProperty(this, "runtimeContext", void 0);
|
|
45
44
|
_defineProperty(this, "registeredComponents", []);
|
|
45
|
+
_defineProperty(this, "routeKeyToUrl", routeKey => {
|
|
46
|
+
return routeKeyToUrl(routeKey, this.config.siteBasePath, isProd && this.config.staticSite);
|
|
47
|
+
});
|
|
48
|
+
// unchecked: goto's routing() does the pattern matching and 404 fallback
|
|
49
|
+
_defineProperty(this, "urlToRouteKey", pathname => {
|
|
50
|
+
const routeKey = urlToRouteKey(pathname, this.config.siteBasePath, isProd && this.config.staticSite);
|
|
51
|
+
return routeKey; // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion
|
|
52
|
+
});
|
|
46
53
|
_defineProperty(this, "getRoutes", () => {
|
|
47
54
|
return typeof this.appRoutes === 'function' ? this.appRoutes(this.reqRes) : this.appRoutes;
|
|
48
55
|
});
|
|
@@ -53,7 +60,9 @@ export class Instance {
|
|
|
53
60
|
this.location = location;
|
|
54
61
|
this.internalStore.location.set(location);
|
|
55
62
|
});
|
|
56
|
-
_defineProperty(this, "goto", async routeKey
|
|
63
|
+
_defineProperty(this, "goto", async (routeKey, {
|
|
64
|
+
pushHistory = true
|
|
65
|
+
} = {}) => {
|
|
57
66
|
// get route data
|
|
58
67
|
this.navigating = true;
|
|
59
68
|
let matchedRouteInfo;
|
|
@@ -110,11 +119,9 @@ export class Instance {
|
|
|
110
119
|
//console.log('location', location)
|
|
111
120
|
//console.log('final dest', this.config.siteBasePath + location)
|
|
112
121
|
this.matchedRouteInfo = matchedRouteInfo;
|
|
113
|
-
|
|
114
|
-
? routeKey === '/' ? '/' : routeKey + '.html' : routeKey;
|
|
115
|
-
if (isClient) {
|
|
122
|
+
if (isClient && pushHistory) {
|
|
116
123
|
const runtimeWindow = this.runtimeContext?.window ?? window;
|
|
117
|
-
runtimeWindow.history.pushState(null, '', this.
|
|
124
|
+
runtimeWindow.history.pushState(null, '', this.routeKeyToUrl(routeKey));
|
|
118
125
|
}
|
|
119
126
|
this.setTitleToDefault();
|
|
120
127
|
this.updateLocation(routeKey); // this.internalStore.set('location', to)
|
|
@@ -201,17 +208,17 @@ export class Instance {
|
|
|
201
208
|
this.config = instanceConfig; // createInstanceConfig(appConfig)
|
|
202
209
|
this.persistentHeadChildren = [];
|
|
203
210
|
this.runtimeContext = runtimeContext;
|
|
211
|
+
// handle back button navigation?
|
|
204
212
|
//if (AppClass === null) throwError('Instance', 'AppClass is null, did you register an '
|
|
205
213
|
if (isClient && (runtimeContext?.navigation ?? true)) {
|
|
206
214
|
const runtimeWindow = runtimeContext?.window ?? window;
|
|
207
215
|
runtimeWindow.addEventListener('popstate', event => {
|
|
208
216
|
//console.log('popstate', window.location.pathname)
|
|
209
217
|
//this.updateLocation(window.location.pathname)
|
|
210
|
-
const newLocation = runtimeWindow.location.pathname;
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
}
|
|
214
|
-
this.goto(newLocation); // This should be a RouteKey, if everything worked? But it's still a bit dangerous
|
|
218
|
+
const newLocation = this.urlToRouteKey(runtimeWindow.location.pathname);
|
|
219
|
+
void this.goto(newLocation, {
|
|
220
|
+
pushHistory: false
|
|
221
|
+
});
|
|
215
222
|
});
|
|
216
223
|
}
|
|
217
224
|
}
|
|
@@ -6,5 +6,5 @@ export declare class InternalStoreSchema {
|
|
|
6
6
|
popMessages: PopMessage[];
|
|
7
7
|
constructor(location: string, matchedRouteInfo: MatchedRouteInfo);
|
|
8
8
|
}
|
|
9
|
-
export type PartialInternalStoreSchema = Pick<InternalStoreSchema, '
|
|
9
|
+
export type PartialInternalStoreSchema = Pick<InternalStoreSchema, 'popMessages'> & Partial<Omit<InternalStoreSchema, 'popMessages'>>;
|
|
10
10
|
//# sourceMappingURL=InternalStoreSchema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InternalStoreSchema.d.ts","sourceRoot":"","sources":["../../src/Store/InternalStoreSchema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAGvD,qBAAa,mBAAmB;IAC5B,QAAQ,EAAE,MAAM,CAAA;IAChB,gBAAgB,EAAE,gBAAgB,CAAA;IAClC,WAAW,EAAE,UAAU,EAAE,CAAK;gBAClB,QAAQ,EAAE,MAAM,EAAE,gBAAgB,EAAE,gBAAgB;CAInE;AAGD,MAAM,MAAM,0BAA0B,GAChC,IAAI,CAAC,mBAAmB,EAAE,
|
|
1
|
+
{"version":3,"file":"InternalStoreSchema.d.ts","sourceRoot":"","sources":["../../src/Store/InternalStoreSchema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAGvD,qBAAa,mBAAmB;IAC5B,QAAQ,EAAE,MAAM,CAAA;IAChB,gBAAgB,EAAE,gBAAgB,CAAA;IAClC,WAAW,EAAE,UAAU,EAAE,CAAK;gBAClB,QAAQ,EAAE,MAAM,EAAE,gBAAgB,EAAE,gBAAgB;CAInE;AAGD,MAAM,MAAM,0BAA0B,GAChC,IAAI,CAAC,mBAAmB,EAAE,aAAa,CAAC,GACxC,OAAO,CAAC,IAAI,CAAC,mBAAmB,EAAE,aAAa,CAAC,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Link.d.ts","sourceRoot":"","sources":["../../src/components/Link.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"Link.d.ts","sourceRoot":"","sources":["../../src/components/Link.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAA;AAG3D,MAAM,MAAM,SAAS,GAAG;IACpB,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC9B,EAAE,EAAE,IAAI,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,WAAW,CAAA;CACxB,CAAA;AAED,qBAAa,IAAK,SAAQ,uBAAuB,CAAC,SAAS,CAAC;IACxD,IAAI,SAA+C;IACnD,KAAK,GAAI,OAAO,gBAAgB,UAgB/B;IACD,OAAO,uDAUN;CACJ"}
|
package/dist/components/Link.js
CHANGED
|
@@ -2,12 +2,11 @@ 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
|
import { TungstenSimpleComponent } from "../Components.js";
|
|
5
|
-
import { isProd } from '../isProd.js';
|
|
6
5
|
import { jsx as _jsx } from "tungsten/jsx-runtime";
|
|
7
6
|
export class Link extends TungstenSimpleComponent {
|
|
8
7
|
constructor(...args) {
|
|
9
8
|
super(...args);
|
|
10
|
-
_defineProperty(this, "href",
|
|
9
|
+
_defineProperty(this, "href", this.__instance.routeKeyToUrl(this.props.to));
|
|
11
10
|
_defineProperty(this, "click", (event /* Event */) => {
|
|
12
11
|
// GUARD if control key is pressed, allow the link to be opened in a new tab
|
|
13
12
|
// should this only apply on chrome?
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hydrate.d.ts","sourceRoot":"","sources":["../../src/hydrate/hydrate.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AAQnE,OAAO,KAAK,EAAE,SAAS,E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,MAAM,EAAE,MAAM,CAAC,EACpC,SAAS,CAAC,EAAE,OAAO,GACpB,OAAO,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC,CA6DtC"}
|
package/dist/hydrate/hydrate.js
CHANGED
|
@@ -27,6 +27,8 @@ import { checkedValueToBoolean } from '../checkedValueToBoolean.js';
|
|
|
27
27
|
import { Default404 } from "../routing/Default404.js";
|
|
28
28
|
import { MatchedRoute } from '../routing/MatchedRoute.js';
|
|
29
29
|
import { isDev } from '../isDev.js';
|
|
30
|
+
import { isProd } from '../isProd.js';
|
|
31
|
+
import { urlToRouteKey } from '../routing/routeUrl.js';
|
|
30
32
|
import { warn } from '../appOutput.js';
|
|
31
33
|
import { reconcileHydratedAttributes } from './reconcileHydratedAttributes.js';
|
|
32
34
|
import { markOptionSelected } from '../markOptionSelected.js';
|
|
@@ -58,7 +60,7 @@ export async function hydrate(appRoutes, RootComponent, instanceConfig) {
|
|
|
58
60
|
// happens next (a read of its value throws below). Rendered again at the end, for the count.
|
|
59
61
|
if (isDev) renderDocInitErrorBanner();
|
|
60
62
|
//console.log('hydration global data ', __tungsten_global_data__)
|
|
61
|
-
const location = window.location.pathname;
|
|
63
|
+
const location = urlToRouteKey(window.location.pathname, instanceConfig.siteBasePath, isProd && instanceConfig.staticSite);
|
|
62
64
|
const routes = typeof appRoutes === 'function' ? appRoutes(null) : appRoutes;
|
|
63
65
|
const matchedRouteInfo = hydrationRouting(__tungsten_matched_route_info__, routes);
|
|
64
66
|
const globalData = __tungsten_global_data__;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Routes } from './Routes.js';
|
|
2
1
|
import type { RouteDataFunction } from './RouteDataFunction.type.js';
|
|
3
2
|
import type { ContentNode } from '../ContentNode.js';
|
|
4
3
|
import type { RouteContentFunction } from './RouteContentFunction.js';
|
|
@@ -13,7 +12,6 @@ export type Route = Endpoint<object, unknown> & {
|
|
|
13
12
|
export type Path = `/${string}`;
|
|
14
13
|
export type SpecialRoute = 'default' | '404' | 'error';
|
|
15
14
|
export type RouteKey = Path | SpecialRoute;
|
|
16
|
-
export declare function StringIsValidRouteKey(string: string, routes: Routes): string is RouteKey;
|
|
17
15
|
export declare function StringIsPath(string: string): string is Path;
|
|
18
16
|
export declare function RouteKeyIsPath(path: RouteKey): path is Path;
|
|
19
17
|
//# sourceMappingURL=RouteTypes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RouteTypes.d.ts","sourceRoot":"","sources":["../../src/routing/RouteTypes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"RouteTypes.d.ts","sourceRoot":"","sources":["../../src/routing/RouteTypes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAA;AACpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAGrE,MAAM,MAAM,QAAQ,CAAC,MAAM,SAAS,MAAM,EAAE,QAAQ,IAAI;IACpD,IAAI,CAAC,EAAE,iBAAiB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;IAC1C,OAAO,EAAE,WAAW,GAAG,oBAAoB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;CAChE,CAAA;AAGD,MAAM,MAAM,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAA;AAE1E,MAAM,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;KAC3C,CAAC,IAAI,MAAM,CAAC,CAAC,EAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CAC5C,CAAA;AAED,MAAM,MAAM,IAAI,GAAG,IAAI,MAAM,EAAE,CAAA;AAC/B,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,KAAK,GAAG,OAAO,CAAA;AACtD,MAAM,MAAM,QAAQ,GAAG,IAAI,GAAG,YAAY,CAAA;AAE1C,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,IAAI,IAAI,CAE3D;AACD,wBAAgB,cAAc,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,IAAI,IAAI,CAE3D"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { SiteBasePath } from '../render/HeadData.js';
|
|
2
|
+
export declare function routeKeyToUrl(routeKey: string, siteBasePath: SiteBasePath, staticFiles: boolean): string;
|
|
3
|
+
export declare function urlToRouteKey(pathname: string, siteBasePath: SiteBasePath, staticFiles: boolean): string;
|
|
4
|
+
//# sourceMappingURL=routeUrl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routeUrl.d.ts","sourceRoot":"","sources":["../../src/routing/routeUrl.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAOzD,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,OAAO,GAAG,MAAM,CASxG;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,OAAO,GAAG,MAAM,CAWxG"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// staticFiles: the site is served as generated .html files (a prod static site)
|
|
2
|
+
const trimBase = siteBasePath => siteBasePath.replace(/\/$/, '');
|
|
3
|
+
export function routeKeyToUrl(routeKey, siteBasePath, staticFiles) {
|
|
4
|
+
const base = trimBase(siteBasePath);
|
|
5
|
+
if (!staticFiles) return base + routeKey;
|
|
6
|
+
const suffixIndex = routeKey.search(/[?#]/);
|
|
7
|
+
const path = suffixIndex === -1 ? routeKey : routeKey.slice(0, suffixIndex);
|
|
8
|
+
const suffix = suffixIndex === -1 ? '' : routeKey.slice(suffixIndex);
|
|
9
|
+
// a directory route links to the directory; the host serves its index.html
|
|
10
|
+
const file = path.endsWith('/') ? path : path + '.html';
|
|
11
|
+
return base + file + suffix;
|
|
12
|
+
}
|
|
13
|
+
export function urlToRouteKey(pathname, siteBasePath, staticFiles) {
|
|
14
|
+
const base = trimBase(siteBasePath);
|
|
15
|
+
let path = pathname;
|
|
16
|
+
if (base !== '' && (path === base || path.startsWith(base + '/'))) {
|
|
17
|
+
path = path.slice(base.length) || '/';
|
|
18
|
+
}
|
|
19
|
+
if (staticFiles) {
|
|
20
|
+
if (path.endsWith('/index.html')) path = path.slice(0, -'index.html'.length);else if (path.endsWith('.html')) path = path.slice(0, -'.html'.length);
|
|
21
|
+
}
|
|
22
|
+
return path;
|
|
23
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"staticGenFunctions.d.ts","sourceRoot":"","sources":["../../src/staticGen/staticGenFunctions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,IAAI,YAAY,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"staticGenFunctions.d.ts","sourceRoot":"","sources":["../../src/staticGen/staticGenFunctions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,IAAI,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAIzE,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,UAM1C;AACD,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,UAElE;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAQnD;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,UAM/E"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { routeKeyToUrl } from '../routing/routeUrl.js';
|
|
1
2
|
export function pathToFileName(path) {
|
|
2
3
|
// Is this good?
|
|
3
4
|
// /foo/ becomes /foo/index.html
|
|
@@ -5,10 +6,7 @@ export function pathToFileName(path) {
|
|
|
5
6
|
if (path.endsWith('/')) return path + 'index.html';else return path + '.html';
|
|
6
7
|
}
|
|
7
8
|
export function pathToLink(path, siteBasePath) {
|
|
8
|
-
|
|
9
|
-
// /foo/ becomes /foo/index.html
|
|
10
|
-
// seems like a bodge
|
|
11
|
-
if (path.endsWith('/')) return siteBasePath + path + 'index.html';else return siteBasePath + path + '.html';
|
|
9
|
+
return routeKeyToUrl(path, siteBasePath, true);
|
|
12
10
|
}
|
|
13
11
|
export function findLinks(content) {
|
|
14
12
|
const matches = [...content.matchAll(/href="(.+?)"/g)].map(x => {
|
package/dist/testing/host.js
CHANGED
|
@@ -37,7 +37,9 @@ async function hostedRouting(options) {
|
|
|
37
37
|
return {
|
|
38
38
|
routes: options.routes,
|
|
39
39
|
internalStore: {
|
|
40
|
-
location
|
|
40
|
+
...(location !== undefined ? {
|
|
41
|
+
location
|
|
42
|
+
} : {}),
|
|
41
43
|
...(matchedRouteInfo !== undefined ? {
|
|
42
44
|
matchedRouteInfo
|
|
43
45
|
} : {}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testingComponentPackage.d.ts","sourceRoot":"","sources":["../../src/testing/testingComponentPackage.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AACnE,OAAO,KAAK,EAAuB,0BAA0B,EAAE,MAAM,iCAAiC,CAAA;AACtG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAA;AAElE,OAAO,EAAE,cAAc,EAAE,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version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K;CACjB,CAAA;AAuBF,eAAO,MAAM,uBAAuB,GAAI,KAAK,SAAS,MAAM,EACxD,OAAO,KAAK,EACZ,UAAS,8BAAmC,KAC7C,gBAAgB,CAAC,KAAK,EAAE,SAAS,CA6ClC,CAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { $trueStoreCell } from '../Store/makeStore.js';
|
|
2
|
+
import { routeKeyToUrl } from '../routing/routeUrl.js';
|
|
2
3
|
const missing = key => {
|
|
3
4
|
throw new Error(`testingComponentPackage: no ${key} supplied. Pass one in the options if the value is part` + ` of the test, or use createTestApp() for a component that needs a real app.`);
|
|
4
5
|
};
|
|
@@ -88,6 +89,17 @@ export const testingComponentPackage = (props, options = {}) => ({
|
|
|
88
89
|
redirect: options.redirect ?? (to => {
|
|
89
90
|
missing(`redirect (component redirected to '${to}')`);
|
|
90
91
|
}),
|
|
92
|
+
routeKeyToUrl: routeKey => {
|
|
93
|
+
const {
|
|
94
|
+
siteBasePath,
|
|
95
|
+
prod,
|
|
96
|
+
staticSite
|
|
97
|
+
} = {
|
|
98
|
+
...defaultConfig,
|
|
99
|
+
...options.config
|
|
100
|
+
};
|
|
101
|
+
return routeKeyToUrl(routeKey, siteBasePath, prod && staticSite);
|
|
102
|
+
},
|
|
91
103
|
...(options.trackWork !== undefined ? {
|
|
92
104
|
trackWork: options.trackWork
|
|
93
105
|
} : {})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tungsten",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.9",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"npm-run-all": "^4.1.5",
|
|
95
95
|
"rimraf": "^5.0.10",
|
|
96
96
|
"rollup-plugin-visualizer": "^5.14.0",
|
|
97
|
-
"sxy-test-runner": "^2.4.
|
|
97
|
+
"sxy-test-runner": "^2.4.17",
|
|
98
98
|
"typescript": "^6.0.3",
|
|
99
99
|
"typescript-eslint": "^8.70.0"
|
|
100
100
|
},
|
|
@@ -120,13 +120,13 @@
|
|
|
120
120
|
"__build": "pnpm clean && pnpm build-prep && pnpm build-watch",
|
|
121
121
|
"build": "run-s -c clean build-prep build-watch",
|
|
122
122
|
"clean": "rimraf intermed dist",
|
|
123
|
+
"build-prep": "pnpm build-ts-once",
|
|
124
|
+
"build-watch": "run-p build-ts build-babel",
|
|
125
|
+
"build-quick": "pnpm build-watch",
|
|
123
126
|
"build-once": "rimraf intermed dist && pnpm build-ts-once && pnpm build-babel-once && pnpm build-component-styles",
|
|
124
127
|
"build-component-styles": "node scripts/buildComponentStyles.ts",
|
|
125
128
|
"build-vendor": "node scripts/bundleVendor.ts",
|
|
126
129
|
"build-once-nd": "rimraf intermed dist.building && pnpm build-ts-once && pnpm build-babel-staged && node scripts/syncDist.ts && node scripts/writeBuildMarker.ts",
|
|
127
|
-
"build-quick": "pnpm build-watch",
|
|
128
|
-
"build-prep": "pnpm build-ts-once",
|
|
129
|
-
"build-watch": "run-p build-ts build-babel",
|
|
130
130
|
"build-ts": "tscmon",
|
|
131
131
|
"build-ts-once": "tsc",
|
|
132
132
|
"build-babel": "node scripts/watchBabelAndMark.ts",
|