tungsten 0.6.1 → 0.6.3
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/Components.d.ts +12 -8
- package/dist/Components.d.ts.map +1 -1
- package/dist/Components.js +1 -0
- package/dist/Instance/Instance.d.ts +16 -7
- package/dist/Instance/Instance.d.ts.map +1 -1
- package/dist/Instance/Instance.js +116 -68
- package/dist/Servers/DevServer.d.ts.map +1 -1
- package/dist/Servers/DevServer.js +4 -0
- package/dist/Servers/ProdServer.d.ts.map +1 -1
- package/dist/Servers/ProdServer.js +4 -0
- package/dist/Store/InternalStoreSchema.d.ts +12 -1
- package/dist/Store/InternalStoreSchema.d.ts.map +1 -1
- package/dist/Store/InternalStoreSchema.js +2 -0
- package/dist/Store/StoreSubscriptions.types.d.ts +2 -2
- package/dist/Store/StoreSubscriptions.types.d.ts.map +1 -1
- package/dist/Store/getInternalStore.d.ts +3 -3
- package/dist/Store/getInternalStore.d.ts.map +1 -1
- package/dist/Store/makeStore.d.ts +24 -11
- package/dist/Store/makeStore.d.ts.map +1 -1
- package/dist/Store/makeStore.js +27 -23
- package/dist/assert.d.ts +2 -0
- package/dist/assert.d.ts.map +1 -0
- package/dist/assert.js +4 -0
- package/dist/components/Link.d.ts +0 -1
- package/dist/components/Link.d.ts.map +1 -1
- package/dist/components/Link.js +4 -6
- package/dist/hydrate/hydrate.js +2 -2
- package/dist/routing/routeUrl.d.ts +4 -0
- package/dist/routing/routeUrl.d.ts.map +1 -1
- package/dist/routing/routeUrl.js +4 -0
- package/dist/testing/createTestApp.d.ts +12 -0
- package/dist/testing/createTestApp.d.ts.map +1 -1
- package/dist/testing/createTestApp.js +9 -3
- package/dist/testing/host.d.ts.map +1 -1
- package/dist/testing/host.js +3 -3
- package/dist/testing/hydrateTestApp.d.ts +1 -0
- package/dist/testing/hydrateTestApp.d.ts.map +1 -1
- package/dist/testing/hydrateTestApp.js +10 -4
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/testingComponentPackage.d.ts +6 -11
- package/dist/testing/testingComponentPackage.d.ts.map +1 -1
- package/dist/testing/testingComponentPackage.js +20 -23
- package/package.json +1 -1
|
@@ -2,38 +2,51 @@ import type { Key } from '../Key.js';
|
|
|
2
2
|
import type { TungstenBaseStoreComponent } from '../Components.jsx';
|
|
3
3
|
import type { ServerDataLoading } from './ServerDataLoading.js';
|
|
4
4
|
import type { SubscribedElements } from './StoreSubscriptions.types.js';
|
|
5
|
-
export declare const $
|
|
6
|
-
export declare class StoreValueServer<T> {
|
|
5
|
+
export declare const $trueStoreValue: unique symbol;
|
|
6
|
+
export declare class StoreValueServer<T> implements TrueStoreValueInterface<T> {
|
|
7
7
|
#private;
|
|
8
|
-
readonly [$
|
|
8
|
+
readonly [$trueStoreValue] = true;
|
|
9
9
|
constructor(value: T, serverDataLoading: ServerDataLoading);
|
|
10
10
|
readonly get: () => T;
|
|
11
11
|
readonly sync: () => T;
|
|
12
12
|
readonly set: (newValue: T) => void;
|
|
13
13
|
readonly subscribe: () => void;
|
|
14
14
|
readonly unsubscribe: () => void;
|
|
15
|
-
readonly notify: <Fn extends ((value: T) => void)>(fn: Fn) => Fn;
|
|
16
|
-
readonly stopNotify: <Fn extends ((value: T) => void)>(fn: Fn) => Fn;
|
|
15
|
+
readonly notify: <Fn extends ((value: T) => void)>(fn: Fn, element: TungstenBaseStoreComponent<any, any, any>) => Fn;
|
|
16
|
+
readonly stopNotify: <Fn extends ((value: T) => void)>(fn: Fn, element: TungstenBaseStoreComponent<any, any, any>) => Fn;
|
|
17
17
|
readonly stopNotifyAll: () => void;
|
|
18
18
|
}
|
|
19
19
|
export type NotifyFn<T> = (value: T) => void;
|
|
20
|
-
export
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
export interface TrueStoreValueInterface<T> {
|
|
21
|
+
readonly [$trueStoreValue]: true;
|
|
22
|
+
readonly get: () => T;
|
|
23
|
+
readonly sync: (element: TungstenBaseStoreComponent<any, any, any>) => T;
|
|
24
|
+
readonly set: (value: T) => void;
|
|
25
|
+
readonly subscribe: (element: TungstenBaseStoreComponent<any, any, any>) => void;
|
|
26
|
+
readonly unsubscribe: (element: TungstenBaseStoreComponent<any, any, any>) => void;
|
|
27
|
+
readonly notify: <Fn extends NotifyFn<T>>(fn: Fn, element: TungstenBaseStoreComponent<any, any, any>) => Fn;
|
|
28
|
+
readonly stopNotify: <Fn extends NotifyFn<T>>(fn: Fn, element: TungstenBaseStoreComponent<any, any, any>) => Fn;
|
|
29
|
+
readonly stopNotifyAll: (element: TungstenBaseStoreComponent<any, any, any>) => void;
|
|
30
|
+
}
|
|
31
|
+
export type ReadonlyTrueStoreValue<T> = Omit<TrueStoreValueInterface<T>, 'set'>;
|
|
32
|
+
export declare class StoreValue<T> implements TrueStoreValueInterface<T> {
|
|
23
33
|
#private;
|
|
24
|
-
readonly [$
|
|
34
|
+
readonly [$trueStoreValue] = true;
|
|
25
35
|
constructor(key: Key, value: T, subscribedElements: SubscribedElements);
|
|
26
36
|
readonly get: () => T;
|
|
27
37
|
readonly sync: (element: TungstenBaseStoreComponent<any, any, any>) => T;
|
|
28
38
|
readonly set: (newValue: T) => void;
|
|
29
39
|
readonly subscribe: (element: TungstenBaseStoreComponent<any, any, any>) => void;
|
|
30
40
|
readonly unsubscribe: (element: TungstenBaseStoreComponent<any, any, any>) => void;
|
|
31
|
-
readonly notify: <Fn extends ((value: T) => void)>(fn: Fn, element
|
|
32
|
-
readonly stopNotify: <Fn extends ((value: T) => void)>(fn: Fn, element
|
|
41
|
+
readonly notify: <Fn extends ((value: T) => void)>(fn: Fn, element: TungstenBaseStoreComponent<any, any, any>) => Fn;
|
|
42
|
+
readonly stopNotify: <Fn extends ((value: T) => void)>(fn: Fn, element: TungstenBaseStoreComponent<any, any, any>) => Fn;
|
|
33
43
|
readonly stopNotifyAll: (element: TungstenBaseStoreComponent<any, any, any>) => void;
|
|
34
44
|
}
|
|
35
45
|
export type TrueStore<Schema> = {
|
|
36
46
|
[Property in keyof Schema]: StoreValue<Schema[Property]>;
|
|
37
47
|
};
|
|
48
|
+
export type ReadonlyTrueStore<Schema> = {
|
|
49
|
+
[Property in keyof Schema]: ReadonlyTrueStoreValue<Schema[Property]>;
|
|
50
|
+
};
|
|
38
51
|
export declare function makeStore<Schema extends object>(schema: Schema, subscribedElements: SubscribedElements, serverDataLoading?: ServerDataLoading | null): TrueStore<Schema>;
|
|
39
52
|
//# sourceMappingURL=makeStore.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"makeStore.d.ts","sourceRoot":"","sources":["../../src/Store/makeStore.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AACpC,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAA;AACnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAA;
|
|
1
|
+
{"version":3,"file":"makeStore.d.ts","sourceRoot":"","sources":["../../src/Store/makeStore.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AACpC,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAA;AACnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAA;AAUvE,eAAO,MAAM,eAAe,eAA2B,CAAA;AAIvD,qBAAa,gBAAgB,CAAC,CAAC,CAAE,YAAW,uBAAuB,CAAC,CAAC,CAAC;;IAClE,QAAQ,CAAC,CAAC,eAAe,CAAC,QAAO;gBAGrB,KAAK,EAAE,CAAC,EAAE,iBAAiB,EAAE,iBAAiB;IAI1D,QAAQ,CAAC,GAAG,UAA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C,EACjD,IAAI,EAAE,EAAE,SAAS,0BAA0B,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,KAAG,EAAE,CAkB/D;IACD,QAAQ,CAAC,UAAU,GAAI,EAAE,SAAS,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC,EACrD,IAAI,EAAE,EAAE,SAAS,0BAA0B,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,KAAG,EAAE,CAO/D;IACD,QAAQ,CAAC,aAAa,GAAI,SAAS,0BAA0B,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,UAQ3E;CAeJ;AAED,MAAM,MAAM,SAAS,CAAC,MAAM,IAAI;KAC3B,QAAQ,IAAI,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;CAC3D,CAAA;AAGD,MAAM,MAAM,iBAAiB,CAAC,MAAM,IAAI;KACnC,QAAQ,IAAI,MAAM,MAAM,GAAG,sBAAsB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;CACvE,CAAA;AAGD,wBAAgB,SAAS,CAAC,MAAM,SAAS,MAAM,EAC3C,MAAM,EAAE,MAAM,EACd,kBAAkB,EAAE,kBAAkB,EACtC,iBAAiB,GAAE,iBAAiB,GAAG,IAAW,GACnD,SAAS,CAAC,MAAM,CAAC,CAWnB"}
|
package/dist/Store/makeStore.js
CHANGED
|
@@ -7,17 +7,19 @@ function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
|
|
|
7
7
|
function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
|
|
8
8
|
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
|
|
9
9
|
import { objectMap } from '../objectMap.js';
|
|
10
|
+
// type Notify<T> = <Fn extends ((value: T) => void)>(fn: Fn, element: TungstenBaseStoreComponent<any, any, any>) => Fn
|
|
11
|
+
// type StopNotify<T> = Notify<T>
|
|
10
12
|
// Marks a cell as unbound - subscribe takes the component. A ComponentStore's cells are the
|
|
11
13
|
// same objects behind a proxy that binds it, and without this their types would be assignable
|
|
12
14
|
// (a () => void fits an (element) => void), so a bound store could pass for a TrueStore.
|
|
13
|
-
export const $
|
|
15
|
+
export const $trueStoreValue = Symbol('trueStoreValue');
|
|
14
16
|
// the server render is one pass, so nothing re-renders on a write: no subscribers, and subscribe
|
|
15
17
|
// is a no-op that keeps the cell's shape for the component proxy
|
|
16
18
|
var _value = /*#__PURE__*/new WeakMap();
|
|
17
19
|
var _serverDataLoading = /*#__PURE__*/new WeakMap();
|
|
18
20
|
export class StoreValueServer {
|
|
19
21
|
constructor(value, serverDataLoading) {
|
|
20
|
-
_defineProperty(this, $
|
|
22
|
+
_defineProperty(this, $trueStoreValue, true);
|
|
21
23
|
_classPrivateFieldInitSpec(this, _value, void 0);
|
|
22
24
|
_classPrivateFieldInitSpec(this, _serverDataLoading, void 0);
|
|
23
25
|
_defineProperty(this, "get", () => _classPrivateFieldGet(_value, this));
|
|
@@ -36,8 +38,10 @@ export class StoreValueServer {
|
|
|
36
38
|
// do nothing on the server, because nothing continue past first render.
|
|
37
39
|
});
|
|
38
40
|
// no-ops, but they return the function as the client cells do, so a caller can keep the handle
|
|
39
|
-
_defineProperty(this, "notify", fn
|
|
40
|
-
|
|
41
|
+
_defineProperty(this, "notify", (fn, element // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
42
|
+
) => fn);
|
|
43
|
+
_defineProperty(this, "stopNotify", (fn, element // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
44
|
+
) => fn);
|
|
41
45
|
_defineProperty(this, "stopNotifyAll", () => {
|
|
42
46
|
// do nothing on the server, because nothing continue past first render.
|
|
43
47
|
});
|
|
@@ -54,7 +58,7 @@ var _notifyOwners = /*#__PURE__*/new WeakMap();
|
|
|
54
58
|
var _dropOwnerIfDone = /*#__PURE__*/new WeakMap();
|
|
55
59
|
export class StoreValue {
|
|
56
60
|
constructor(key, value, subscribedElements) {
|
|
57
|
-
_defineProperty(this, $
|
|
61
|
+
_defineProperty(this, $trueStoreValue, true);
|
|
58
62
|
/* #store: StoreSchemaClassGeneral */
|
|
59
63
|
_classPrivateFieldInitSpec(this, _key, void 0);
|
|
60
64
|
_classPrivateFieldInitSpec(this, _value2, void 0);
|
|
@@ -104,29 +108,29 @@ export class StoreValue {
|
|
|
104
108
|
});
|
|
105
109
|
_defineProperty(this, "notify", (fn, element) => {
|
|
106
110
|
_classPrivateFieldGet(_notifyFunctions, this).add(fn);
|
|
107
|
-
if (element !== undefined) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
subscriptions.add(_classPrivateFieldGet(_key, this));
|
|
111
|
+
//if (element !== undefined) {
|
|
112
|
+
let owned = _classPrivateFieldGet(_notifyOwners, this).get(element);
|
|
113
|
+
if (owned === undefined) {
|
|
114
|
+
owned = new Set();
|
|
115
|
+
_classPrivateFieldGet(_notifyOwners, this).set(element, owned);
|
|
116
|
+
}
|
|
117
|
+
owned.add(fn);
|
|
118
|
+
// index the key like subscribe does, so teardown visits this cell
|
|
119
|
+
let subscriptions = _classPrivateFieldGet(_subscribedElements, this).get(element);
|
|
120
|
+
if (subscriptions === undefined) {
|
|
121
|
+
subscriptions = new Set();
|
|
122
|
+
_classPrivateFieldGet(_subscribedElements, this).set(element, subscriptions);
|
|
121
123
|
}
|
|
124
|
+
subscriptions.add(_classPrivateFieldGet(_key, this));
|
|
125
|
+
//}
|
|
122
126
|
return fn;
|
|
123
127
|
});
|
|
124
128
|
_defineProperty(this, "stopNotify", (fn, element) => {
|
|
125
129
|
_classPrivateFieldGet(_notifyFunctions, this).delete(fn);
|
|
126
|
-
if (element !== undefined) {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
+
//if (element !== undefined) {
|
|
131
|
+
_classPrivateFieldGet(_notifyOwners, this).get(element)?.delete(fn);
|
|
132
|
+
_classPrivateFieldGet(_dropOwnerIfDone, this).call(this, element);
|
|
133
|
+
//}
|
|
130
134
|
return fn;
|
|
131
135
|
});
|
|
132
136
|
_defineProperty(this, "stopNotifyAll", element => {
|
package/dist/assert.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../src/assert.ts"],"names":[],"mappings":"AAGA,wBAAgB,OAAO,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,QAE1D"}
|
package/dist/assert.js
ADDED
|
@@ -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;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,
|
|
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,KAAK,GAAI,OAAO,gBAAgB,UAiB/B;IACD,OAAO,uDAUN;CACJ"}
|
package/dist/components/Link.js
CHANGED
|
@@ -6,11 +6,9 @@ import { jsx as _jsx } from "tungsten/jsx-runtime";
|
|
|
6
6
|
export class Link extends TungstenSimpleComponent {
|
|
7
7
|
constructor(...args) {
|
|
8
8
|
super(...args);
|
|
9
|
-
_defineProperty(this, "href", this.__instance.routeKeyToUrl(this.props.to));
|
|
10
9
|
_defineProperty(this, "click", (event /* Event */) => {
|
|
11
|
-
// GUARD
|
|
12
|
-
|
|
13
|
-
if (event.ctrlKey) return;
|
|
10
|
+
// GUARD a modified or non-primary click is the browser's: new tab, new window, download
|
|
11
|
+
if (event.button !== 0 || event.ctrlKey || event.metaKey || event.shiftKey || event.altKey) return;
|
|
14
12
|
// GUARD don't do anything if clientSideNavigation is disabled
|
|
15
13
|
if (!this.__instance.config.clientSideNav) return;
|
|
16
14
|
//if (this.__instance.config.staticSite) return // temporarily disable this on static sites
|
|
@@ -21,12 +19,12 @@ export class Link extends TungstenSimpleComponent {
|
|
|
21
19
|
// ? '/'
|
|
22
20
|
// : `${to}.html`
|
|
23
21
|
//console.log('go to', to)
|
|
24
|
-
this.__instance.goto(to);
|
|
22
|
+
void this.__instance.goto(to);
|
|
25
23
|
});
|
|
26
24
|
_defineProperty(this, "content", () => {
|
|
27
25
|
return _jsx("a", {
|
|
28
26
|
className: this.props.className,
|
|
29
|
-
href: this.
|
|
27
|
+
href: this.__instance.routeKeyToUrl(this.props.to),
|
|
30
28
|
onClick: this.click,
|
|
31
29
|
children: this.props.children
|
|
32
30
|
});
|
package/dist/hydrate/hydrate.js
CHANGED
|
@@ -28,7 +28,7 @@ import { Default404 } from "../routing/Default404.js";
|
|
|
28
28
|
import { MatchedRoute } from '../routing/MatchedRoute.js';
|
|
29
29
|
import { isDev } from '../isDev.js';
|
|
30
30
|
import { isProd } from '../isProd.js';
|
|
31
|
-
import {
|
|
31
|
+
import { urlToLocation } from '../routing/routeUrl.js';
|
|
32
32
|
import { warn } from '../appOutput.js';
|
|
33
33
|
import { reconcileHydratedAttributes } from './reconcileHydratedAttributes.js';
|
|
34
34
|
import { markOptionSelected } from '../markOptionSelected.js';
|
|
@@ -60,7 +60,7 @@ export async function hydrate(appRoutes, RootComponent, instanceConfig) {
|
|
|
60
60
|
// happens next (a read of its value throws below). Rendered again at the end, for the count.
|
|
61
61
|
if (isDev) renderDocInitErrorBanner();
|
|
62
62
|
//console.log('hydration global data ', __tungsten_global_data__)
|
|
63
|
-
const location =
|
|
63
|
+
const location = urlToLocation(window.location, instanceConfig.siteBasePath, isProd && instanceConfig.staticSite);
|
|
64
64
|
const routes = typeof appRoutes === 'function' ? appRoutes(null) : appRoutes;
|
|
65
65
|
const matchedRouteInfo = hydrationRouting(__tungsten_matched_route_info__, routes);
|
|
66
66
|
const globalData = __tungsten_global_data__;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import type { SiteBasePath } from '../render/HeadData.js';
|
|
2
2
|
export declare function routeKeyToUrl(routeKey: string, siteBasePath: SiteBasePath, staticFiles: boolean): string;
|
|
3
3
|
export declare function urlToRouteKey(pathname: string, siteBasePath: SiteBasePath, staticFiles: boolean): string;
|
|
4
|
+
export declare function urlToLocation(url: {
|
|
5
|
+
pathname: string;
|
|
6
|
+
search: string;
|
|
7
|
+
}, siteBasePath: SiteBasePath, staticFiles: boolean): string;
|
|
4
8
|
//# sourceMappingURL=routeUrl.d.ts.map
|
|
@@ -1 +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"}
|
|
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;AAGD,wBAAgB,aAAa,CACzB,GAAG,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,OAAO,GAC5F,MAAM,CAER"}
|
package/dist/routing/routeUrl.js
CHANGED
|
@@ -20,4 +20,8 @@ export function urlToRouteKey(pathname, siteBasePath, staticFiles) {
|
|
|
20
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
21
|
}
|
|
22
22
|
return path;
|
|
23
|
+
}
|
|
24
|
+
// the app's location for a browser URL: route path plus query, as the server sees it (no fragment)
|
|
25
|
+
export function urlToLocation(url, siteBasePath, staticFiles) {
|
|
26
|
+
return urlToRouteKey(url.pathname, siteBasePath, staticFiles) + url.search;
|
|
23
27
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { ConstructPackage, TungstenBaseComponent, TungstenBaseComponentType, TungstenComponentPropsBase } from '../Components.jsx';
|
|
2
2
|
import type { TrueStore } from '../Store/makeStore.js';
|
|
3
|
+
import type { Endpoint, Path } from '../routing/RouteTypes.js';
|
|
4
|
+
import type { ErrorRouteType } from '../routing/ErrorRouteType.js';
|
|
5
|
+
import type { ReqRes } from '../ReqRes.js';
|
|
3
6
|
export type ComponentProps<ComponentType extends TungstenBaseComponentType<any, any>> = InstanceType<ComponentType>['props'];
|
|
4
7
|
export type TestStoreRegistration<Schema extends object> = {
|
|
5
8
|
getStore: (stores: TrueStore<unknown>[]) => TrueStore<Schema>;
|
|
@@ -19,6 +22,14 @@ export type TestAppOptions<Props extends object> = {
|
|
|
19
22
|
routeData?: unknown;
|
|
20
23
|
globalData?: Record<string, unknown>;
|
|
21
24
|
stores?: readonly TestStoreOverride<any>[];
|
|
25
|
+
routes?: TestRoutes | ((reqRes: ReqRes | null) => TestRoutes);
|
|
26
|
+
};
|
|
27
|
+
export type TestRoutes = {
|
|
28
|
+
[key in Path]: Endpoint<any, any>;
|
|
29
|
+
} & {
|
|
30
|
+
'404'?: Endpoint<any, any>;
|
|
31
|
+
'default'?: Endpoint<any, any>;
|
|
32
|
+
'error'?: ErrorRouteType;
|
|
22
33
|
};
|
|
23
34
|
export type TestApp<Component extends TungstenBaseComponent> = {
|
|
24
35
|
readonly document: Document;
|
|
@@ -27,6 +38,7 @@ export type TestApp<Component extends TungstenBaseComponent> = {
|
|
|
27
38
|
resolved(): Promise<void>;
|
|
28
39
|
setProps(props: Component['props']): Promise<void>;
|
|
29
40
|
unmount(): Promise<void>;
|
|
41
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
30
42
|
};
|
|
31
43
|
export type CreateTestAppArgs<Props extends object> = object extends Props ? [options?: TestAppOptions<Props>] : keyof Props extends never ? [options?: TestAppOptions<Props>] : [options: TestAppOptions<Props> & {
|
|
32
44
|
props: Props;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTestApp.d.ts","sourceRoot":"","sources":["../../src/testing/createTestApp.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACR,gBAAgB,EAChB,qBAAqB,EACrB,yBAAyB,EACzB,0BAA0B,EAC7B,MAAM,mBAAmB,CAAA;AAI1B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"createTestApp.d.ts","sourceRoot":"","sources":["../../src/testing/createTestApp.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACR,gBAAgB,EAChB,qBAAqB,EACrB,yBAAyB,EACzB,0BAA0B,EAC7B,MAAM,mBAAmB,CAAA;AAI1B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEtD,OAAO,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAClE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAa1C,MAAM,MAAM,cAAc,CACtB,aAAa,SAAS,yBAAyB,CAAC,GAAG,EAAE,GAAG,CAAC,IACzD,YAAY,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,CAAA;AAExC,MAAM,MAAM,qBAAqB,CAAC,MAAM,SAAS,MAAM,IAAI;IACvD,QAAQ,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC,OAAO,CAAC,EAAE,KAAK,SAAS,CAAC,MAAM,CAAC,CAAA;CAChE,CAAA;AAED,MAAM,MAAM,SAAS,CAAC,MAAM,SAAS,MAAM,IAAI,SAAS,CAAC,MAAM,CAAC,CAAA;AAEhE,MAAM,MAAM,iBAAiB,CAAC,MAAM,SAAS,MAAM,GAAG,MAAM,IAAI;IAC5D,YAAY,EAAE,qBAAqB,CAAC,MAAM,CAAC,CAAA;IAC3C,UAAU,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC,MAAM,CAA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E,QAAQ,CAAA;IAC3B,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAA;IAC/B,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAA;IAE7B,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IACzB,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAClD,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IAExB,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CACzC,CAAA;AAED,MAAM,MAAM,iBAAiB,CAAC,KAAK,SAAS,MAAM,IAAI,MAAM,SAAS,KAAK,GACpE,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC,KAAK,CAAC,CAAC,GACjC,MAAM,KAAK,SAAS,KAAK,GACrB,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC,KAAK,CAAC,CAAC,GACjC,CAAC,OAAO,EAAE,cAAc,CAAC,KAAK,CAAC,GAAG;IAAE,KAAK,EAAE,KAAK,CAAA;CAAE,CAAC,CAAA;AAyE7D,wBAAsB,aAAa,CAC/B,KAAK,SAAS,0BAA0B,EACxC,SAAS,SAAS,qBAAqB,CAAC,GAAG,EAAE,GAAG,CAAC,EACjD,SAAS,GAAG,SAAS,EAGrB,aAAa,EAAE,KAAK,GAAG,EAAE,gBAAgB,CAAC,KAAK,EAAE,SAAS,CAAC,KAAK,SAAS,EACzE,GAAG,IAAI,EAAE,iBAAiB,CAAC,KAAK,CAAC,GAClC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAwH7B"}
|
|
@@ -41,6 +41,9 @@ class TestAppImplementation {
|
|
|
41
41
|
_classPrivateFieldGet(_instance, this).queueUpdate(this.component);
|
|
42
42
|
await this.resolved();
|
|
43
43
|
});
|
|
44
|
+
_defineProperty(this, Symbol.asyncDispose, async () => {
|
|
45
|
+
await this.unmount();
|
|
46
|
+
});
|
|
44
47
|
_defineProperty(this, "unmount", async () => {
|
|
45
48
|
if (_classPrivateFieldGet(_unmounted, this)) return;
|
|
46
49
|
_classPrivateFieldSet(_unmounted, this, true);
|
|
@@ -123,13 +126,16 @@ RootComponent, ...args) {
|
|
|
123
126
|
const instanceConfig = {
|
|
124
127
|
prod: false,
|
|
125
128
|
useRootComponent: true,
|
|
126
|
-
clientSideNav:
|
|
129
|
+
clientSideNav: true,
|
|
127
130
|
siteBasePath: '/',
|
|
128
131
|
staticSite: false,
|
|
129
132
|
csr: false
|
|
130
133
|
};
|
|
131
|
-
|
|
132
|
-
|
|
134
|
+
// routing() falls back to the built-in 404 when neither '404' nor 'default' is given
|
|
135
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
136
|
+
const appRoutes = options?.routes ?? {};
|
|
137
|
+
const routes = typeof appRoutes === 'function' ? appRoutes(null) : appRoutes;
|
|
138
|
+
const instance = new Instance(location, instanceConfig, null, appRoutes, routes, internalStore, stores, storeSubscriptions, globalData, matchedRouteInfo, runtimeContext);
|
|
133
139
|
try {
|
|
134
140
|
for (const override of options?.stores ?? []) {
|
|
135
141
|
const store = override.registration.getStore(instance.stores);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../../src/testing/host.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAEpD,OAAO,KAAK,EAAE,mBAAmB,EAA8B,MAAM,iCAAiC,CAAA;AACtG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAClE,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,EACH,qBAAqB,
|
|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AC,mBAAmB,CAAC,GAAG,KAAK,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC,GAC5F,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAA;AAE7B,wBAAsB,IAAI,CACtB,KAAK,SAAS,0BAA0B,EAExC,SAAS,SAAS,qBAAqB,CAAC,GAAG,EAAE,GAAG,CAAC,EAEjD,aAAa,EAAE,sBAAsB,CAAC,KAAK,EAAE,SAAS,CAAC,EACvD,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,GAChD,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAA"}
|
package/dist/testing/host.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TungstenBaseComponent, TungstenBaseSimpleStoreComponent, TungstenBaseStatefulStoreComponent, TungstenBaseStoreComponent, TungstenSimpleComponent } from "../Components.js";
|
|
2
|
-
import {
|
|
2
|
+
import { makeStore } from '../Store/makeStore.js';
|
|
3
3
|
import { routing } from "../Servers/routing.js";
|
|
4
|
-
import { missingStoreValue,
|
|
4
|
+
import { missingStoreValue, testingComponentPackage } from './testingComponentPackage.js';
|
|
5
5
|
const isPromise = value => value instanceof Promise || typeof value === 'object' && value !== null && 'then' in value;
|
|
6
6
|
// The same list at runtime. Underscore-prefixed members are excluded by rule
|
|
7
7
|
// (the framework's naming scheme), so only the plain-named ones are listed, and
|
|
@@ -52,7 +52,7 @@ export async function host(ComponentType, props,
|
|
|
52
52
|
options) {
|
|
53
53
|
const stored = options ?? {};
|
|
54
54
|
const storeData = stored.storeData ?? stored.partialStoreData;
|
|
55
|
-
const store = stored.store ?? stored.partialStore ?? (storeData === undefined ? undefined :
|
|
55
|
+
const store = stored.store ?? stored.partialStore ?? (storeData === undefined ? undefined : makeStore(storeData, new Map()));
|
|
56
56
|
const partial = stored.partialStore !== undefined || stored.partialStoreData !== undefined;
|
|
57
57
|
const route = await hostedRouting(stored);
|
|
58
58
|
const pending = [];
|
|
@@ -17,6 +17,7 @@ export type HydrateTestApp<Component extends TungstenBaseComponent> = {
|
|
|
17
17
|
resolved(): Promise<void>;
|
|
18
18
|
setProps(props: Component['props']): Promise<void>;
|
|
19
19
|
unmount(): Promise<void>;
|
|
20
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
20
21
|
};
|
|
21
22
|
/**
|
|
22
23
|
* The hydration round trip createTestApp() deliberately doesn't cover: render a component to
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hydrateTestApp.d.ts","sourceRoot":"","sources":["../../src/testing/hydrateTestApp.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACR,gBAAgB,EAChB,qBAAqB,EACrB,0BAA0B,EAC7B,MAAM,mBAAmB,CAAA;AAI1B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6CAA6C,CAAA;AAK1F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAaxD,MAAM,MAAM,qBAAqB,CAAC,KAAK,SAAS,MAAM,IAAI,cAAc,CAAC,KAAK,CAAC,GAAG;IAM9E,WAAW,CAAC,EAAE,KAAK,CAAA;IAEnB,GAAG,CAAC,EAAE,OAAO,CAAA;CAChB,CAAA;AAED,KAAK,kBAAkB,CAAC,KAAK,SAAS,MAAM,IAAI,MAAM,SAAS,KAAK,GAC9D,CAAC,OAAO,CAAC,EAAE,qBAAqB,CAAC,KAAK,CAAC,CAAC,GACxC,MAAM,KAAK,SAAS,KAAK,GACrB,CAAC,OAAO,CAAC,EAAE,qBAAqB,CAAC,KAAK,CAAC,CAAC,GACxC,CAAC,OAAO,EAAE,qBAAqB,CAAC,KAAK,CAAC,GAAG;IAAE,KAAK,EAAE,KAAK,CAAA;CAAE,CAAC,CAAA;AAEpE,MAAM,MAAM,cAAc,CAAC,SAAS,SAAS,qBAAqB,IAAI;IAClE,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAA;IAC3B,QAA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IAClE,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAA;IAC3B,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAA;IAC/B,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAA;IAG7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IAIrB,QAAQ,CAAC,UAAU,EAAE,SAAS,uBAAuB,EAAE,CAAA;IAEvD,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IACzB,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAClD,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IAExB,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CACzC,CAAA;AAsGD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,cAAc,CAChC,KAAK,SAAS,0BAA0B,EACxC,SAAS,SAAS,qBAAqB,CAAC,GAAG,EAAE,GAAG,CAAC,EACjD,SAAS,GAAG,SAAS,EAErB,aAAa,EAAE,KAAK,GAAG,EAAE,gBAAgB,CAAC,KAAK,EAAE,SAAS,CAAC,KAAK,SAAS,EACzE,GAAG,IAAI,EAAE,kBAAkB,CAAC,KAAK,CAAC,GACnC,OAAO,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAgIpC"}
|
|
@@ -58,6 +58,9 @@ class HydrateTestAppImplementation {
|
|
|
58
58
|
_classPrivateFieldGet(_instance, this).queueUpdate(this.component);
|
|
59
59
|
await this.resolved();
|
|
60
60
|
});
|
|
61
|
+
_defineProperty(this, Symbol.asyncDispose, async () => {
|
|
62
|
+
await this.unmount();
|
|
63
|
+
});
|
|
61
64
|
_defineProperty(this, "unmount", async () => {
|
|
62
65
|
if (_classPrivateFieldGet(_unmounted, this)) return;
|
|
63
66
|
_classPrivateFieldSet(_unmounted, this, true);
|
|
@@ -146,12 +149,15 @@ export async function hydrateTestApp(RootComponent, ...args) {
|
|
|
146
149
|
const instanceConfig = {
|
|
147
150
|
prod: false,
|
|
148
151
|
useRootComponent: true,
|
|
149
|
-
clientSideNav:
|
|
152
|
+
clientSideNav: true,
|
|
150
153
|
siteBasePath: '/',
|
|
151
154
|
staticSite: false,
|
|
152
155
|
csr: options?.csr ?? false
|
|
153
156
|
};
|
|
154
|
-
|
|
157
|
+
// routing() falls back to the built-in 404 when neither '404' nor 'default' is given
|
|
158
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
159
|
+
const appRoutes = options?.routes ?? {};
|
|
160
|
+
const routes = typeof appRoutes === 'function' ? appRoutes(null) : appRoutes;
|
|
155
161
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- rootToHtml.ts builds a root content node the same way
|
|
156
162
|
const componentNode = {
|
|
157
163
|
[$type]: RootComponent,
|
|
@@ -167,7 +173,7 @@ export async function hydrateTestApp(RootComponent, ...args) {
|
|
|
167
173
|
stores,
|
|
168
174
|
storeSubscriptions
|
|
169
175
|
} = initStores(location, null, globalData, matchedRouteInfo);
|
|
170
|
-
const ssrInstance = new Instance(location, instanceConfig, null,
|
|
176
|
+
const ssrInstance = new Instance(location, instanceConfig, null, appRoutes, routes, internalStore, stores, storeSubscriptions, globalData, matchedRouteInfo, {
|
|
171
177
|
document,
|
|
172
178
|
window: document.defaultView,
|
|
173
179
|
scheduler: ssrScheduler,
|
|
@@ -211,7 +217,7 @@ export async function hydrateTestApp(RootComponent, ...args) {
|
|
|
211
217
|
scheduler,
|
|
212
218
|
navigation: false
|
|
213
219
|
};
|
|
214
|
-
const instance = new Instance(location, instanceConfig, null,
|
|
220
|
+
const instance = new Instance(location, instanceConfig, null, appRoutes, routes, internalStore, stores, storeSubscriptions, globalData, matchedRouteInfo, runtimeContext);
|
|
215
221
|
try {
|
|
216
222
|
for (const override of options?.stores ?? []) {
|
|
217
223
|
const store = override.registration.getStore(instance.stores);
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { loadEnv } from './loadEnv.js';
|
|
2
2
|
export { testEnvVariableName } from './testEnvIsRequested.js';
|
|
3
3
|
export { hydrateTestApp, type HydrateTestApp, type HydrateTestAppOptions } from './hydrateTestApp.js';
|
|
4
|
-
export { createTestApp, testStore, type ComponentProps, type CreateTestAppArgs, type TestApp, type TestAppOptions, type TestStore, type TestStoreOverride, type TestStoreRegistration, } from './createTestApp.js';
|
|
4
|
+
export { createTestApp, testStore, type ComponentProps, type CreateTestAppArgs, type TestApp, type TestAppOptions, type TestStore, type TestStoreOverride, type TestStoreRegistration, type TestRoutes, } from './createTestApp.js';
|
|
5
5
|
export { host, type HostOptions, type HostStoreOptions, type Hosted } from './host.js';
|
|
6
6
|
export { testingComponentPackage } from './testingComponentPackage.js';
|
|
7
7
|
export { contentHtmlElements } from './helpers/contentHtmlElements.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,EAAE,cAAc,EAAE,KAAK,cAAc,EAAE,KAAK,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AACrG,OAAO,EACH,aAAa,EACb,SAAS,EACT,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,EAAE,cAAc,EAAE,KAAK,cAAc,EAAE,KAAK,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AACrG,OAAO,EACH,aAAa,EACb,SAAS,EACT,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,UAAU,GAClB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,IAAI,EAAE,KAAK,WAAW,EAAE,KAAK,gBAAgB,EAAE,KAAK,MAAM,EAAE,MAAM,WAAW,CAAA;AACtF,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAA;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAA;AACtE,OAAO,EAAE,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAA"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { ConstructPackage } from '../Components.jsx';
|
|
1
|
+
import type { ConstructPackage, TungstenBaseStoreComponent } from '../Components.jsx';
|
|
2
2
|
import type { Instance } from '../Instance/Instance.js';
|
|
3
3
|
import type { InstanceConfig } from '../Instance/InstanceConfig.js';
|
|
4
4
|
import type { PartialInternalStoreSchema } from '../Store/InternalStoreSchema.js';
|
|
5
5
|
import type { GlobalData } from '../routing/registerGlobalData.js';
|
|
6
|
-
import { $
|
|
6
|
+
import { $trueStoreValue, type TrueStore } from '../Store/makeStore.js';
|
|
7
7
|
export type TestingComponentPackageOptions = {
|
|
8
8
|
store?: Partial<TrueStore<any>>;
|
|
9
9
|
routes?: object;
|
|
@@ -17,21 +17,16 @@ export type TestingComponentPackageOptions = {
|
|
|
17
17
|
goto?: Instance['goto'];
|
|
18
18
|
redirect?: Instance['redirect'];
|
|
19
19
|
};
|
|
20
|
-
export declare const storeValue: <Value>(initialValue: Value) => {
|
|
21
|
-
[$trueStoreCell]: true;
|
|
22
|
-
get: () => Value;
|
|
23
|
-
set: (newValue: Value) => void;
|
|
24
|
-
subscribe: () => undefined;
|
|
25
|
-
unsubscribe: () => undefined;
|
|
26
|
-
sync: () => Value;
|
|
27
|
-
};
|
|
28
20
|
export declare const missingStoreValue: <Value>(key: string) => {
|
|
29
|
-
[$
|
|
21
|
+
[$trueStoreValue]: true;
|
|
30
22
|
get: () => Value;
|
|
31
23
|
set: () => undefined;
|
|
32
24
|
subscribe: () => undefined;
|
|
33
25
|
unsubscribe: () => undefined;
|
|
34
26
|
sync: () => Value;
|
|
27
|
+
notify: <Fn extends ((value: Value) => void)>(fn: Fn, el: TungstenBaseStoreComponent<any, any, any>) => Fn;
|
|
28
|
+
stopNotify: <Fn extends ((value: Value) => void)>(fn: Fn, el: TungstenBaseStoreComponent<any, any, any>) => Fn;
|
|
29
|
+
stopNotifyAll: () => undefined;
|
|
35
30
|
};
|
|
36
31
|
export declare const testingComponentPackage: <Props extends object>(props: Props, options?: TestingComponentPackageOptions) => ConstructPackage<Props, undefined>;
|
|
37
32
|
//# sourceMappingURL=testingComponentPackage.d.ts.map
|
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"testingComponentPackage.d.ts","sourceRoot":"","sources":["../../src/testing/testingComponentPackage.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAA;AACrF,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;AAGlE,OAAO,EACH,eAA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 +1,40 @@
|
|
|
1
|
-
import { $
|
|
1
|
+
import { $trueStoreValue, StoreValue } from '../Store/makeStore.js';
|
|
2
2
|
import { routeKeyToUrl } from '../routing/routeUrl.js';
|
|
3
3
|
const missing = key => {
|
|
4
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.`);
|
|
5
5
|
};
|
|
6
|
-
export const storeValue = initialValue => {
|
|
7
|
-
let value = initialValue;
|
|
8
|
-
return {
|
|
9
|
-
[$trueStoreCell]: true,
|
|
10
|
-
get: () => value,
|
|
11
|
-
set: newValue => {
|
|
12
|
-
value = newValue;
|
|
13
|
-
},
|
|
14
|
-
subscribe: () => undefined,
|
|
15
|
-
unsubscribe: () => undefined,
|
|
16
|
-
sync: () => value
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
6
|
// A store key the test did not supply: subscribing and setting work, reading
|
|
20
7
|
// names the key.
|
|
21
8
|
export const missingStoreValue = key => ({
|
|
22
|
-
[$
|
|
9
|
+
[$trueStoreValue]: true,
|
|
23
10
|
get: () => missing(key),
|
|
24
11
|
set: () => undefined,
|
|
25
12
|
subscribe: () => undefined,
|
|
26
13
|
unsubscribe: () => undefined,
|
|
27
|
-
sync: () => missing(key)
|
|
14
|
+
sync: () => missing(key),
|
|
15
|
+
notify: (fn, el) => fn,
|
|
16
|
+
stopNotify: (fn, el) => fn,
|
|
17
|
+
stopNotifyAll: () => undefined
|
|
28
18
|
});
|
|
29
|
-
|
|
19
|
+
// A supplied key gets the real cell, so the mock never has to track StoreValue's methods
|
|
20
|
+
const storeField = (key, value, subscribedElements) => value === undefined ? missingStoreValue(key) : new StoreValue(key, value, subscribedElements);
|
|
30
21
|
// Keyed off the schema, so a new internal store key fails to compile here
|
|
31
22
|
// rather than turning up as `undefined.sync is not a function` in a test.
|
|
32
|
-
const internalStore = supplied =>
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
23
|
+
const internalStore = supplied => {
|
|
24
|
+
// the cells of one store share an element index, as a real store's do
|
|
25
|
+
const subscribedElements = new Map();
|
|
26
|
+
return {
|
|
27
|
+
location: storeField('internalStore.location', supplied?.location, subscribedElements),
|
|
28
|
+
navigationIndex: storeField('internalStore.navigationIndex', 0, subscribedElements),
|
|
29
|
+
navigating: storeField('internalStore.navigating', false, subscribedElements),
|
|
30
|
+
matchedRouteInfo: storeField('internalStore.matchedRouteInfo', supplied?.matchedRouteInfo, subscribedElements),
|
|
31
|
+
popMessages: storeField('internalStore.popMessages', supplied?.popMessages, subscribedElements)
|
|
32
|
+
};
|
|
33
|
+
};
|
|
37
34
|
const defaultConfig = {
|
|
38
35
|
prod: false,
|
|
39
36
|
useRootComponent: true,
|
|
40
|
-
clientSideNav:
|
|
37
|
+
clientSideNav: true,
|
|
41
38
|
siteBasePath: '',
|
|
42
39
|
staticSite: false,
|
|
43
40
|
csr: false
|