@blotch/rsbuild-plugin-angular-lynx 22.2.1 → 22.2.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/README.md +20 -3
- package/dist/544.js +21 -0
- package/dist/angular-cli-context.d.ts +34 -0
- package/dist/angular-diagnostics.d.ts +58 -0
- package/dist/angular-diagnostics.test.d.ts +1 -0
- package/dist/angular-rebuild-coordinator.d.ts +1 -1
- package/dist/angular.d.ts +5 -3
- package/dist/background-entry.d.ts +96 -0
- package/dist/background-entry.test.d.ts +1 -0
- package/dist/budgets-plugin.d.ts +64 -0
- package/dist/budgets-plugin.test.d.ts +1 -0
- package/dist/client/background-hot-updates.d.ts +50 -0
- package/dist/client/background-hot-updates.js +77 -0
- package/dist/client/background-hot-updates.test.d.ts +1 -0
- package/dist/client/css-hot-update.cjs +9 -0
- package/dist/client/css-hot-update.d.ts +44 -0
- package/dist/client/css-hot-update.js +42 -0
- package/dist/client/css-hot-update.test.d.ts +1 -0
- package/dist/client/hmr-background.js +16 -0
- package/dist/client/hmr-main-thread.js +9 -0
- package/dist/client/hmr-protocol.d.ts +74 -0
- package/dist/client/main-thread-hot-updates.d.ts +40 -0
- package/dist/client/main-thread-hot-updates.js +78 -0
- package/dist/client/main-thread-hot-updates.test.d.ts +1 -0
- package/dist/client/testing/test-context.d.ts +16 -0
- package/dist/component-styles-cache.d.ts +13 -31
- package/dist/component-styles.d.ts +73 -0
- package/dist/component-styles.test.d.ts +1 -0
- package/dist/cross-thread-transform.d.ts +38 -0
- package/dist/cross-thread-transform.test.d.ts +1 -0
- package/dist/css.d.ts +2 -2
- package/dist/entry.d.ts +28 -2
- package/dist/hot-updates.d.ts +67 -0
- package/dist/hot-updates.test.d.ts +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +1494 -638
- package/dist/layers.d.ts +6 -4
- package/dist/logger/dev-logger-middleware.d.ts +13 -7
- package/dist/logger/dev-logger.d.ts +13 -0
- package/dist/polyfills.js +56 -0
- package/dist/polyfills.test.d.ts +1 -0
- package/dist/pure-classes.d.ts +27 -0
- package/dist/pure-classes.test.d.ts +1 -0
- package/dist/resolve.d.ts +19 -0
- package/dist/resolve.test.d.ts +1 -0
- package/dist/split-chunks.d.ts +2 -2
- package/dist/styles/blur-view.css +16 -0
- package/dist/transform-module.d.ts +43 -17
- package/dist/utils/angular/budgets.d.ts +72 -0
- package/dist/utils/angular/budgets.test.d.ts +1 -0
- package/dist/utils/angular/build-internals.d.ts +14 -0
- package/dist/utils/angular/component-scope-id.d.ts +5 -3
- package/dist/utils/angular/component-style-bundler.d.ts +1 -1
- package/dist/utils/angular/options.d.ts +80 -2
- package/dist/utils/angular/read-workspace.d.ts +5 -1
- package/dist/utils/angular/resolve-primary-build.d.ts +26 -0
- package/dist/utils/angular/resolve-primary-build.test.d.ts +1 -0
- package/dist/utils/options.d.ts +40 -1
- package/package.json +13 -8
- package/dist/loaders/thread-globals-loader.d.ts +0 -8
- package/dist/loaders/thread-globals-loader.js +0 -6
- package/patch/patch-angular-build.cjs +0 -27
- /package/dist/{loaders/thread-globals-loader.test.d.ts → angular-cli-context.test.d.ts} +0 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The messages the two hot update clients exchange (hmr-background.ts and
|
|
3
|
+
* hmr-main-thread.ts). They travel over Lynx's cross-thread event channel:
|
|
4
|
+
* the background thread dispatches on `lynx.getCoreContext()` and the main
|
|
5
|
+
* thread listens on `lynx.getJSContext()`, and the reverse. Each payload is a
|
|
6
|
+
* JSON string, as in the runtime's other relays.
|
|
7
|
+
*/
|
|
8
|
+
/** Main → background: fetch a hot update file the main thread needs. */
|
|
9
|
+
export declare const HMR_FETCH = "AngularLynx.HmrFetch";
|
|
10
|
+
/** Background → main: the fetched file, or why it couldn't be fetched. */
|
|
11
|
+
export declare const HMR_FETCH_RESULT = "AngularLynx.HmrFetchResult";
|
|
12
|
+
/** Background → main: check for and apply the update to `hash`. */
|
|
13
|
+
export declare const HMR_CHECK = "AngularLynx.HmrCheck";
|
|
14
|
+
/** Main → background: whether the main thread applied it. */
|
|
15
|
+
export declare const HMR_CHECK_RESULT = "AngularLynx.HmrCheckResult";
|
|
16
|
+
/**
|
|
17
|
+
* Main → background: an update the main thread took in can't be shown, so
|
|
18
|
+
* reload the page. Sent by the stylesheet updater (css-hot-update.ts), which
|
|
19
|
+
* runs after the update itself has already succeeded.
|
|
20
|
+
*/
|
|
21
|
+
export declare const HMR_RELOAD = "AngularLynx.HmrReload";
|
|
22
|
+
export type FetchRequest = {
|
|
23
|
+
id: number;
|
|
24
|
+
url: string;
|
|
25
|
+
};
|
|
26
|
+
export type FetchResult = {
|
|
27
|
+
id: number;
|
|
28
|
+
status: number;
|
|
29
|
+
text: string;
|
|
30
|
+
} | {
|
|
31
|
+
id: number;
|
|
32
|
+
error: string;
|
|
33
|
+
};
|
|
34
|
+
export type CheckRequest = {
|
|
35
|
+
id: number;
|
|
36
|
+
hash: string;
|
|
37
|
+
};
|
|
38
|
+
export type ReloadRequest = {
|
|
39
|
+
reason: string;
|
|
40
|
+
};
|
|
41
|
+
/** Whether the main thread applied an update, and if not, why. */
|
|
42
|
+
export type CheckOutcome = {
|
|
43
|
+
ok: true;
|
|
44
|
+
updatedModules: number;
|
|
45
|
+
} | {
|
|
46
|
+
ok: false;
|
|
47
|
+
reason: string;
|
|
48
|
+
};
|
|
49
|
+
export type CheckResult = {
|
|
50
|
+
id: number;
|
|
51
|
+
} & CheckOutcome;
|
|
52
|
+
/** A thread's end of the cross-thread event channel. */
|
|
53
|
+
export type ThreadContext = {
|
|
54
|
+
addEventListener(type: string, listener: (event: {
|
|
55
|
+
data: string;
|
|
56
|
+
}) => void): void;
|
|
57
|
+
dispatchEvent(event: {
|
|
58
|
+
type: string;
|
|
59
|
+
data: string;
|
|
60
|
+
}): void;
|
|
61
|
+
};
|
|
62
|
+
/** The parts of webpack's `module.hot` API the clients use. */
|
|
63
|
+
export type HotApi = {
|
|
64
|
+
check(autoApply: true): Promise<(string | number)[] | null>;
|
|
65
|
+
status(): string;
|
|
66
|
+
};
|
|
67
|
+
export declare const send: (context: ThreadContext, type: string, message: object) => void;
|
|
68
|
+
export declare const listen: <T>(context: ThreadContext, type: string, listener: (message: T) => void) => void;
|
|
69
|
+
/**
|
|
70
|
+
* An error as text for the logs, with its stack. PrimJS, which runs the main
|
|
71
|
+
* thread, leaves the name and message out of `error.stack`, so they're added
|
|
72
|
+
* when the stack doesn't start with them.
|
|
73
|
+
*/
|
|
74
|
+
export declare const formatError: (error: unknown) => string;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type HotApi, type ThreadContext } from './hmr-protocol.js';
|
|
2
|
+
/** Lynx's `requireModuleAsync`, which the hot update runtime loads with. */
|
|
3
|
+
type RequireModuleAsync = (url: string, callback: (error: (Error & {
|
|
4
|
+
code?: string;
|
|
5
|
+
}) | null, exports?: unknown) => void) => void;
|
|
6
|
+
export type MainThreadHotUpdatesOptions = {
|
|
7
|
+
/** The main thread's `import.meta.webpackHot`. */
|
|
8
|
+
hot: HotApi;
|
|
9
|
+
/** The main thread's `lynx` global. */
|
|
10
|
+
lynx: {
|
|
11
|
+
requireModuleAsync?: RequireModuleAsync;
|
|
12
|
+
};
|
|
13
|
+
/** Lynx's `getJSContext()`, which reaches the background thread. */
|
|
14
|
+
context: ThreadContext;
|
|
15
|
+
/**
|
|
16
|
+
* Where `bootstrapApplication()` leaves its latest promise. Read through a
|
|
17
|
+
* function because each call replaces it.
|
|
18
|
+
*/
|
|
19
|
+
currentBootstrap: () => unknown;
|
|
20
|
+
/** Whether an app is running: the last bootstrap succeeded. */
|
|
21
|
+
appRunning: () => boolean;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Applies the main thread's half of each hot update, when the background
|
|
25
|
+
* thread asks (see background-hot-updates.ts).
|
|
26
|
+
*
|
|
27
|
+
* Webpack's hot update runtime is already in the main-thread bundle, with
|
|
28
|
+
* `module.hot` on every module, but nothing ever asked it to check, and it
|
|
29
|
+
* loads updates with `lynx.requireModuleAsync()`, which the main thread
|
|
30
|
+
* doesn't have. This gives the main thread one that has the background
|
|
31
|
+
* thread fetch the file (only it has network access) and runs it here, then
|
|
32
|
+
* runs the checks.
|
|
33
|
+
*
|
|
34
|
+
* After an update, it waits for the app to bootstrap again if the update
|
|
35
|
+
* re-ran the app's entry: the old app is gone by then, so a failure has to
|
|
36
|
+
* reload the page rather than leave it blank. It reports failure too when no
|
|
37
|
+
* app is running at all.
|
|
38
|
+
*/
|
|
39
|
+
export declare const startMainThreadHotUpdates: ({ hot, lynx, context, currentBootstrap, appRunning, }: MainThreadHotUpdatesOptions) => void;
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { HMR_CHECK_RESULT, HMR_FETCH_RESULT, HMR_CHECK, send, listen, formatError, HMR_FETCH } from "../544.js";
|
|
2
|
+
const evaluateChunk = (source, url)=>{
|
|
3
|
+
const module = {
|
|
4
|
+
exports: {}
|
|
5
|
+
};
|
|
6
|
+
new Function('module', 'exports', `${source}\n//# sourceURL=${url}`)(module, module.exports);
|
|
7
|
+
return module.exports;
|
|
8
|
+
};
|
|
9
|
+
const startMainThreadHotUpdates = ({ hot, lynx, context, currentBootstrap, appRunning })=>{
|
|
10
|
+
const fetches = new Map();
|
|
11
|
+
let nextFetchId = 0;
|
|
12
|
+
listen(context, HMR_FETCH_RESULT, (result)=>{
|
|
13
|
+
fetches.get(result.id)?.(result);
|
|
14
|
+
fetches.delete(result.id);
|
|
15
|
+
});
|
|
16
|
+
lynx.requireModuleAsync ??= (url, callback)=>{
|
|
17
|
+
const id = nextFetchId++;
|
|
18
|
+
fetches.set(id, (result)=>{
|
|
19
|
+
if ('error' in result) return void callback(new Error(`Loading ${url} failed: ${result.error}`));
|
|
20
|
+
if (404 === result.status) {
|
|
21
|
+
const error = new Error(`Cannot find module '${url}'`);
|
|
22
|
+
error.code = 'MODULE_NOT_FOUND';
|
|
23
|
+
callback(error);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (result.status >= 400) return void callback(new Error(`Loading ${url} failed with HTTP ${result.status}`));
|
|
27
|
+
let exports;
|
|
28
|
+
try {
|
|
29
|
+
exports = url.endsWith('.json') ? JSON.parse(result.text) : evaluateChunk(result.text, url);
|
|
30
|
+
} catch (error) {
|
|
31
|
+
callback(error);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
callback(null, exports);
|
|
35
|
+
});
|
|
36
|
+
send(context, HMR_FETCH, {
|
|
37
|
+
id,
|
|
38
|
+
url
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
const apply = async ()=>{
|
|
42
|
+
const status = hot.status();
|
|
43
|
+
if ('idle' !== status) return {
|
|
44
|
+
ok: false,
|
|
45
|
+
reason: `The hot update status is "${status}".`
|
|
46
|
+
};
|
|
47
|
+
const bootstrapBefore = currentBootstrap();
|
|
48
|
+
try {
|
|
49
|
+
const updatedModules = await hot.check(true);
|
|
50
|
+
if (!updatedModules) return {
|
|
51
|
+
ok: false,
|
|
52
|
+
reason: 'Cannot find update.'
|
|
53
|
+
};
|
|
54
|
+
const bootstrap = currentBootstrap();
|
|
55
|
+
if (bootstrap !== bootstrapBefore) await bootstrap;
|
|
56
|
+
if (!appRunning()) return {
|
|
57
|
+
ok: false,
|
|
58
|
+
reason: 'The app is not running.'
|
|
59
|
+
};
|
|
60
|
+
return {
|
|
61
|
+
ok: true,
|
|
62
|
+
updatedModules: updatedModules.length
|
|
63
|
+
};
|
|
64
|
+
} catch (error) {
|
|
65
|
+
return {
|
|
66
|
+
ok: false,
|
|
67
|
+
reason: formatError(error)
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
listen(context, HMR_CHECK, ({ id })=>{
|
|
72
|
+
apply().then((result)=>send(context, HMR_CHECK_RESULT, {
|
|
73
|
+
id,
|
|
74
|
+
...result
|
|
75
|
+
}));
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
export { startMainThreadHotUpdates };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ThreadContext } from '../hmr-protocol.js';
|
|
2
|
+
/**
|
|
3
|
+
* One thread's end of the cross-thread channel, for the client tests. It
|
|
4
|
+
* records what the code under test sends, and `receive()` plays a message
|
|
5
|
+
* from the other thread.
|
|
6
|
+
*/
|
|
7
|
+
export declare const createTestContext: () => {
|
|
8
|
+
context: ThreadContext;
|
|
9
|
+
sent: {
|
|
10
|
+
type: string;
|
|
11
|
+
message: any;
|
|
12
|
+
}[];
|
|
13
|
+
/** The messages of one type, in order. */
|
|
14
|
+
sentOf: (type: string) => any[];
|
|
15
|
+
receive: (type: string, message: object) => void;
|
|
16
|
+
};
|
|
@@ -1,43 +1,25 @@
|
|
|
1
|
+
import type { ComponentStyleSize } from './utils/angular/budgets.js';
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* Angular's inline-style handling surface; `processedFiles` deduplicates calls
|
|
5
|
-
* that Angular's AOT compiler makes multiple times for the same stylesheet.
|
|
3
|
+
* Drops the recorded stylesheet sizes of a component whose file was deleted,
|
|
4
|
+
* so `anyComponentStyle` budgets stop reporting styles that no longer ship.
|
|
6
5
|
*/
|
|
7
|
-
export
|
|
8
|
-
imports: string[];
|
|
9
|
-
inlineStyles: string[];
|
|
10
|
-
scopeId: string;
|
|
11
|
-
processedFiles: Map<string, string>;
|
|
12
|
-
};
|
|
13
|
-
export type ComponentScopeInfo = {
|
|
14
|
-
className: string;
|
|
15
|
-
scopeId: string;
|
|
16
|
-
};
|
|
6
|
+
export declare const forgetComponentStyleSizes: (componentStyleSizes: Map<string, ComponentStyleSize>, containingFile: string) => void;
|
|
17
7
|
/**
|
|
18
8
|
* Builds the `transformStylesheet` callback that Angular's AOT compiler invokes
|
|
19
9
|
* for every component stylesheet (inline `styles: []` and external `styleUrls`).
|
|
20
10
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* Extracted from angular.ts so the dedup / scoped-path / write-if-changed logic
|
|
27
|
-
* can be unit-tested directly by driving the returned callback, without standing
|
|
28
|
-
* up a full Angular compilation.
|
|
11
|
+
* It returns the CSS unchanged, so the compiler embeds it in the component's
|
|
12
|
+
* definition and scopes it for the component's `encapsulation`, as on the web.
|
|
13
|
+
* extractComponentStyles() (component-styles.ts) then lifts it back out of the
|
|
14
|
+
* compiled code as Lynx CSS. The callback only records each stylesheet's size,
|
|
15
|
+
* for `anyComponentStyle` budgets.
|
|
29
16
|
*/
|
|
30
17
|
export declare const createTransformStylesheet: (params: {
|
|
31
18
|
basePath: string;
|
|
32
|
-
scopedCssCacheDir: string;
|
|
33
|
-
componentStylesCache: Map<string, ComponentStylesEntry>;
|
|
34
|
-
componentScopeIds: Map<string, ComponentScopeInfo>;
|
|
35
19
|
/**
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* rspack as modified. Otherwise the CSS change would only ship on the
|
|
40
|
-
* following rebuild.
|
|
20
|
+
* The compiled size of every component stylesheet, for `anyComponentStyle`
|
|
21
|
+
* budgets. Overwritten each time Angular compiles a stylesheet, so watch
|
|
22
|
+
* rebuilds check the current sizes.
|
|
41
23
|
*/
|
|
42
|
-
|
|
24
|
+
componentStyleSizes?: Map<string, ComponentStyleSize>;
|
|
43
25
|
}) => ((data: string, containingFile: string, stylesheetFile: string | undefined, order: number, className: string | undefined) => Promise<string>);
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { ModuleStylesheets } from './transform-module.js';
|
|
2
|
+
/**
|
|
3
|
+
* One component's styles, lifted out of its compiled definition.
|
|
4
|
+
*/
|
|
5
|
+
export type ExtractedComponentStyles = {
|
|
6
|
+
className: string;
|
|
7
|
+
/**
|
|
8
|
+
* The ID the runtime builds the scope classes from. Only Emulated components
|
|
9
|
+
* need one, so it's `undefined` for the others.
|
|
10
|
+
*/
|
|
11
|
+
scopeId: string | undefined;
|
|
12
|
+
/** The stylesheets, ready to be written as CSS files. */
|
|
13
|
+
stylesheets: string[];
|
|
14
|
+
};
|
|
15
|
+
export type ExtractComponentStylesResult = {
|
|
16
|
+
/** The module's code, without the `styles` the stylesheets came from. */
|
|
17
|
+
code: string;
|
|
18
|
+
components: ExtractedComponentStyles[];
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Turns Angular's emulated-encapsulation CSS into CSS that Lynx can match.
|
|
22
|
+
*
|
|
23
|
+
* Angular's compiler scopes an Emulated component's styles with attribute
|
|
24
|
+
* selectors: `.title` becomes `.title[_ngcontent-%COMP%]`, `:host` becomes
|
|
25
|
+
* `[_nghost-%COMP%]`, and keyframe names gain a `_ngcontent-%COMP%_` prefix. On
|
|
26
|
+
* the web, the renderer puts those attributes on the elements. Lynx's selector
|
|
27
|
+
* matcher has no attribute selectors (`SelectorMatcher::MatchSimple` in Lynx
|
|
28
|
+
* core's css/ng/matcher only handles tag, class, id and pseudo-classes), so the
|
|
29
|
+
* attributes become classes here, and EmulatedLynxRenderer adds the same
|
|
30
|
+
* classes to the elements.
|
|
31
|
+
*/
|
|
32
|
+
export declare const toLynxScopedCss: (css: string, scopeId: string) => string;
|
|
33
|
+
/**
|
|
34
|
+
* Fills the CSS variable namespace placeholder Angular's compiler puts in every
|
|
35
|
+
* component's styles: `var(--muted)` compiles to `var(--%NS%muted)`. Angular's
|
|
36
|
+
* renderer fills it with `CSS_VAR_NAMESPACE`, which is empty unless an app
|
|
37
|
+
* opts in with `provideCssVarNamespacing()`. Lynx CSS is compiled ahead of
|
|
38
|
+
* time, so it gets the default here, and the variables keep their own names,
|
|
39
|
+
* which global stylesheets such as the theme define.
|
|
40
|
+
*/
|
|
41
|
+
export declare const fillCssVarNamespace: (css: string) => string;
|
|
42
|
+
/**
|
|
43
|
+
* Lifts each component's `styles` out of Angular's compiled output, so they
|
|
44
|
+
* can ship as Lynx CSS.
|
|
45
|
+
*
|
|
46
|
+
* Lynx can't add styles at runtime: CSS has to be compiled into the bundle.
|
|
47
|
+
* So the plugin lets Angular's compiler embed every component's styles in its
|
|
48
|
+
* definition, exactly as on the web (scoped for `ViewEncapsulation.Emulated`,
|
|
49
|
+
* left global for `None` and `ShadowDom`), then takes them back out here. That
|
|
50
|
+
* keeps each component's styles with its own encapsulation, even when two
|
|
51
|
+
* components share a stylesheet file, and removes the CSS strings from the
|
|
52
|
+
* JavaScript.
|
|
53
|
+
*
|
|
54
|
+
* Only `styles` arrays made of string literals are taken, which is what the
|
|
55
|
+
* compiler emits. Anything else is left in place.
|
|
56
|
+
*/
|
|
57
|
+
export declare const extractComponentStyles: (code: string, fileName: string) => ExtractComponentStylesResult;
|
|
58
|
+
/**
|
|
59
|
+
* Writes the stylesheets extracted from one module as CSS files, so the
|
|
60
|
+
* module can import them and css-extract compiles them into the bundle.
|
|
61
|
+
*
|
|
62
|
+
* A file is only rewritten when its content changed, and each rewrite is
|
|
63
|
+
* reported through `onWritten`: on a watch rebuild the files change after
|
|
64
|
+
* rspack's watcher collected the edit, so the plugin reports them to rspack as
|
|
65
|
+
* changed, or the new CSS would only ship on the following rebuild.
|
|
66
|
+
*/
|
|
67
|
+
export declare const writeModuleStylesheets: (params: {
|
|
68
|
+
basePath: string;
|
|
69
|
+
cacheDir: string;
|
|
70
|
+
fileName: string;
|
|
71
|
+
components: readonly ExtractedComponentStyles[];
|
|
72
|
+
onWritten?: (filePath: string) => void;
|
|
73
|
+
}) => ModuleStylesheets | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export type CrossThreadTransformOptions = {
|
|
2
|
+
/** The directory the file keys are relative to, the same for both bundles. */
|
|
3
|
+
root: string;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Gives each module-level `backgroundFn(fn)`, `createMainThreadRef(value)` and
|
|
7
|
+
* `new MainThreadRef(value)` one more argument: an ID from the file and the
|
|
8
|
+
* call's position, such as `'3f9a1c2b7d:0'`.
|
|
9
|
+
*
|
|
10
|
+
* Angular runs on the main thread only, but the background thread runs the
|
|
11
|
+
* modules that make these calls too (see background-entry.ts), for the
|
|
12
|
+
* functions that main-thread code calls there. The main thread sends a handle
|
|
13
|
+
* or ref across by this ID, and the other thread finds its own copy by it.
|
|
14
|
+
* The runtime's fallback is a counter, which only matches if both threads run
|
|
15
|
+
* the same calls in the same order. They don't: the background thread runs
|
|
16
|
+
* only some of the app's modules, and in a different order, and Angular code
|
|
17
|
+
* (which also creates refs) runs on the main thread only.
|
|
18
|
+
*
|
|
19
|
+
* Calls inside a function or class are left alone, since one call site can run
|
|
20
|
+
* any number of times there.
|
|
21
|
+
*
|
|
22
|
+
* @param code - The module's JavaScript.
|
|
23
|
+
* @param filename - The module's path.
|
|
24
|
+
* @param options - See {@link CrossThreadTransformOptions}.
|
|
25
|
+
* @returns The transformed code, or `code` itself when nothing applies.
|
|
26
|
+
*/
|
|
27
|
+
export declare const transformCrossThread: (code: string, filename: string, options: CrossThreadTransformOptions) => string;
|
|
28
|
+
/**
|
|
29
|
+
* Whether the module calls `backgroundFn()`, `createMainThreadRef()` or
|
|
30
|
+
* `new MainThreadRef()` at module level, so the background thread has to run
|
|
31
|
+
* it too. These are the calls {@link transformCrossThread} tags.
|
|
32
|
+
*
|
|
33
|
+
* @param code - The module's JavaScript.
|
|
34
|
+
* @param filename - The module's path.
|
|
35
|
+
* @returns `true` when the module defines a value the main thread can send
|
|
36
|
+
* across by ID.
|
|
37
|
+
*/
|
|
38
|
+
export declare const definesCrossThreadValues: (code: string, filename: string) => boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/css.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { RsbuildPluginAPI } from '@lynx-js/rspeedy';
|
|
2
2
|
import type { CSSLoaderOptions } from '@rsbuild/core';
|
|
3
|
-
import type {
|
|
4
|
-
export declare const applyCSS: (api: RsbuildPluginAPI, options:
|
|
3
|
+
import type { NormalizedPluginAngularLynxOptions } from './utils/options.js';
|
|
4
|
+
export declare const applyCSS: (api: RsbuildPluginAPI, options: NormalizedPluginAngularLynxOptions) => void;
|
|
5
5
|
/**
|
|
6
6
|
* This is copied from https://github.com/web-infra-dev/rsbuild/blob/9f8be2d71ffeb7da969cda36fd9755db2cadaff5/packages/core/src/plugins/css.ts#L42
|
|
7
7
|
*
|
package/dist/entry.d.ts
CHANGED
|
@@ -1,7 +1,33 @@
|
|
|
1
1
|
import type { RsbuildPluginAPI, Rspack } from '@lynx-js/rspeedy';
|
|
2
2
|
import type { UndefinedOnPartialDeep } from 'type-fest';
|
|
3
|
-
import type {
|
|
4
|
-
|
|
3
|
+
import type { BackgroundEntries } from './background-entry.js';
|
|
4
|
+
import type { NormalizedPluginAngularLynxOptions } from './utils/options.js';
|
|
5
|
+
/**
|
|
6
|
+
* The key `pluginLynx` (the Lynx build engine, which Rspeedy registers) exposes
|
|
7
|
+
* its resolved config under. Mirrors `S_LYNX_CONFIG` in React Lynx's plugin.
|
|
8
|
+
*/
|
|
9
|
+
export declare const S_LYNX_CONFIG: unique symbol;
|
|
10
|
+
/**
|
|
11
|
+
* The `blur-view` rule that approximates iOS's blur materials on Android,
|
|
12
|
+
* from variables the runtime sets (see the file). Only the native bundle gets
|
|
13
|
+
* it: web draws the materials itself, in the element's shadow root, and an
|
|
14
|
+
* app-level rule there would beat them. It goes before every other import, so
|
|
15
|
+
* the app's own stylesheets come later and win a tie.
|
|
16
|
+
*/
|
|
17
|
+
export declare const BLUR_VIEW_STYLESHEET: string;
|
|
18
|
+
/**
|
|
19
|
+
* The hot update clients (see client/). The background one stands in for
|
|
20
|
+
* `@rspack/core/hot/dev-server`; the main-thread one gives the main thread its
|
|
21
|
+
* own hot updates. Together they apply each update on both threads, or reload.
|
|
22
|
+
*/
|
|
23
|
+
export declare const HMR_BACKGROUND_CLIENT: string;
|
|
24
|
+
export declare const HMR_MAIN_THREAD_CLIENT: string;
|
|
25
|
+
/**
|
|
26
|
+
* Applies stylesheet edits on the main thread, in place of css-extract's
|
|
27
|
+
* `runtime/hotModuleReplacement.cjs` (see client/css-hot-update.ts).
|
|
28
|
+
*/
|
|
29
|
+
export declare const CSS_HOT_UPDATE: string;
|
|
30
|
+
export declare const applyEntry: (api: RsbuildPluginAPI, options: NormalizedPluginAngularLynxOptions, backgroundEntries: BackgroundEntries, appEntries: Set<string>) => void;
|
|
5
31
|
/**
|
|
6
32
|
* This is copied from https://github.com/web-infra-dev/rsbuild/blob/037da7b9d92e20c7136c8b2efa21eef539fa2f88/packages/core/src/plugins/html.ts#L168
|
|
7
33
|
*/
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether a build environment takes hot updates, under the same conditions
|
|
3
|
+
* entry.ts adds the hot update clients: a development build of a Lynx
|
|
4
|
+
* environment (the web preview has none) without `dev.hmr: false`.
|
|
5
|
+
*
|
|
6
|
+
* @param environment - The environment, as Rsbuild passes it to a transform.
|
|
7
|
+
* @returns Whether modules should take hot updates.
|
|
8
|
+
*/
|
|
9
|
+
export declare const hotUpdatesEnabled: (environment: {
|
|
10
|
+
name: string;
|
|
11
|
+
config: {
|
|
12
|
+
mode?: string;
|
|
13
|
+
dev?: {
|
|
14
|
+
hmr?: boolean;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
}) => boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Hashes a component file's source without its components' templates and
|
|
20
|
+
* styles. Two versions of a file with the same signature differ only in what
|
|
21
|
+
* a hot update can apply in place (see `ɵhmrAccept` in the runtime). An
|
|
22
|
+
* external template or stylesheet isn't in the source at all, so editing one
|
|
23
|
+
* leaves the signature as it was.
|
|
24
|
+
*
|
|
25
|
+
* @param source - The file's TypeScript source.
|
|
26
|
+
* @param fileName - The file's path, for the parser.
|
|
27
|
+
* @returns The signature.
|
|
28
|
+
*/
|
|
29
|
+
export declare const hotUpdateSignature: (source: string, fileName: string) => string;
|
|
30
|
+
/**
|
|
31
|
+
* Finds the components a module's compiled code defines, as the names of
|
|
32
|
+
* their classes. Only classes declared at the top of the module are listed,
|
|
33
|
+
* because the code {@link addHotAccept} appends assigns to them there.
|
|
34
|
+
*
|
|
35
|
+
* @param code - The module's code, as Angular's compiler emitted it.
|
|
36
|
+
* @param fileName - The module's path, for the parser.
|
|
37
|
+
* @returns The class names, in the order the module defines them.
|
|
38
|
+
*/
|
|
39
|
+
export declare const componentClassNames: (code: string, fileName: string) => string[];
|
|
40
|
+
/**
|
|
41
|
+
* Makes a module that defines components take its own hot updates, through
|
|
42
|
+
* the runtime's `ɵhmrAccept`. The call reassigns the module's component
|
|
43
|
+
* classes to what it returns, so after an in-place update the module's
|
|
44
|
+
* exports are the classes the running app already uses.
|
|
45
|
+
*
|
|
46
|
+
* @param code - The module's code.
|
|
47
|
+
* @param options.components - The names of the module's component classes.
|
|
48
|
+
* @param options.signature - The source's {@link hotUpdateSignature}.
|
|
49
|
+
* @param options.compiled - The code Angular's compiler emitted for the
|
|
50
|
+
* module, before the plugin's other transforms.
|
|
51
|
+
* @returns The code with the call appended.
|
|
52
|
+
*/
|
|
53
|
+
export declare const addHotAccept: (code: string, { components, signature, compiled, }: {
|
|
54
|
+
components: string[];
|
|
55
|
+
signature: string;
|
|
56
|
+
compiled: string;
|
|
57
|
+
}) => string;
|
|
58
|
+
/**
|
|
59
|
+
* Makes the app's entry module take every hot update its imports pass on.
|
|
60
|
+
* Re-running the entry calls `bootstrapApplication()` again, which replaces
|
|
61
|
+
* the running app with one built from the updated modules (on the main
|
|
62
|
+
* thread; the background thread runs no app).
|
|
63
|
+
*
|
|
64
|
+
* @param code - The entry module's code.
|
|
65
|
+
* @returns The code with the self-accept appended.
|
|
66
|
+
*/
|
|
67
|
+
export declare const addEntryHotAccept: (code: string) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
-
export { pluginAngularLynx } from './plugin-angular-lynx';
|
|
1
|
+
export { pluginAngularLynx } from './plugin-angular-lynx.js';
|
|
2
|
+
export type { PluginAngularLynxOptions } from './utils/options.js';
|
|
3
|
+
export { type AngularCliContext, pluginAngularCliContext, } from './angular-cli-context.js';
|