@ecopages/react 0.2.0-alpha.8 → 0.2.0-beta.0

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.
Files changed (77) hide show
  1. package/README.md +30 -13
  2. package/package.json +23 -12
  3. package/src/eco-embed.d.ts +11 -0
  4. package/src/eco-embed.js +11 -0
  5. package/src/react-hmr-strategy.d.ts +102 -18
  6. package/src/react-hmr-strategy.js +427 -50
  7. package/src/react-renderer.d.ts +100 -92
  8. package/src/react-renderer.js +356 -340
  9. package/src/react.constants.d.ts +1 -0
  10. package/src/react.constants.js +4 -0
  11. package/src/react.plugin.d.ts +25 -107
  12. package/src/react.plugin.js +109 -61
  13. package/src/react.types.d.ts +88 -0
  14. package/src/react.types.js +0 -0
  15. package/src/router-adapter.d.ts +7 -14
  16. package/src/runtime/use-sync-external-store-with-selector.d.ts +3 -0
  17. package/src/runtime/use-sync-external-store-with-selector.js +56 -0
  18. package/src/services/pages-index.d.ts +64 -0
  19. package/src/services/pages-index.js +73 -0
  20. package/src/services/react-bundle.service.d.ts +24 -9
  21. package/src/services/react-bundle.service.js +35 -24
  22. package/src/services/react-hmr-page-metadata-cache.d.ts +10 -1
  23. package/src/services/react-hmr-page-metadata-cache.js +18 -2
  24. package/src/services/react-hydration-asset.service.d.ts +28 -19
  25. package/src/services/react-hydration-asset.service.js +83 -64
  26. package/src/services/react-mdx-config-dependency.service.d.ts +36 -0
  27. package/src/services/react-mdx-config-dependency.service.js +122 -0
  28. package/src/services/react-page-module.service.d.ts +8 -3
  29. package/src/services/react-page-module.service.js +33 -26
  30. package/src/services/react-page-payload.service.d.ts +46 -0
  31. package/src/services/react-page-payload.service.js +67 -0
  32. package/src/services/react-runtime-bundle.service.d.ts +9 -2
  33. package/src/services/react-runtime-bundle.service.js +77 -16
  34. package/src/utils/client-graph-boundary-cache.d.ts +108 -0
  35. package/src/utils/client-graph-boundary-cache.js +116 -0
  36. package/src/utils/client-graph-boundary-plugin.d.ts +13 -5
  37. package/src/utils/client-graph-boundary-plugin.js +63 -5
  38. package/src/utils/component-config-traversal.d.ts +36 -0
  39. package/src/utils/component-config-traversal.js +54 -0
  40. package/src/utils/declared-modules.d.ts +1 -1
  41. package/src/utils/declared-modules.js +7 -16
  42. package/src/utils/dynamic.test.browser.d.ts +1 -0
  43. package/src/utils/dynamic.test.browser.js +33 -0
  44. package/src/utils/hydration-scripts.d.ts +9 -5
  45. package/src/utils/hydration-scripts.js +119 -34
  46. package/src/utils/hydration-scripts.test.browser.d.ts +1 -0
  47. package/src/utils/hydration-scripts.test.browser.js +198 -0
  48. package/src/utils/react-dom-runtime-interop-plugin.d.ts +1 -1
  49. package/src/utils/react-dom-runtime-interop-plugin.js +9 -0
  50. package/src/utils/react-mdx-loader-plugin.d.ts +1 -1
  51. package/src/utils/{react-runtime-specifier-map.d.ts → react-runtime-alias-map.d.ts} +3 -1
  52. package/src/utils/react-runtime-alias-map.js +90 -0
  53. package/CHANGELOG.md +0 -27
  54. package/src/react-hmr-strategy.ts +0 -386
  55. package/src/react-renderer.ts +0 -803
  56. package/src/react.plugin.ts +0 -276
  57. package/src/router-adapter.ts +0 -95
  58. package/src/services/react-bundle.service.ts +0 -108
  59. package/src/services/react-hmr-page-metadata-cache.ts +0 -24
  60. package/src/services/react-hydration-asset.service.ts +0 -263
  61. package/src/services/react-page-module.service.ts +0 -224
  62. package/src/services/react-runtime-bundle.service.ts +0 -172
  63. package/src/utils/client-graph-boundary-plugin.ts +0 -831
  64. package/src/utils/client-only.ts +0 -27
  65. package/src/utils/declared-modules.ts +0 -99
  66. package/src/utils/dynamic.ts +0 -27
  67. package/src/utils/hmr-scripts.ts +0 -47
  68. package/src/utils/html-boundary.ts +0 -66
  69. package/src/utils/hydration-scripts.ts +0 -459
  70. package/src/utils/reachability-analyzer.ts +0 -593
  71. package/src/utils/react-dom-runtime-interop-plugin.ts +0 -33
  72. package/src/utils/react-mdx-loader-plugin.ts +0 -63
  73. package/src/utils/react-runtime-specifier-map.js +0 -37
  74. package/src/utils/react-runtime-specifier-map.ts +0 -45
  75. package/src/utils/use-sync-external-store-shim-plugin.d.ts +0 -5
  76. package/src/utils/use-sync-external-store-shim-plugin.js +0 -41
  77. package/src/utils/use-sync-external-store-shim-plugin.ts +0 -45
@@ -1,37 +0,0 @@
1
- const REACT_RUNTIME_SPECIFIERS = [
2
- "react",
3
- "react-dom",
4
- "react/jsx-runtime",
5
- "react/jsx-dev-runtime",
6
- "react-dom/client"
7
- ];
8
- function buildReactRuntimeSpecifierMap(runtimeImports, routerAdapter) {
9
- const map = {
10
- react: runtimeImports.react,
11
- "react/jsx-runtime": runtimeImports.reactJsxRuntime,
12
- "react/jsx-dev-runtime": runtimeImports.reactJsxDevRuntime,
13
- "react-dom": runtimeImports.reactDom,
14
- "react-dom/client": runtimeImports.reactDomClient
15
- };
16
- if (routerAdapter && runtimeImports.router) {
17
- map[routerAdapter.importMapKey] = runtimeImports.router;
18
- }
19
- return map;
20
- }
21
- function getReactRuntimeExternalSpecifiers() {
22
- return [...REACT_RUNTIME_SPECIFIERS];
23
- }
24
- function getReactClientGraphAllowSpecifiers(runtimeSpecifiers, routerAdapter) {
25
- return [
26
- "@ecopages/core",
27
- ...REACT_RUNTIME_SPECIFIERS,
28
- ...routerAdapter ? [routerAdapter.importMapKey] : [],
29
- ...Array.from(runtimeSpecifiers)
30
- ];
31
- }
32
- export {
33
- REACT_RUNTIME_SPECIFIERS,
34
- buildReactRuntimeSpecifierMap,
35
- getReactClientGraphAllowSpecifiers,
36
- getReactRuntimeExternalSpecifiers
37
- };
@@ -1,45 +0,0 @@
1
- import type { ReactRouterAdapter } from '../router-adapter.ts';
2
- import type { ReactRuntimeImports } from '../services/react-runtime-bundle.service.ts';
3
-
4
- export const REACT_RUNTIME_SPECIFIERS = [
5
- 'react',
6
- 'react-dom',
7
- 'react/jsx-runtime',
8
- 'react/jsx-dev-runtime',
9
- 'react-dom/client',
10
- ] as const;
11
-
12
- export function buildReactRuntimeSpecifierMap(
13
- runtimeImports: ReactRuntimeImports,
14
- routerAdapter?: ReactRouterAdapter,
15
- ): Record<string, string> {
16
- const map: Record<string, string> = {
17
- react: runtimeImports.react,
18
- 'react/jsx-runtime': runtimeImports.reactJsxRuntime,
19
- 'react/jsx-dev-runtime': runtimeImports.reactJsxDevRuntime,
20
- 'react-dom': runtimeImports.reactDom,
21
- 'react-dom/client': runtimeImports.reactDomClient,
22
- };
23
-
24
- if (routerAdapter && runtimeImports.router) {
25
- map[routerAdapter.importMapKey] = runtimeImports.router;
26
- }
27
-
28
- return map;
29
- }
30
-
31
- export function getReactRuntimeExternalSpecifiers(): string[] {
32
- return [...REACT_RUNTIME_SPECIFIERS];
33
- }
34
-
35
- export function getReactClientGraphAllowSpecifiers(
36
- runtimeSpecifiers: Iterable<string>,
37
- routerAdapter?: ReactRouterAdapter,
38
- ): string[] {
39
- return [
40
- '@ecopages/core',
41
- ...REACT_RUNTIME_SPECIFIERS,
42
- ...(routerAdapter ? [routerAdapter.importMapKey] : []),
43
- ...Array.from(runtimeSpecifiers),
44
- ];
45
- }
@@ -1,5 +0,0 @@
1
- import type { EcoBuildPlugin } from '@ecopages/core/build/build-types';
2
- export declare function createUseSyncExternalStoreShimPlugin(options?: {
3
- name?: string;
4
- namespace?: string;
5
- }): EcoBuildPlugin;
@@ -1,41 +0,0 @@
1
- function createUseSyncExternalStoreShimPlugin(options) {
2
- const namespace = options?.namespace ?? "ecopages-react-use-sync-external-store-shim";
3
- return {
4
- name: options?.name ?? "react-use-sync-external-store-shim",
5
- setup(build) {
6
- build.onResolve({ filter: /^use-sync-external-store\/shim(?:\/index\.js)?$/ }, () => ({
7
- path: "use-sync-external-store/shim",
8
- namespace
9
- }));
10
- build.onLoad({ filter: /^use-sync-external-store\/shim$/, namespace }, () => ({
11
- contents: "export { useSyncExternalStore } from 'react';",
12
- loader: "js"
13
- }));
14
- build.onLoad({ filter: /[\\/]use-sync-external-store[\\/]shim[\\/]index\.js$/ }, () => ({
15
- contents: "export { useSyncExternalStore } from 'react';",
16
- loader: "js"
17
- }));
18
- build.onLoad(
19
- {
20
- filter: /[\\/]use-sync-external-store[\\/]cjs[\\/]use-sync-external-store-shim\.development\.js$/
21
- },
22
- () => ({
23
- contents: "export { useSyncExternalStore } from 'react';",
24
- loader: "js"
25
- })
26
- );
27
- build.onLoad(
28
- {
29
- filter: /[\\/]use-sync-external-store[\\/]cjs[\\/]use-sync-external-store-shim\.production\.js$/
30
- },
31
- () => ({
32
- contents: "export { useSyncExternalStore } from 'react';",
33
- loader: "js"
34
- })
35
- );
36
- }
37
- };
38
- }
39
- export {
40
- createUseSyncExternalStoreShimPlugin
41
- };
@@ -1,45 +0,0 @@
1
- import type { EcoBuildPlugin } from '@ecopages/core/build/build-types';
2
-
3
- export function createUseSyncExternalStoreShimPlugin(options?: { name?: string; namespace?: string }): EcoBuildPlugin {
4
- const namespace = options?.namespace ?? 'ecopages-react-use-sync-external-store-shim';
5
-
6
- return {
7
- name: options?.name ?? 'react-use-sync-external-store-shim',
8
- setup(build) {
9
- build.onResolve({ filter: /^use-sync-external-store\/shim(?:\/index\.js)?$/ }, () => ({
10
- path: 'use-sync-external-store/shim',
11
- namespace,
12
- }));
13
-
14
- build.onLoad({ filter: /^use-sync-external-store\/shim$/, namespace }, () => ({
15
- contents: "export { useSyncExternalStore } from 'react';",
16
- loader: 'js',
17
- }));
18
-
19
- build.onLoad({ filter: /[\\/]use-sync-external-store[\\/]shim[\\/]index\.js$/ }, () => ({
20
- contents: "export { useSyncExternalStore } from 'react';",
21
- loader: 'js',
22
- }));
23
-
24
- build.onLoad(
25
- {
26
- filter: /[\\/]use-sync-external-store[\\/]cjs[\\/]use-sync-external-store-shim\.development\.js$/,
27
- },
28
- () => ({
29
- contents: "export { useSyncExternalStore } from 'react';",
30
- loader: 'js',
31
- }),
32
- );
33
-
34
- build.onLoad(
35
- {
36
- filter: /[\\/]use-sync-external-store[\\/]cjs[\\/]use-sync-external-store-shim\.production\.js$/,
37
- },
38
- () => ({
39
- contents: "export { useSyncExternalStore } from 'react';",
40
- loader: 'js',
41
- }),
42
- );
43
- },
44
- };
45
- }