Skip to content

Commit 42c47a0

Browse files
feat: export add trusted context (#5399)
* feat: export add trusted context * fix: addTrustedContext alias * fix: bundle size
1 parent c921979 commit 42c47a0

File tree

8 files changed

+22
-10
lines changed

8 files changed

+22
-10
lines changed

packages/@lwc/engine-core/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,15 @@ If `setTrustedSignalSet` is called more than once, it will throw an error. If it
124124

125125
### setContextKeys
126126

127-
Not intended for external use. Enables another library to establish contextful relationships via the LWC component tree. The `connectContext` and `disconnectContext` symbols that are provided are later used to identify methods that facilitate the establishment and dissolution of these contextful relationships.
127+
Not intended for external use. Enables another library to establish contextful relationships via the LWC component tree. The `connectContext` and `disconnectContext` symbols that are provided are later used to identify methods that facilitate the establishment and dissolution of these contextful relationships. The [ENABLE_EXPERIMENTAL_SIGNALS](https://github.com/salesforce/lwc/blob/master/packages/%40lwc/features/README.md#lwcfeatures) feature must be enabled.
128128

129129
### setTrustedContextSet()
130130

131-
Not intended for external use. This experimental API enables the addition of context as trusted context. If the [ENABLE_EXPERIMENTAL_SIGNALS](https://github.com/salesforce/lwc/blob/master/packages/%40lwc/features/README.md#lwcfeatures) feature is enabled.
131+
Not intended for external use. This experimental API enables the addition of context as trusted context. The [ENABLE_EXPERIMENTAL_SIGNALS](https://github.com/salesforce/lwc/blob/master/packages/%40lwc/features/README.md#lwcfeatures) feature must be enabled.
132132

133133
If `setTrustedContextSet` is called more than once, it will throw an error. If it is never called, then context will not be connected.
134134

135135
### ContextBinding
136136

137137
The context object's `connectContext` and `disconnectContext` methods are called with this object when contextful components are connected and disconnected. The ContextBinding exposes `provideContext` and `consumeContext`,
138-
enabling the provision/consumption of a contextful Signal of a specified variety for the associated component.
138+
enabling the provision/consumption of a contextful Signal of a specified variety for the associated component. The [ENABLE_EXPERIMENTAL_SIGNALS](https://github.com/salesforce/lwc/blob/master/packages/%40lwc/features/README.md#lwcfeatures) feature must be enabled.

packages/@lwc/engine-core/src/framework/main.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,10 @@ export { default as wire } from './decorators/wire';
7373
export { readonly } from './readonly';
7474

7575
export { setFeatureFlag, setFeatureFlagForTest } from '@lwc/features';
76-
export { setContextKeys, setTrustedSignalSet, setTrustedContextSet } from '@lwc/shared';
76+
export {
77+
setContextKeys,
78+
setTrustedSignalSet,
79+
setTrustedContextSet,
80+
addTrustedContext,
81+
} from '@lwc/shared';
7782
export type { Stylesheet, Stylesheets } from '@lwc/shared';

packages/@lwc/engine-dom/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export {
3333
setContextKeys,
3434
setTrustedSignalSet,
3535
setTrustedContextSet,
36+
addTrustedContext as __dangerous_do_not_use_addTrustedContext,
3637
swapComponent,
3738
swapStyle,
3839
swapTemplate,

packages/@lwc/engine-server/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export {
3030
parseFragment,
3131
parseFragment as parseSVGFragment,
3232
setTrustedContextSet,
33+
addTrustedContext as __dangerous_do_not_use_addTrustedContext,
3334
setContextKeys,
3435
} from '@lwc/engine-core';
3536

packages/@lwc/integration-karma/test-hydration/context/x/contextManager/contextManager.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import { setContextKeys, setTrustedContextSet } from 'lwc';
1+
import {
2+
setContextKeys,
3+
setTrustedContextSet,
4+
__dangerous_do_not_use_addTrustedContext,
5+
} from 'lwc';
26

37
const connectContext = Symbol('connectContext');
48
const disconnectContext = Symbol('disconnectContext');
@@ -16,7 +20,7 @@ class MockContextSignal {
1620
this.value = initialValue;
1721
this.contextDefinition = contextDefinition;
1822
this.fromContext = fromContext;
19-
trustedContext.add(this);
23+
__dangerous_do_not_use_addTrustedContext(this);
2024
}
2125
[connectContext](runtimeAdapter) {
2226
this.connectProvidedComponent = runtimeAdapter.component;

packages/@lwc/ssr-runtime/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export {
1717
setContextKeys,
1818
setTrustedSignalSet,
1919
setTrustedContextSet,
20+
addTrustedContext as __dangerous_do_not_use_addTrustedContext,
2021
} from '@lwc/shared';
2122

2223
export { setFeatureFlag, setFeatureFlagForTest } from '@lwc/features';

packages/lwc/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,15 @@ If `setTrustedSignalSet` is called more than once, it will throw an error. If it
9090

9191
### setContextKeys
9292

93-
Not intended for external use. Enables another library to establish contextful relationships via the LWC component tree. The `connectContext` and `disconnectContext` symbols that are provided are later used to identify methods that facilitate the establishment and dissolution of these contextful relationships.
93+
Not intended for external use. Enables another library to establish contextful relationships via the LWC component tree. The `connectContext` and `disconnectContext` symbols that are provided are later used to identify methods that facilitate the establishment and dissolution of these contextful relationships. The [ENABLE_EXPERIMENTAL_SIGNALS](https://github.com/salesforce/lwc/blob/master/packages/%40lwc/features/README.md#lwcfeatures) feature must be enabled.
9494

9595
### setTrustedContextSet()
9696

97-
Not intended for external use. This experimental API enables the addition of context as trusted context. If the [ENABLE_EXPERIMENTAL_SIGNALS](https://github.com/salesforce/lwc/blob/master/packages/%40lwc/features/README.md#lwcfeatures) feature is enabled.
97+
Not intended for external use. This experimental API enables the addition of context as trusted context. The [ENABLE_EXPERIMENTAL_SIGNALS](https://github.com/salesforce/lwc/blob/master/packages/%40lwc/features/README.md#lwcfeatures) feature must be enabled.
9898

9999
If `setTrustedContextSet` is called more than once, it will throw an error. If it is never called, then context will not be connected.
100100

101101
### ContextBinding
102102

103103
The context object's `connectContext` and `disconnectContext` methods are called with this object when contextful components are connected and disconnected. The ContextBinding exposes `provideContext` and `consumeContext`,
104-
enabling the provision/consumption of a contextful Signal of a specified variety for the associated component.
104+
enabling the provision/consumption of a contextful Signal of a specified variety for the associated component. The [ENABLE_EXPERIMENTAL_SIGNALS](https://github.com/salesforce/lwc/blob/master/packages/%40lwc/features/README.md#lwcfeatures) feature must be enabled.

scripts/bundlesize/bundlesize.config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"files": [
33
{
44
"path": "packages/@lwc/engine-dom/dist/index.js",
5-
"maxSize": "24.59KB"
5+
"maxSize": "24.62KB"
66
},
77
{
88
"path": "packages/@lwc/synthetic-shadow/dist/index.js",

0 commit comments

Comments
 (0)