@owlmeans/client 0.1.18-rc.4 → 0.1.18-rc.41
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/README.md +231 -54
- package/agent-meta/manifest.json +2 -2
- package/agent-meta/skills/client/SKILL.md +282 -19
- package/build/consts.d.ts +8 -0
- package/build/consts.d.ts.map +1 -1
- package/build/consts.js +8 -0
- package/build/consts.js.map +1 -1
- package/build/context.d.ts.map +1 -1
- package/build/context.js +1 -3
- package/build/context.js.map +1 -1
- package/build/entrypoint.d.ts +3 -0
- package/build/entrypoint.d.ts.map +1 -0
- package/build/entrypoint.js +4 -0
- package/build/entrypoint.js.map +1 -0
- package/build/helper.js +3 -3
- package/build/helper.js.map +1 -1
- package/build/index.d.ts +3 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +3 -1
- package/build/index.js.map +1 -1
- package/build/lazy-retry.d.ts +47 -0
- package/build/lazy-retry.d.ts.map +1 -0
- package/build/lazy-retry.js +128 -0
- package/build/lazy-retry.js.map +1 -0
- package/build/lazy.d.ts +32 -0
- package/build/lazy.d.ts.map +1 -0
- package/build/lazy.js +114 -0
- package/build/lazy.js.map +1 -0
- package/build/navigate.d.ts.map +1 -1
- package/build/navigate.js +15 -18
- package/build/navigate.js.map +1 -1
- package/build/router.d.ts.map +1 -1
- package/build/router.js +12 -6
- package/build/router.js.map +1 -1
- package/build/services/debug.js.map +1 -1
- package/build/store.d.ts +19 -3
- package/build/store.d.ts.map +1 -1
- package/build/store.js +57 -50
- package/build/store.js.map +1 -1
- package/build/types.d.ts +85 -7
- package/build/types.d.ts.map +1 -1
- package/build/utils/entrypoint.d.ts +3 -0
- package/build/utils/entrypoint.d.ts.map +1 -0
- package/build/utils/{module.js → entrypoint.js} +2 -2
- package/build/utils/entrypoint.js.map +1 -0
- package/build/utils/index.d.ts +1 -1
- package/build/utils/index.d.ts.map +1 -1
- package/build/utils/index.js +1 -1
- package/build/utils/index.js.map +1 -1
- package/build/utils/route.d.ts.map +1 -1
- package/build/utils/route.js +12 -6
- package/build/utils/route.js.map +1 -1
- package/build/utils/router.d.ts +4 -4
- package/build/utils/router.d.ts.map +1 -1
- package/build/utils/router.js +8 -8
- package/build/utils/router.js.map +1 -1
- package/package.json +21 -14
- package/src/consts.ts +10 -0
- package/src/context.ts +1 -4
- package/src/entrypoint.ts +6 -0
- package/src/helper.tsx +6 -6
- package/src/index.ts +3 -1
- package/src/lazy-retry.ts +141 -0
- package/src/lazy.tsx +161 -0
- package/src/navigate.ts +16 -19
- package/src/router.ts +14 -10
- package/src/services/debug.ts +2 -2
- package/src/store.ts +71 -54
- package/src/types.ts +95 -7
- package/src/utils/{module.ts → entrypoint.ts} +2 -2
- package/src/utils/index.ts +1 -1
- package/src/utils/route.tsx +15 -8
- package/src/utils/router.ts +11 -11
- package/tests/context.ts +33 -0
- package/tests/harness/index.html +11 -0
- package/tests/harness/mount.tsx +86 -0
- package/tests/harness/piece.tsx +4 -0
- package/tests/lazy-retry.spec.ts +199 -0
- package/tests/lazy.spec.ts +145 -0
- package/tsconfig.json +1 -1
- package/build/module.d.ts +0 -3
- package/build/module.d.ts.map +0 -1
- package/build/module.js +0 -4
- package/build/module.js.map +0 -1
- package/build/utils/module.d.ts +0 -3
- package/build/utils/module.d.ts.map +0 -1
- package/build/utils/module.js.map +0 -1
- package/src/module.ts +0 -6
package/build/types.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import type { PropsWithChildren, FC, DependencyList } from 'react';
|
|
1
|
+
import type { PropsWithChildren, FC, DependencyList, ComponentType, ReactNode } from 'react';
|
|
2
2
|
import type { AbstractRequest } from '@owlmeans/entrypoint';
|
|
3
3
|
import type { ClientConfig, ClientContext as BasicClientContext } from '@owlmeans/client-context';
|
|
4
|
+
import type { Criteria, ResourceRecord, Sort } from '@owlmeans/resource';
|
|
4
5
|
import type { StateResourceAppend } from '@owlmeans/state';
|
|
5
|
-
import type { ClientEntrypoint } from '@owlmeans/client-entrypoint';
|
|
6
|
+
import type { ClientEntrypoint, RefedEntrypointHandler } from '@owlmeans/client-entrypoint';
|
|
6
7
|
import type { DebugServiceAppend, ModalServiceAppend } from './components/types.js';
|
|
7
8
|
import type { ConfigResourceAppend } from '@owlmeans/config';
|
|
8
|
-
import type { ConfigRecord } from '@owlmeans/context';
|
|
9
|
+
import type { ConfigRecord, EntrypointReference } from '@owlmeans/context';
|
|
9
10
|
import type { NavigateFunction, RouterService, Location, RouteObject, LibraryRouter } from '@owlmeans/router';
|
|
10
11
|
export interface RouterModel {
|
|
11
12
|
routes: RouteObject[];
|
|
@@ -29,9 +30,9 @@ export interface AppProps extends PropsWithChildren {
|
|
|
29
30
|
/** Opt out of mounting the router (e.g. when routing is hosted elsewhere). */
|
|
30
31
|
noRouter?: boolean;
|
|
31
32
|
}
|
|
32
|
-
export interface RoutedComponent<ExtraProps = {}> extends FC<PropsWithChildren<
|
|
33
|
+
export interface RoutedComponent<ExtraProps = {}> extends FC<PropsWithChildren<EntrypointContextParams & ExtraProps>> {
|
|
33
34
|
}
|
|
34
|
-
export interface
|
|
35
|
+
export interface EntrypointContextParams<T extends {} = {}> {
|
|
35
36
|
alias: string;
|
|
36
37
|
params: AbstractRequest<T>['params'];
|
|
37
38
|
path: string;
|
|
@@ -46,13 +47,15 @@ export interface NavRequest<T extends Record<string, any> = Record<string, any>>
|
|
|
46
47
|
replace?: boolean;
|
|
47
48
|
silent?: boolean;
|
|
48
49
|
}
|
|
50
|
+
/** A navigation target is a protocol reference in application code, with strings retained for adapters. */
|
|
51
|
+
export type EntrypointTarget = EntrypointReference | string;
|
|
49
52
|
export interface Navigator {
|
|
50
53
|
_navigate: NavigateFunction;
|
|
51
54
|
navigate: <R extends NavRequest = NavRequest>(module: ClientEntrypoint<string, AbstractRequest>, request?: R) => Promise<void>;
|
|
52
|
-
go: <R extends NavRequest = NavRequest>(
|
|
55
|
+
go: <R extends NavRequest = NavRequest>(target: EntrypointTarget, request?: R) => Promise<void>;
|
|
53
56
|
back: () => Promise<void>;
|
|
54
57
|
pressBack: () => () => void;
|
|
55
|
-
press: <R extends NavRequest = NavRequest>(
|
|
58
|
+
press: <R extends NavRequest = NavRequest>(target: EntrypointTarget, request?: R) => () => void;
|
|
56
59
|
location: <R extends NavRequest = NavRequest>() => Location<R>;
|
|
57
60
|
}
|
|
58
61
|
export interface DebugConfigRecord extends ConfigRecord {
|
|
@@ -62,4 +65,79 @@ export interface UseValueParams<T> {
|
|
|
62
65
|
default?: T;
|
|
63
66
|
deps?: DependencyList;
|
|
64
67
|
}
|
|
68
|
+
/** What `useStoreList` subscribes to. Every field is optional; nothing at all means everything. */
|
|
69
|
+
export interface UseStoreListOptions<T extends ResourceRecord = ResourceRecord> {
|
|
70
|
+
/** The live query. Omitted or `{}` matches every record the resource holds. */
|
|
71
|
+
query?: Criteria<T>;
|
|
72
|
+
sort?: Sort<T>[];
|
|
73
|
+
/** Which state resource to read; the context's default one when omitted. */
|
|
74
|
+
resource?: string;
|
|
75
|
+
}
|
|
76
|
+
/** How `retryImport` retries a rejected dynamic import. */
|
|
77
|
+
export interface RetryImportOptions {
|
|
78
|
+
/** Loads after the first failure, at most; `0` loads once. Default 2. */
|
|
79
|
+
attempts?: number;
|
|
80
|
+
/** The pause before each retry, in order; the last one repeats. Default 500 ms, then 1500 ms. */
|
|
81
|
+
delaysMs?: readonly number[];
|
|
82
|
+
/**
|
|
83
|
+
* Which rejections are retried. Default `isChunkLoadError` — a module that could not be fetched,
|
|
84
|
+
* never one that was fetched and then failed.
|
|
85
|
+
*/
|
|
86
|
+
shouldRetry?: (error: unknown) => boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Retry a failed chunk from its own URL with a cache-busting `t` parameter when the browser's
|
|
89
|
+
* error names it (Chromium, Firefox). Default `true`: a browser that remembers a failed module
|
|
90
|
+
* fetch rejects every later `import()` of the same URL at once, so only a new URL is fetched
|
|
91
|
+
* again. `false` repeats `load` as is.
|
|
92
|
+
*/
|
|
93
|
+
bustCache?: boolean;
|
|
94
|
+
/** How a cache-busted URL is imported; a seam for tests. Default: a dynamic `import()`. */
|
|
95
|
+
importUrl?: (url: string) => Promise<unknown>;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* What a lazily-loaded piece renders once it failed: the props it was given, the error, and
|
|
99
|
+
* `retry`, which resets the piece's boundary so its chunk loads again.
|
|
100
|
+
*/
|
|
101
|
+
export type LazyErrorRenderer = (props: any, error: unknown, retry: () => void) => ReactNode;
|
|
102
|
+
/** How a lazily-loaded component behaves while its chunk loads and when the load fails. */
|
|
103
|
+
export interface LazyComponentOptions {
|
|
104
|
+
/** Shown while the chunk loads: a node, or a function of the props the component was given. */
|
|
105
|
+
fallback?: ReactNode | ((props: any) => ReactNode);
|
|
106
|
+
/**
|
|
107
|
+
* Rendered in place of the component when its chunk fails to load, or it throws: a node, or a
|
|
108
|
+
* `LazyErrorRenderer`. Omitted, a chunk failure starts the guarded reload
|
|
109
|
+
* (`recoverFromChunkError`) and leaves `fallback` in place, and any other error propagates to
|
|
110
|
+
* the nearest boundary above.
|
|
111
|
+
*/
|
|
112
|
+
error?: ReactNode | LazyErrorRenderer;
|
|
113
|
+
/**
|
|
114
|
+
* How a rejected load is retried before it counts as failed — `retryImport`'s options, its
|
|
115
|
+
* defaults when omitted. `false` loads once.
|
|
116
|
+
*/
|
|
117
|
+
retry?: false | RetryImportOptions;
|
|
118
|
+
/**
|
|
119
|
+
* When a chunk still fails after its retries, start the guarded page reload
|
|
120
|
+
* (`recoverFromChunkError`, once a minute per tab) before showing `error`; the fallback stays up
|
|
121
|
+
* while the reload starts, and `error` shows when the guard refuses. Without `error` a chunk
|
|
122
|
+
* failure always reloads. Default `false` for `lazyComponent` (a piece degrades in place), `true`
|
|
123
|
+
* for `lazyHandler` (a whole screen). A dev-served app needs it: its modules import themselves by
|
|
124
|
+
* their own URL (React Fast Refresh), so a browser that remembers the failed fetch can load that
|
|
125
|
+
* module again only in a new document.
|
|
126
|
+
*/
|
|
127
|
+
reload?: boolean;
|
|
128
|
+
}
|
|
129
|
+
export interface LazyPreload<P = {}> {
|
|
130
|
+
/** Start (or join) the chunk load; resolves to the component once it is ready. */
|
|
131
|
+
preload: () => Promise<ComponentType<P>>;
|
|
132
|
+
}
|
|
133
|
+
/** A lazily-loaded component: renders like the real one, and can be preloaded ahead of use. */
|
|
134
|
+
export type LazyComponent<P = {}> = ComponentType<P> & LazyPreload<P>;
|
|
135
|
+
/** An entrypoint handler over a lazily-loaded component, carrying its `.preload()`. */
|
|
136
|
+
export type LazyHandler<P = {}> = RefedEntrypointHandler<P> & LazyPreload<P>;
|
|
137
|
+
/** Names of a module's exports that are React components. */
|
|
138
|
+
export type ComponentExport<M> = {
|
|
139
|
+
[K in keyof M]-?: M[K] extends ComponentType<any> ? K : never;
|
|
140
|
+
}[keyof M] & string;
|
|
141
|
+
/** The props of a module's component export. */
|
|
142
|
+
export type ExportProps<M, K extends keyof M> = M[K] extends ComponentType<infer P> ? P : never;
|
|
65
143
|
//# sourceMappingURL=types.d.ts.map
|
package/build/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,EAAE,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,EAAE,EAAE,cAAc,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAC5F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,IAAI,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AACjG,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM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AAC,GAAG,KAAK,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entrypoint.d.ts","sourceRoot":"","sources":["../../src/utils/entrypoint.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,uBAAuB,EAAiB,MAAM,aAAa,CAAA;AAMzE,eAAO,MAAM,iBAAiB,sDAK5B,CAAA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createContext } from 'react';
|
|
2
|
-
export const
|
|
2
|
+
export const EntrypointContext = createContext({
|
|
3
3
|
alias: '',
|
|
4
4
|
params: {},
|
|
5
5
|
path: '',
|
|
6
6
|
context: {}
|
|
7
7
|
});
|
|
8
|
-
//# sourceMappingURL=
|
|
8
|
+
//# sourceMappingURL=entrypoint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entrypoint.js","sourceRoot":"","sources":["../../src/utils/entrypoint.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAOrC,MAAM,CAAC,MAAM,iBAAiB,GAAG,aAAa,CAA0B;IACtE,KAAK,EAAE,EAAE;IACT,MAAM,EAAE,EAAE;IACV,IAAI,EAAE,EAAE;IACR,OAAO,EAAE,EAAa;CACvB,CAAC,CAAA"}
|
package/build/utils/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,iBAAiB,CAAA"}
|
package/build/utils/index.js
CHANGED
package/build/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,iBAAiB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../src/utils/route.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAChE,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../src/utils/route.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAChE,OAAO,KAAK,EAA4C,aAAa,EAAE,MAAM,aAAa,CAAA;AAE1F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAKnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAE5D,KAAK,MAAM,GAAG,YAAY,CAAA;AAC1B,UAAU,OAAO,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,CAAE,SAAQ,aAAa,CAAC,CAAC,CAAC;CAAI;AAEzE,eAAO,MAAM,mBAAmB,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,EAgE7D,CAAA;AAED,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,YAAY,CAAA;AAEvF,UAAU,cAAc;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAA;IACjC,WAAW,EAAE,OAAO,CAAA;CACrB"}
|
package/build/utils/route.js
CHANGED
|
@@ -6,10 +6,16 @@ import { AuthorizationError } from '@owlmeans/auth';
|
|
|
6
6
|
export const createRouteRenderer = ({ context, module, hasChildren }) => () => {
|
|
7
7
|
const params = context.router().useParams();
|
|
8
8
|
const reply = provideResponse();
|
|
9
|
+
// Own guards plus every ancestor's — the same set the request would be judged by. Whether a
|
|
10
|
+
// screen is guarded is a question about THIS list being non-empty, never about the declaration
|
|
11
|
+
// carrying a `guards` property: binding always assigns the array, empty when nothing was
|
|
12
|
+
// declared, and an empty list means an open screen. Asking the wrong question refuses every
|
|
13
|
+
// guest screen with `frontend-guard`, since no guard can match when there are none.
|
|
14
|
+
const aliases = module.getGuards();
|
|
9
15
|
useEffect(() => {
|
|
10
|
-
if (
|
|
11
|
-
const guards =
|
|
12
|
-
const request = provideRequest(module.alias, module.
|
|
16
|
+
if (aliases.length > 0) {
|
|
17
|
+
const guards = aliases.map(guard => context.service(guard));
|
|
18
|
+
const request = provideRequest(module.alias, module.path());
|
|
13
19
|
const reply = provideResponse();
|
|
14
20
|
let canceled = false;
|
|
15
21
|
Promise.all(guards.map(async (guard) => {
|
|
@@ -32,9 +38,9 @@ export const createRouteRenderer = ({ context, module, hasChildren }) => () => {
|
|
|
32
38
|
});
|
|
33
39
|
return () => { canceled = true; };
|
|
34
40
|
}
|
|
35
|
-
},
|
|
41
|
+
}, aliases);
|
|
36
42
|
let Renderer = module.handle?.({
|
|
37
|
-
alias: module.alias, path: module.
|
|
43
|
+
alias: module.alias, path: module.path(),
|
|
38
44
|
params, body: {}, headers: {}, query: {},
|
|
39
45
|
}, reply);
|
|
40
46
|
if (reply.error != null) {
|
|
@@ -47,7 +53,7 @@ export const createRouteRenderer = ({ context, module, hasChildren }) => () => {
|
|
|
47
53
|
if (isComponent(Renderer)) {
|
|
48
54
|
const EnsuredRenderer = memo(Renderer);
|
|
49
55
|
const props = {
|
|
50
|
-
context, params, alias: module.
|
|
56
|
+
context, params, alias: module.alias, path: module.path()
|
|
51
57
|
};
|
|
52
58
|
if (hasChildren) {
|
|
53
59
|
return _jsx(EnsuredRenderer, { ...props, children: _jsx(Outlet, {}) });
|
package/build/utils/route.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.js","sourceRoot":"","sources":["../../src/utils/route.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEvD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAEtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAMnD,MAAM,CAAC,MAAM,mBAAmB,GAAmC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE;IAC5G,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,SAAS,EAAE,CAAA;IAC3C,MAAM,KAAK,GAAG,eAAe,EAAE,CAAA;IAE/B,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,
|
|
1
|
+
{"version":3,"file":"route.js","sourceRoot":"","sources":["../../src/utils/route.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEvD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAEtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAMnD,MAAM,CAAC,MAAM,mBAAmB,GAAmC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE;IAC5G,MAAM,MAAM,GAAG,OAAO,CAAC,MA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CAAC;QAChB,OAAO,KAAC,MAAM,KAAG,CAAA;IACnB,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC,CAAA;AAUD,MAAM,WAAW,GAAG,CAAe,OAA2B,EAAqD,EAAE,CACnH,OAAO,IAAI,IAAI,IAAI,OAAO,OAAO,KAAK,UAAU,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAA"}
|
package/build/utils/router.d.ts
CHANGED
|
@@ -4,13 +4,13 @@ import type { ClientContext } from '../types.js';
|
|
|
4
4
|
type Config = ClientConfig;
|
|
5
5
|
interface Context<C extends Config = Config> extends ClientContext<C> {
|
|
6
6
|
}
|
|
7
|
-
export declare const
|
|
8
|
-
export declare const
|
|
7
|
+
export declare const buildEntrypointTree: <R, C extends Config = Config, T extends Context<C> = Context<C>>(context: T) => EntrypointTree<R>;
|
|
8
|
+
export declare const visitEntrypointTree: <T, R>(tree: EntrypointTree<T>, visitor: EntrypointTreeVisitor<T, R>) => Promise<R[]>;
|
|
9
9
|
export declare const initializeRouter: (context: Context) => Promise<import("@owlmeans/router").RouteObject[]>;
|
|
10
|
-
export interface
|
|
10
|
+
export interface EntrypointTreeVisitor<T, R> {
|
|
11
11
|
(module: ClientEntrypoint<T>, children: R[], alone: boolean): Promise<R>;
|
|
12
12
|
}
|
|
13
|
-
interface
|
|
13
|
+
interface EntrypointTree<T> extends Map<ClientEntrypoint<T>, EntrypointTree<T>> {
|
|
14
14
|
}
|
|
15
15
|
export {};
|
|
16
16
|
//# sourceMappingURL=router.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/utils/router.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAGnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEhD,KAAK,M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,cAAc,CAAC,CAAC,CAAC,CAAC;CAC9E"}
|
package/build/utils/router.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { AppType } from '@owlmeans/context';
|
|
2
2
|
import { makeRouterModel } from '../router.js';
|
|
3
|
-
export const
|
|
4
|
-
const
|
|
3
|
+
export const buildEntrypointTree = (context) => {
|
|
4
|
+
const entrypoints = context.entrypoints().filter(module => module.route.route.type === AppType.Frontend
|
|
5
5
|
&& (module.sticky || module.route.route.service == null
|
|
6
6
|
|| module.route.route.service === context.cfg.service));
|
|
7
7
|
const flatTree = new Map();
|
|
8
8
|
const roots = [];
|
|
9
|
-
|
|
10
|
-
const parentAlias = module.
|
|
9
|
+
entrypoints.forEach(module => {
|
|
10
|
+
const parentAlias = module.route.route.parent;
|
|
11
11
|
if (parentAlias == null) {
|
|
12
12
|
roots.push(module);
|
|
13
13
|
}
|
|
@@ -18,12 +18,12 @@ export const buildModuleTree = (context) => {
|
|
|
18
18
|
flatTree.set(parent, list);
|
|
19
19
|
}
|
|
20
20
|
});
|
|
21
|
-
const
|
|
22
|
-
return
|
|
21
|
+
const reduceEntrypoints = (entrypoints) => entrypoints.reduce((tree, module) => tree.set(module, reduceEntrypoints(flatTree.get(module) ?? [])), new Map());
|
|
22
|
+
return reduceEntrypoints(roots);
|
|
23
23
|
};
|
|
24
|
-
export const
|
|
24
|
+
export const visitEntrypointTree = async (tree, visitor) => Array.from(tree.entries()).reduce(async (result, [module, tree], _, source) => [
|
|
25
25
|
...(await result),
|
|
26
|
-
await visitor(module, await
|
|
26
|
+
await visitor(module, await visitEntrypointTree(tree, visitor), source.length === 1)
|
|
27
27
|
], Promise.resolve([]));
|
|
28
28
|
export const initializeRouter = async (context) => {
|
|
29
29
|
if (!context.cfg.ready) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.js","sourceRoot":"","sources":["../../src/utils/router.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,mB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rC,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@owlmeans/client",
|
|
3
|
-
"version": "0.1.18-rc.
|
|
3
|
+
"version": "0.1.18-rc.41",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "tsc -b",
|
|
8
8
|
"dev": "sleep 54 && nodemon -e ts,tsx,json --watch src --exec \"tsc -p ./tsconfig.json\"",
|
|
9
|
-
"watch": "tsc -b -w --preserveWatchOutput --pretty"
|
|
9
|
+
"watch": "tsc -b -w --preserveWatchOutput --pretty",
|
|
10
|
+
"test": "bun test ./tests"
|
|
10
11
|
},
|
|
11
12
|
"main": "build/index.js",
|
|
12
13
|
"module": "build/index.js",
|
|
@@ -28,17 +29,17 @@
|
|
|
28
29
|
}
|
|
29
30
|
},
|
|
30
31
|
"dependencies": {
|
|
31
|
-
"@owlmeans/auth": "^0.1.18-rc.
|
|
32
|
-
"@owlmeans/client-context": "^0.1.18-rc.
|
|
33
|
-
"@owlmeans/client-entrypoint": "^0.1.18-rc.
|
|
34
|
-
"@owlmeans/client-resource": "^0.1.18-rc.
|
|
35
|
-
"@owlmeans/config": "^0.1.18-rc.
|
|
36
|
-
"@owlmeans/context": "^0.1.18-rc.
|
|
37
|
-
"@owlmeans/error": "^0.1.18-rc.
|
|
38
|
-
"@owlmeans/entrypoint": "^0.1.18-rc.
|
|
39
|
-
"@owlmeans/resource": "^0.1.18-rc.
|
|
40
|
-
"@owlmeans/router": "^0.1.18-rc.
|
|
41
|
-
"@owlmeans/state": "^0.1.18-rc.
|
|
32
|
+
"@owlmeans/auth": "^0.1.18-rc.36",
|
|
33
|
+
"@owlmeans/client-context": "^0.1.18-rc.39",
|
|
34
|
+
"@owlmeans/client-entrypoint": "^0.1.18-rc.38",
|
|
35
|
+
"@owlmeans/client-resource": "^0.1.18-rc.38",
|
|
36
|
+
"@owlmeans/config": "^0.1.18-rc.38",
|
|
37
|
+
"@owlmeans/context": "^0.1.18-rc.32",
|
|
38
|
+
"@owlmeans/error": "^0.1.18-rc.36",
|
|
39
|
+
"@owlmeans/entrypoint": "^0.1.18-rc.37",
|
|
40
|
+
"@owlmeans/resource": "^0.1.18-rc.36",
|
|
41
|
+
"@owlmeans/router": "^0.1.18-rc.31",
|
|
42
|
+
"@owlmeans/state": "^0.1.18-rc.35"
|
|
42
43
|
},
|
|
43
44
|
"peerDependencies": {
|
|
44
45
|
"@remix-run/router": "*",
|
|
@@ -51,9 +52,15 @@
|
|
|
51
52
|
},
|
|
52
53
|
"devDependencies": {
|
|
53
54
|
"@owlmeans/dep-config": "workspace:*",
|
|
55
|
+
"@owlmeans/test-ui": "^0.1.18-rc.39",
|
|
54
56
|
"@types/react": "^19.2.17",
|
|
57
|
+
"@vitejs/plugin-react": "^6.0.3",
|
|
55
58
|
"nodemon": "^3.1.14",
|
|
56
|
-
"
|
|
59
|
+
"playwright": "^1.61.1",
|
|
60
|
+
"react": "^19.2.7",
|
|
61
|
+
"react-dom": "^19.2.7",
|
|
62
|
+
"typescript": "^7.0.2",
|
|
63
|
+
"vite": "^8.1.2"
|
|
57
64
|
},
|
|
58
65
|
"publishConfig": {
|
|
59
66
|
"access": "public"
|
package/src/consts.ts
CHANGED
|
@@ -5,3 +5,13 @@ export const DEF_DEBUG_ALIAS = 'debug'
|
|
|
5
5
|
export const DEBUGGER_FLAG = 'debugger'
|
|
6
6
|
export const DEBUG_CONFIG_KEY = 'debugger'
|
|
7
7
|
|
|
8
|
+
/** How many times `retryImport` loads a chunk again after its first failure. */
|
|
9
|
+
export const DEF_IMPORT_RETRY_ATTEMPTS = 2
|
|
10
|
+
/** The pause before each retry, in order; the last one repeats. */
|
|
11
|
+
export const DEF_IMPORT_RETRY_DELAYS_MS: readonly number[] = [500, 1500]
|
|
12
|
+
|
|
13
|
+
/** The `sessionStorage` key `recoverFromChunkError` keeps the time of its last reload under. */
|
|
14
|
+
export const CHUNK_RELOAD_KEY = 'owlmeans:chunk-reload'
|
|
15
|
+
/** At most one chunk-recovery reload per this window, per tab. */
|
|
16
|
+
export const CHUNK_RELOAD_WINDOW_MS = 60_000
|
|
17
|
+
|
package/src/context.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { createContext, useContext as useCtx } from 'react'
|
|
|
3
3
|
import type { Context as ReactContext } from 'react'
|
|
4
4
|
import { makeClientContext as makeBasicContext, PLUGINS } from '@owlmeans/client-context'
|
|
5
5
|
import type { ClientConfig } from '@owlmeans/client-context'
|
|
6
|
-
import { AppType, CONFIG_RECORD
|
|
6
|
+
import { AppType, CONFIG_RECORD } from '@owlmeans/context'
|
|
7
7
|
import type { ClientContext } from './types.js'
|
|
8
8
|
import { appendStateResource } from '@owlmeans/state'
|
|
9
9
|
import { appendModalService } from './components/modal.js'
|
|
@@ -15,7 +15,6 @@ import { ROUTER_SERVICE } from '@owlmeans/router'
|
|
|
15
15
|
const defaultCfg: ClientConfig = {
|
|
16
16
|
services: {},
|
|
17
17
|
brand: {},
|
|
18
|
-
layer: Layer.Service,
|
|
19
18
|
trusted: [],
|
|
20
19
|
[CONFIG_RECORD]: [],
|
|
21
20
|
ready: false,
|
|
@@ -51,8 +50,6 @@ export const makeClientContext = <C extends ClientConfig, T extends ClientContex
|
|
|
51
50
|
|
|
52
51
|
context.router = () => context.service<RouterService>(ROUTER_SERVICE)
|
|
53
52
|
|
|
54
|
-
context.makeContext = makeClientContext as typeof context.makeContext
|
|
55
|
-
|
|
56
53
|
return context
|
|
57
54
|
}
|
|
58
55
|
|
package/src/helper.tsx
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { AbstractRequest, AbstractResponse } from '@owlmeans/entrypoint'
|
|
2
|
-
import type {
|
|
2
|
+
import type { EntrypointContextParams, RoutedComponent, ClientContext } from './types.js'
|
|
3
3
|
import type { RefedEntrypointHandler } from '@owlmeans/client-entrypoint'
|
|
4
4
|
import { HandledRenderer } from './utils/route.js'
|
|
5
5
|
import { isValidElement } from 'react'
|
|
6
6
|
import type { PropsWithChildren } from 'react'
|
|
7
|
-
import {
|
|
7
|
+
import { EntrypointContext } from './utils/entrypoint.js'
|
|
8
8
|
import type { ClientConfig } from '@owlmeans/client-context'
|
|
9
9
|
import { assertContext } from '@owlmeans/context'
|
|
10
10
|
|
|
@@ -17,7 +17,7 @@ export const handler = <T extends {}>(
|
|
|
17
17
|
R extends AbstractRequest = AbstractRequest,
|
|
18
18
|
P extends AbstractResponse<HandledRenderer<T>> = AbstractResponse<HandledRenderer<T>>
|
|
19
19
|
>(req: R, res: P): any => {
|
|
20
|
-
const location = `client-handler:${ref.ref?.
|
|
20
|
+
const location = `client-handler:${ref.ref?.alias ?? 'unknown'}`
|
|
21
21
|
if (ref.ref == null) {
|
|
22
22
|
throw new SyntaxError('Module reference is not provided')
|
|
23
23
|
}
|
|
@@ -40,12 +40,12 @@ export const handler = <T extends {}>(
|
|
|
40
40
|
|
|
41
41
|
const Renderer: RoutedComponent = ({ children, ...props }) => {
|
|
42
42
|
const Renderer = Component as unknown as RendererType
|
|
43
|
-
return <
|
|
43
|
+
return <EntrypointContext.Provider value={props}>
|
|
44
44
|
<Renderer {...props}>{children}</Renderer>
|
|
45
|
-
</
|
|
45
|
+
</EntrypointContext.Provider>
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
return Renderer
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
type RendererType = HandledRenderer<PropsWithChildren<
|
|
51
|
+
type RendererType = HandledRenderer<PropsWithChildren<EntrypointContextParams>> & RoutedComponent
|
package/src/index.ts
CHANGED
|
@@ -3,8 +3,10 @@ export * from './context.js'
|
|
|
3
3
|
export * from './components/index.js'
|
|
4
4
|
export * from './services/index.js'
|
|
5
5
|
export * from './helper.js'
|
|
6
|
+
export * from './lazy.js'
|
|
7
|
+
export * from './lazy-retry.js'
|
|
6
8
|
export * from './navigate.js'
|
|
7
|
-
export * from './
|
|
9
|
+
export * from './entrypoint.js'
|
|
8
10
|
export * from './router.js'
|
|
9
11
|
export * from './types.js'
|
|
10
12
|
export * from './store.js'
|