@ecopages/react 0.2.0-beta.4 → 0.2.0-beta.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.
Files changed (142) hide show
  1. package/README.md +175 -7
  2. package/package.json +54 -29
  3. package/src/app/client-only.js +15 -0
  4. package/src/app/dynamic.js +9 -0
  5. package/src/app/dynamic.test.browser.js +31 -0
  6. package/src/bundling/bootstrap-package-paths.d.ts +5 -0
  7. package/src/bundling/bootstrap-package-paths.js +5 -0
  8. package/src/{services/react-bundle.service.d.ts → bundling/bundle.d.ts} +23 -8
  9. package/src/bundling/bundle.js +120 -0
  10. package/src/bundling/discover-layout-runtime-modules.d.ts +32 -0
  11. package/src/bundling/discover-layout-runtime-modules.js +191 -0
  12. package/src/bundling/runtime-alias-map.d.ts +13 -0
  13. package/src/bundling/runtime-alias-map.js +113 -0
  14. package/src/{services/react-runtime-bundle.service.d.ts → bundling/runtime-bundle.d.ts} +30 -5
  15. package/src/bundling/runtime-bundle.js +258 -0
  16. package/src/bundling/runtime-interop-plugin.js +34 -0
  17. package/src/bundling/runtime-mode.d.ts +9 -0
  18. package/src/bundling/runtime-mode.js +11 -0
  19. package/src/bundling/runtime-modules.d.ts +29 -0
  20. package/src/bundling/runtime-modules.js +49 -0
  21. package/src/client-graph/ast-transform.d.ts +18 -0
  22. package/src/client-graph/ast-transform.js +426 -0
  23. package/src/{utils/client-graph-boundary-cache.d.ts → client-graph/boundary-cache.d.ts} +23 -13
  24. package/src/client-graph/boundary-cache.js +182 -0
  25. package/src/{utils/client-graph-boundary-plugin.d.ts → client-graph/boundary-plugin.d.ts} +4 -13
  26. package/src/client-graph/boundary-plugin.js +149 -0
  27. package/src/client-graph/component-config-traversal.js +77 -0
  28. package/src/client-graph/declared-modules.js +69 -0
  29. package/src/client-graph/module-classification.d.ts +3 -0
  30. package/src/client-graph/module-classification.js +43 -0
  31. package/src/{utils → client-graph}/reachability-analyzer.d.ts +4 -12
  32. package/src/client-graph/reachability-analyzer.js +515 -0
  33. package/src/client-graph/specifier-classification.d.ts +75 -0
  34. package/src/client-graph/specifier-classification.js +223 -0
  35. package/src/contracts/router-adapter.js +6 -0
  36. package/src/dev-transform/react-dev-transform-contributor.d.ts +17 -0
  37. package/src/dev-transform/react-dev-transform-contributor.js +22 -0
  38. package/src/hmr/hmr-scripts.js +44 -0
  39. package/src/hmr/hmr-strategy.d.ts +74 -0
  40. package/src/hmr/hmr-strategy.js +351 -0
  41. package/src/{services/react-hmr-page-metadata-cache.d.ts → hmr/page-metadata-cache.d.ts} +5 -1
  42. package/src/hmr/page-metadata-cache.js +44 -0
  43. package/src/hmr/react-hmr-dev-transform-plugins.d.ts +23 -0
  44. package/src/hmr/react-hmr-dev-transform-plugins.js +20 -0
  45. package/src/hydration/assert-no-bare-ecopages-imports.d.ts +4 -0
  46. package/src/hydration/assert-no-bare-ecopages-imports.js +7 -0
  47. package/src/hydration/bootstrap-imports.d.ts +25 -0
  48. package/src/hydration/bootstrap-imports.js +33 -0
  49. package/src/hydration/hydration-asset.d.ts +84 -0
  50. package/src/hydration/hydration-asset.js +227 -0
  51. package/src/hydration/hydration-scripts.d.ts +104 -0
  52. package/src/hydration/hydration-scripts.js +483 -0
  53. package/src/hydration/hydration-scripts.test.browser.js +199 -0
  54. package/src/hydration/page-data-manifest.d.ts +58 -0
  55. package/src/hydration/page-data-manifest.js +97 -0
  56. package/src/hydration/page-data-reader.d.ts +31 -0
  57. package/src/hydration/page-data-reader.js +77 -0
  58. package/src/hydration/page-payload.d.ts +67 -0
  59. package/src/hydration/page-payload.js +106 -0
  60. package/src/hydration/serialize-page-data-script.d.ts +27 -0
  61. package/src/hydration/serialize-page-data-script.js +30 -0
  62. package/src/{services/react-mdx-config-dependency.service.d.ts → mdx/mdx-config-dependency.d.ts} +6 -6
  63. package/src/mdx/mdx-config-dependency.js +110 -0
  64. package/src/mdx/mdx-loader-plugin.d.ts +2 -0
  65. package/src/mdx/mdx-loader-plugin.js +8 -0
  66. package/src/page/page-module.d.ts +46 -0
  67. package/src/page/page-module.js +74 -0
  68. package/src/plugin/react.constants.js +1 -0
  69. package/src/{react.plugin.d.ts → plugin/react.plugin.d.ts} +9 -3
  70. package/src/plugin/react.plugin.js +241 -0
  71. package/src/plugin/react.types.d.ts +152 -0
  72. package/src/plugin/react.types.js +1 -0
  73. package/src/render/component-ownership.d.ts +49 -0
  74. package/src/render/component-ownership.js +46 -0
  75. package/src/render/component-ssr.d.ts +113 -0
  76. package/src/render/component-ssr.js +180 -0
  77. package/src/render/eco-embed.js +9 -0
  78. package/src/render/errors.d.ts +16 -0
  79. package/src/render/errors.js +23 -0
  80. package/src/render/html-boundary.js +59 -0
  81. package/src/render/layout-compose.d.ts +66 -0
  82. package/src/render/layout-compose.js +134 -0
  83. package/src/render/react-renderer.d.ts +138 -0
  84. package/src/render/react-renderer.js +448 -0
  85. package/src/render/react-runtime.d.ts +13 -0
  86. package/src/render/react-runtime.js +26 -0
  87. package/src/render/unified-layout-composition.d.ts +53 -0
  88. package/src/render/unified-layout-composition.js +78 -0
  89. package/src/runtime/use-sync-external-store-with-selector.js +52 -54
  90. package/src/eco-embed.js +0 -11
  91. package/src/react-hmr-strategy.d.ts +0 -230
  92. package/src/react-hmr-strategy.js +0 -657
  93. package/src/react-renderer.d.ts +0 -233
  94. package/src/react-renderer.js +0 -622
  95. package/src/react.constants.js +0 -4
  96. package/src/react.plugin.js +0 -205
  97. package/src/react.types.d.ts +0 -88
  98. package/src/react.types.js +0 -0
  99. package/src/router-adapter.js +0 -0
  100. package/src/services/pages-index.d.ts +0 -64
  101. package/src/services/pages-index.js +0 -73
  102. package/src/services/react-bundle.service.js +0 -86
  103. package/src/services/react-hmr-page-metadata-cache.js +0 -35
  104. package/src/services/react-hydration-asset.service.d.ts +0 -84
  105. package/src/services/react-hydration-asset.service.js +0 -217
  106. package/src/services/react-mdx-config-dependency.service.js +0 -122
  107. package/src/services/react-page-module.service.d.ts +0 -88
  108. package/src/services/react-page-module.service.js +0 -166
  109. package/src/services/react-page-payload.service.d.ts +0 -46
  110. package/src/services/react-page-payload.service.js +0 -67
  111. package/src/services/react-runtime-bundle.service.js +0 -186
  112. package/src/utils/client-graph-boundary-cache.js +0 -116
  113. package/src/utils/client-graph-boundary-plugin.js +0 -552
  114. package/src/utils/client-only.js +0 -19
  115. package/src/utils/component-config-traversal.js +0 -54
  116. package/src/utils/declared-modules.js +0 -47
  117. package/src/utils/dynamic.js +0 -12
  118. package/src/utils/dynamic.test.browser.js +0 -33
  119. package/src/utils/hmr-scripts.js +0 -31
  120. package/src/utils/html-boundary.js +0 -55
  121. package/src/utils/hydration-scripts.d.ts +0 -92
  122. package/src/utils/hydration-scripts.js +0 -358
  123. package/src/utils/hydration-scripts.test.browser.js +0 -198
  124. package/src/utils/reachability-analyzer.js +0 -339
  125. package/src/utils/react-dom-runtime-interop-plugin.js +0 -38
  126. package/src/utils/react-mdx-loader-plugin.d.ts +0 -3
  127. package/src/utils/react-mdx-loader-plugin.js +0 -45
  128. package/src/utils/react-runtime-alias-map.d.ts +0 -8
  129. package/src/utils/react-runtime-alias-map.js +0 -90
  130. /package/src/{utils → app}/client-only.d.ts +0 -0
  131. /package/src/{utils → app}/dynamic.d.ts +0 -0
  132. /package/src/{utils → app}/dynamic.test.browser.d.ts +0 -0
  133. /package/src/{utils/react-dom-runtime-interop-plugin.d.ts → bundling/runtime-interop-plugin.d.ts} +0 -0
  134. /package/src/{utils → client-graph}/component-config-traversal.d.ts +0 -0
  135. /package/src/{utils → client-graph}/declared-modules.d.ts +0 -0
  136. /package/src/{declarations.d.ts → contracts/declarations.d.ts} +0 -0
  137. /package/src/{router-adapter.d.ts → contracts/router-adapter.d.ts} +0 -0
  138. /package/src/{utils → hmr}/hmr-scripts.d.ts +0 -0
  139. /package/src/{utils → hydration}/hydration-scripts.test.browser.d.ts +0 -0
  140. /package/src/{react.constants.d.ts → plugin/react.constants.d.ts} +0 -0
  141. /package/src/{eco-embed.d.ts → render/eco-embed.d.ts} +0 -0
  142. /package/src/{utils → render}/html-boundary.d.ts +0 -0
@@ -1,67 +0,0 @@
1
- import { LocalsAccessError } from "@ecopages/core/errors";
2
- class ReactPagePayloadService {
3
- /**
4
- * Creates the canonical page-props payload used by router hydration.
5
- *
6
- * React pages embedded in a non-React HTML shell still need to expose the same
7
- * page-data contract as fully React-owned documents so navigation and hydration
8
- * can read one shared document payload consistently.
9
- */
10
- buildRouterPageDataScript(pageProps) {
11
- const safeJson = JSON.stringify(pageProps || {}).replace(/</g, "\\u003c");
12
- return `<script id="__ECO_PAGE_DATA__" type="application/json">${safeJson}<\/script>`;
13
- }
14
- /**
15
- * Builds the serialized page-props payload embedded into the final HTML.
16
- *
17
- * The document payload is intentionally narrower than the full server render
18
- * input: only routing data, public page props, and explicitly allowed locals are
19
- * exposed to the browser.
20
- */
21
- buildSerializedPageProps(options) {
22
- return {
23
- ...options.pageProps,
24
- params: options.params,
25
- query: options.query,
26
- ...options.safeLocals && { locals: options.safeLocals }
27
- };
28
- }
29
- /**
30
- * Safely extracts the declared subset of locals for client-side hydration.
31
- *
32
- * On dynamic pages with `cache: 'dynamic'`, middleware populates `locals` with
33
- * request-scoped data (e.g., session). Only keys explicitly declared via
34
- * `Page.requires` are serialized to the client so sensitive request-only data
35
- * is not leaked into hydration payloads by default.
36
- *
37
- * On static pages, `locals` is a Proxy that throws `LocalsAccessError` on access
38
- * to prevent accidental use. This method safely detects that case and returns
39
- * `undefined` instead of throwing.
40
- */
41
- getSerializableLocals(locals, requiredLocals) {
42
- try {
43
- if (!locals) {
44
- return void 0;
45
- }
46
- const requiredKeys = requiredLocals ? Array.isArray(requiredLocals) ? requiredLocals : [requiredLocals] : [];
47
- if (requiredKeys.length === 0) {
48
- return void 0;
49
- }
50
- const serializedLocals = Object.fromEntries(
51
- requiredKeys.filter((key) => Object.prototype.hasOwnProperty.call(locals, key)).map((key) => [key, locals[key]])
52
- );
53
- if (Object.keys(serializedLocals).length > 0) {
54
- return serializedLocals;
55
- }
56
- return void 0;
57
- } catch (error) {
58
- if (error instanceof LocalsAccessError) {
59
- return void 0;
60
- }
61
- throw error;
62
- }
63
- }
64
- }
65
- export {
66
- ReactPagePayloadService
67
- };
@@ -1,186 +0,0 @@
1
- import { createBrowserRuntimePlugin } from "@ecopages/core/build/browser-runtime-plugin";
2
- import { DEFAULT_BROWSER_RUNTIME_PLUGIN_NAME } from "@ecopages/core/build/browser-runtime-plugin";
3
- import {
4
- buildBrowserRuntimeAssetUrl,
5
- createBrowserRuntimeModuleAsset,
6
- createBrowserRuntimeScriptAsset
7
- } from "@ecopages/core/services/asset-processing-service";
8
- import { createReactDomRuntimeInteropPlugin } from "../utils/react-dom-runtime-interop-plugin.js";
9
- import { buildReactRuntimeAliasMap, buildReactRuntimeManifest } from "../utils/react-runtime-alias-map.js";
10
- import {
11
- createBrowserRuntimeManifest
12
- } from "@ecopages/core/build/browser-runtime-manifest";
13
- class ReactRuntimeBundleService {
14
- config;
15
- constructor(config) {
16
- this.config = config;
17
- }
18
- setRootDir(rootDir) {
19
- this.config.rootDir = rootDir;
20
- }
21
- get isDevelopment() {
22
- return process.env.NODE_ENV === "development";
23
- }
24
- getCurrentRuntimeMode() {
25
- return this.isDevelopment ? "development" : "production";
26
- }
27
- createRuntimeDefines(mode) {
28
- const nodeEnv = JSON.stringify(mode);
29
- return {
30
- "process.env.NODE_ENV": nodeEnv,
31
- "import.meta.env.NODE_ENV": nodeEnv
32
- };
33
- }
34
- getReactVendorFileName(mode) {
35
- return mode === "development" ? "react.development.js" : "react.js";
36
- }
37
- getReactDomVendorFileName(mode) {
38
- return mode === "development" ? "react-dom.development.js" : "react-dom.js";
39
- }
40
- getRouterVendorFileName(mode) {
41
- if (!this.config.routerAdapter) {
42
- return "";
43
- }
44
- return mode === "development" ? `${this.config.routerAdapter.bundle.outputName}.development.js` : `${this.config.routerAdapter.bundle.outputName}.js`;
45
- }
46
- getUseSyncExternalStoreWithSelectorVendorFileName(mode) {
47
- return mode === "development" ? "use-sync-external-store-with-selector.development.js" : "use-sync-external-store-with-selector.js";
48
- }
49
- createReactVendorImportRewritePlugin(mode) {
50
- return createBrowserRuntimePlugin({
51
- name: `react-plugin-vendor-runtime-import-rewrite-${mode}`,
52
- manifest: createBrowserRuntimeManifest([
53
- {
54
- specifier: "react",
55
- owner: "@ecopages/react",
56
- importPath: "react",
57
- publicPath: buildBrowserRuntimeAssetUrl(this.getReactVendorFileName(mode))
58
- }
59
- ])
60
- });
61
- }
62
- getRuntimeImports(mode = this.getCurrentRuntimeMode()) {
63
- const reactVendorFileName = this.getReactVendorFileName(mode);
64
- const reactDomVendorFileName = this.getReactDomVendorFileName(mode);
65
- const runtimeImports = {
66
- react: buildBrowserRuntimeAssetUrl(reactVendorFileName),
67
- reactDomClient: buildBrowserRuntimeAssetUrl(reactDomVendorFileName),
68
- reactJsxRuntime: buildBrowserRuntimeAssetUrl(reactVendorFileName),
69
- reactJsxDevRuntime: buildBrowserRuntimeAssetUrl(reactVendorFileName),
70
- reactDom: buildBrowserRuntimeAssetUrl(reactDomVendorFileName),
71
- useSyncExternalStoreWithSelector: buildBrowserRuntimeAssetUrl(
72
- this.getUseSyncExternalStoreWithSelectorVendorFileName(mode)
73
- )
74
- };
75
- if (this.config.routerAdapter) {
76
- runtimeImports.router = buildBrowserRuntimeAssetUrl(this.getRouterVendorFileName(mode));
77
- }
78
- return runtimeImports;
79
- }
80
- getRuntimeAliasMap(mode = this.getCurrentRuntimeMode()) {
81
- return buildReactRuntimeAliasMap(this.getRuntimeImports(mode));
82
- }
83
- getRuntimeManifest(mode = this.getCurrentRuntimeMode()) {
84
- return buildReactRuntimeManifest(this.getRuntimeImports(mode));
85
- }
86
- getDependencies() {
87
- const dependencies = [];
88
- for (const mode of ["production", "development"]) {
89
- const reactVendorImportRewritePlugin = this.createReactVendorImportRewritePlugin(mode);
90
- const reactDomRuntimeInteropPlugin = createReactDomRuntimeInteropPlugin({
91
- reactSpecifier: buildBrowserRuntimeAssetUrl(this.getReactVendorFileName(mode))
92
- });
93
- const reactRuntimeAliasPlugin = createBrowserRuntimePlugin({
94
- name: `react-plugin-runtime-specifier-alias-${mode}`,
95
- manifest: createBrowserRuntimeManifest([
96
- {
97
- specifier: "react",
98
- owner: "",
99
- importPath: "react",
100
- publicPath: buildBrowserRuntimeAssetUrl(this.getReactVendorFileName(mode))
101
- }
102
- ])
103
- });
104
- const reactDomBundlePlugins = [reactRuntimeAliasPlugin, reactDomRuntimeInteropPlugin].filter(
105
- (plugin) => plugin !== null
106
- );
107
- const runtimeAliasPlugin = this.createRuntimeAliasPlugin(mode);
108
- const mappedSpecifiers = new Set(Object.keys(this.getRuntimeAliasMap(mode)));
109
- dependencies.push(
110
- createBrowserRuntimeModuleAsset({
111
- modules: [
112
- { specifier: "react", defaultExport: true },
113
- { specifier: "react/jsx-runtime" },
114
- { specifier: "react/jsx-dev-runtime" }
115
- ],
116
- name: "react",
117
- fileName: this.getReactVendorFileName(mode),
118
- cacheDirName: `ecopages-react-runtime-${mode}`,
119
- rootDir: this.config.rootDir,
120
- bundleOptions: {
121
- define: this.createRuntimeDefines(mode),
122
- excludeAppBuildPlugins: [DEFAULT_BROWSER_RUNTIME_PLUGIN_NAME]
123
- }
124
- }),
125
- createBrowserRuntimeModuleAsset({
126
- modules: [{ specifier: "react-dom", defaultExport: true }, { specifier: "react-dom/client" }],
127
- name: "react-dom",
128
- fileName: this.getReactDomVendorFileName(mode),
129
- cacheDirName: `ecopages-react-runtime-${mode}`,
130
- rootDir: this.config.rootDir,
131
- bundleOptions: {
132
- define: this.createRuntimeDefines(mode),
133
- excludeAppBuildPlugins: [DEFAULT_BROWSER_RUNTIME_PLUGIN_NAME],
134
- plugins: reactDomBundlePlugins
135
- }
136
- }),
137
- createBrowserRuntimeScriptAsset({
138
- importPath: "@ecopages/react/runtime/use-sync-external-store-with-selector",
139
- name: "use-sync-external-store-with-selector",
140
- fileName: this.getUseSyncExternalStoreWithSelectorVendorFileName(mode),
141
- bundleOptions: {
142
- define: this.createRuntimeDefines(mode),
143
- excludeAppBuildPlugins: [DEFAULT_BROWSER_RUNTIME_PLUGIN_NAME],
144
- plugins: [reactVendorImportRewritePlugin]
145
- }
146
- })
147
- );
148
- if (this.config.routerAdapter) {
149
- const unresolvedExternals = this.config.routerAdapter.bundle.externals.filter(
150
- (external) => !mappedSpecifiers.has(external)
151
- );
152
- dependencies.push(
153
- createBrowserRuntimeScriptAsset({
154
- importPath: this.config.routerAdapter.bundle.importPath,
155
- name: this.config.routerAdapter.bundle.outputName,
156
- fileName: this.getRouterVendorFileName(mode),
157
- bundleOptions: {
158
- define: this.createRuntimeDefines(mode),
159
- external: unresolvedExternals,
160
- plugins: [runtimeAliasPlugin]
161
- }
162
- })
163
- );
164
- }
165
- }
166
- return dependencies;
167
- }
168
- createRuntimeAliasPlugin(mode = this.getCurrentRuntimeMode()) {
169
- const aliasMap = this.getRuntimeAliasMap(mode);
170
- const manifest = createBrowserRuntimeManifest(
171
- Object.entries(aliasMap).map(([specifier, publicPath]) => ({
172
- specifier,
173
- owner: "",
174
- importPath: specifier,
175
- publicPath
176
- }))
177
- );
178
- return createBrowserRuntimePlugin({
179
- name: `react-plugin-runtime-alias-${mode}`,
180
- manifest
181
- });
182
- }
183
- }
184
- export {
185
- ReactRuntimeBundleService
186
- };
@@ -1,116 +0,0 @@
1
- import { rapidhash } from "@ecopages/core/utils/hash";
2
- const DEFAULT_MAX_ENTRIES = 5e3;
3
- function cloneRules(rules) {
4
- return rules instanceof Set ? new Set(rules) : rules;
5
- }
6
- class ClientGraphBoundaryCache {
7
- entries = /* @__PURE__ */ new Map();
8
- maxEntries;
9
- hits = 0;
10
- misses = 0;
11
- constructor(maxEntries = DEFAULT_MAX_ENTRIES) {
12
- if (maxEntries <= 0) {
13
- throw new Error(`ClientGraphBoundaryCache: maxEntries must be > 0, got ${maxEntries}`);
14
- }
15
- this.maxEntries = maxEntries;
16
- }
17
- /**
18
- * Look up a cached transform for `filePath`.
19
- *
20
- * Returns `undefined` if the source or allow list has changed since
21
- * the entry was stored. The caller is responsible for re-running the
22
- * transform in that case and calling `set` to update the entry.
23
- */
24
- get(filePath, source, globallyAllowedSpecifiers) {
25
- const sourceHash = rapidhash(source);
26
- const allowListHash = hashAllowList(globallyAllowedSpecifiers);
27
- const existing = this.entries.get(filePath);
28
- if (existing && existing.sourceHash === sourceHash && existing.allowListHash === allowListHash) {
29
- this.hits += 1;
30
- this.entries.delete(filePath);
31
- this.entries.set(filePath, existing);
32
- return existing;
33
- }
34
- this.misses += 1;
35
- return void 0;
36
- }
37
- /**
38
- * Store a transform result.
39
- *
40
- * Evicts the least recently used entry if the cache exceeds its
41
- * capacity. Defensively copies any `Set`-typed rules in `rulesAdded`
42
- * so later mutations to the caller's sets cannot corrupt the cache.
43
- */
44
- set(filePath, source, globallyAllowedSpecifiers, entry) {
45
- const sourceHash = rapidhash(source);
46
- const allowListHash = hashAllowList(globallyAllowedSpecifiers);
47
- const rulesAddedCopy = /* @__PURE__ */ new Map();
48
- for (const [key, rules] of entry.rulesAdded) {
49
- rulesAddedCopy.set(key, cloneRules(rules));
50
- }
51
- const full = {
52
- sourceHash,
53
- allowListHash,
54
- transformed: entry.transformed,
55
- modified: entry.modified,
56
- rulesAdded: rulesAddedCopy
57
- };
58
- this.entries.set(filePath, full);
59
- if (this.entries.size > this.maxEntries) {
60
- const oldestKey = this.entries.keys().next().value;
61
- if (oldestKey !== void 0) {
62
- this.entries.delete(oldestKey);
63
- }
64
- }
65
- }
66
- /**
67
- * Invalidate a single file's entry. Call this from the file watcher
68
- * when `filePath`'s content has changed.
69
- */
70
- invalidate(filePath) {
71
- this.entries.delete(filePath);
72
- }
73
- /**
74
- * Invalidate every file whose key matches a prefix. Useful for
75
- * "anything under `src/pages/` changed" signals.
76
- */
77
- invalidateMatching(predicate) {
78
- let removed = 0;
79
- for (const key of this.entries.keys()) {
80
- if (predicate(key)) {
81
- this.entries.delete(key);
82
- removed += 1;
83
- }
84
- }
85
- return removed;
86
- }
87
- /** Clear all entries. */
88
- clear() {
89
- this.entries.clear();
90
- this.hits = 0;
91
- this.misses = 0;
92
- }
93
- /** Current cache size. */
94
- get size() {
95
- return this.entries.size;
96
- }
97
- /** Hit/miss counters for observability. */
98
- stats() {
99
- const total = this.hits + this.misses;
100
- return {
101
- hits: this.hits,
102
- misses: this.misses,
103
- size: this.entries.size,
104
- hitRate: total === 0 ? 0 : this.hits / total
105
- };
106
- }
107
- }
108
- const clientGraphBoundaryCache = new ClientGraphBoundaryCache();
109
- function hashAllowList(specifiers) {
110
- const sorted = Array.from(specifiers).sort();
111
- return rapidhash(sorted.join("\n"));
112
- }
113
- export {
114
- ClientGraphBoundaryCache,
115
- clientGraphBoundaryCache
116
- };