react-on-rails-pro 16.3.0 → 16.4.0-rc.1
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.
|
@@ -10,6 +10,7 @@ export default class CallbackRegistry<T> {
|
|
|
10
10
|
set(name: string, item: T): void;
|
|
11
11
|
get(name: string): T;
|
|
12
12
|
has(name: string): boolean;
|
|
13
|
+
getIfExists(name: string): T | undefined;
|
|
13
14
|
clear(): void;
|
|
14
15
|
getAll(): Map<string, T>;
|
|
15
16
|
getOrWaitForItem(name: string): Promise<T>;
|
package/lib/CallbackRegistry.js
CHANGED
package/lib/ComponentRegistry.js
CHANGED
|
@@ -20,13 +20,17 @@ const componentRegistry = new CallbackRegistry('component');
|
|
|
20
20
|
*/
|
|
21
21
|
export function register(components) {
|
|
22
22
|
Object.keys(components).forEach((name) => {
|
|
23
|
-
if (componentRegistry.has(name)) {
|
|
24
|
-
console.warn('Called register for component that is already registered', name);
|
|
25
|
-
}
|
|
26
23
|
const component = components[name];
|
|
27
24
|
if (!component) {
|
|
28
25
|
throw new Error(`Called register with null component named ${name}`);
|
|
29
26
|
}
|
|
27
|
+
// Reference comparison lets HMR re-register the same component silently
|
|
28
|
+
// while still catching bugs where different components share a name.
|
|
29
|
+
const existing = componentRegistry.getIfExists(name);
|
|
30
|
+
if (existing && existing.component !== component) {
|
|
31
|
+
console.error(`ReactOnRails: Component "${name}" was registered with a different component than previously. ` +
|
|
32
|
+
'This is likely a bug — ensure each component has a unique registration name.');
|
|
33
|
+
}
|
|
30
34
|
const renderFunction = isRenderFunction(component);
|
|
31
35
|
const isRenderer = renderFunction && component.length === 3;
|
|
32
36
|
componentRegistry.set(name, {
|
package/lib/StoreRegistry.js
CHANGED
|
@@ -21,14 +21,18 @@ const hydratedStoreRegistry = new CallbackRegistry('hydrated store');
|
|
|
21
21
|
*/
|
|
22
22
|
export function register(storeGenerators) {
|
|
23
23
|
Object.keys(storeGenerators).forEach((name) => {
|
|
24
|
-
if (storeGeneratorRegistry.has(name)) {
|
|
25
|
-
console.warn('Called registerStore for store that is already registered', name);
|
|
26
|
-
}
|
|
27
24
|
const storeGenerator = storeGenerators[name];
|
|
28
25
|
if (!storeGenerator) {
|
|
29
26
|
throw new Error('Called ReactOnRails.registerStoreGenerators with a null or undefined as a value ' +
|
|
30
27
|
`for the store generator with key ${name}.`);
|
|
31
28
|
}
|
|
29
|
+
// Reference comparison lets HMR re-register the same store silently
|
|
30
|
+
// while still catching bugs where different stores share a name.
|
|
31
|
+
const existing = storeGeneratorRegistry.getIfExists(name);
|
|
32
|
+
if (existing && existing !== storeGenerator) {
|
|
33
|
+
console.error(`ReactOnRails: Store "${name}" was registered with a different store generator than previously. ` +
|
|
34
|
+
'This is likely a bug — ensure each store has a unique registration name.');
|
|
35
|
+
}
|
|
32
36
|
storeGeneratorRegistry.set(name, storeGenerator);
|
|
33
37
|
});
|
|
34
38
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-on-rails-pro",
|
|
3
|
-
"version": "16.
|
|
3
|
+
"version": "16.4.0-rc.1",
|
|
4
4
|
"description": "React on Rails Pro package with React Server Components support",
|
|
5
5
|
"main": "lib/ReactOnRails.full.js",
|
|
6
6
|
"type": "module",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"./ServerComponentFetchError": "./lib/ServerComponentFetchError.js"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"react-on-rails": "16.
|
|
46
|
+
"react-on-rails": "16.4.0-rc.1"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
49
|
"react": ">= 16",
|
|
@@ -77,8 +77,6 @@
|
|
|
77
77
|
"test": "pnpm run test:non-rsc && pnpm run test:rsc",
|
|
78
78
|
"test:non-rsc": "jest tests --testPathIgnorePatterns=\".*(RSC|stream|registerServerComponent|serverRenderReactComponent|SuspenseHydration).*\"",
|
|
79
79
|
"test:rsc": "node scripts/check-react-version.cjs || NODE_CONDITIONS=react-server jest tests/*.rsc.test.*",
|
|
80
|
-
"type-check": "tsc --noEmit --noErrorTruncation"
|
|
81
|
-
"yalc:publish": "yalc publish",
|
|
82
|
-
"yalc": "yalc"
|
|
80
|
+
"type-check": "tsc --noEmit --noErrorTruncation"
|
|
83
81
|
}
|
|
84
82
|
}
|