dinou 9.0.3 → 9.2.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.
@@ -1,256 +1,500 @@
1
- // dinou/core/ppr-context.js
2
- // PPR Pre-rendering Context and Suspense Hole Tracker for Dinou.
3
-
4
- import { AsyncLocalStorage } from "node:async_hooks";
5
-
6
- const pprStorage = new AsyncLocalStorage();
7
- const pageSegmentStorage = new AsyncLocalStorage();
8
- const layoutSegmentStorage = new AsyncLocalStorage();
9
- const pageRootElements = new WeakSet();
10
-
11
- export function markPageRootElement(el) {
12
- if (el && typeof el === "object") {
13
- pageRootElements.add(el);
14
- }
15
- return el;
16
- }
17
-
18
- export function isPageRootElement(el) {
19
- return Boolean(el && typeof el === "object" && pageRootElements.has(el));
20
- }
21
-
22
- export function runInPageSegment(callback) {
23
- return pageSegmentStorage.run({ active: true }, callback);
24
- }
25
-
26
- export function isInsidePageSegment() {
27
- return Boolean(pageSegmentStorage.getStore()?.active);
28
- }
29
-
30
- export function runInLayoutSegment(callback) {
31
- return layoutSegmentStorage.run({ active: true }, callback);
32
- }
33
-
34
- export function isInsideLayoutSegment() {
35
- return Boolean(layoutSegmentStorage.getStore()?.active);
36
- }
37
-
38
- /**
39
- * Executes a function within a PPR pre-render context.
40
- * @param {object} options
41
- * @param {Function} callback
42
- * @returns {Promise<any>}
43
- */
44
- export function runWithPprContext(options, callback) {
45
- const sharedCounter = { nextHoleIndex: 0 };
46
- const sharedHoles = new Map();
47
- const store = {
48
- isPpr: Boolean(options?.isPpr),
49
- suspenseDepth: 0,
50
- currentHoleId: null,
51
- holeStack: [],
52
- holes: sharedHoles,
53
- counter: sharedCounter,
54
- get nextHoleIndex() {
55
- return sharedCounter.nextHoleIndex;
56
- },
57
- set nextHoleIndex(val) {
58
- sharedCounter.nextHoleIndex = val;
59
- },
60
- ...options,
61
- };
62
- return pprStorage.run(store, callback);
63
- }
64
-
65
- export function getPprStore() {
66
- return pprStorage.getStore() || null;
67
- }
68
-
69
- export function isPprBuildActive() {
70
- const store = getPprStore();
71
- return Boolean(store && store.isPpr);
72
- }
73
-
74
- export function isInsideSuspense() {
75
- const store = getPprStore();
76
- return Boolean(store && store.suspenseDepth > 0);
77
- }
78
-
79
- export function resetPprHoles(startIndex = 0) {
80
- const store = getPprStore();
81
- if (store) {
82
- const startVal = Number(startIndex) || 0;
83
- if (store.counter) {
84
- store.counter.nextHoleIndex = startVal;
85
- } else {
86
- store.nextHoleIndex = startVal;
87
- }
88
- if (store.holes && typeof store.holes.clear === "function") {
89
- store.holes.clear();
90
- }
91
- store.suspenseDepth = 0;
92
- store.currentHoleId = null;
93
- if (Array.isArray(store.holeStack)) {
94
- store.holeStack.length = 0;
95
- }
96
- }
97
- }
98
-
99
- export function getPprHoleCounter() {
100
- const store = getPprStore();
101
- if (store) {
102
- return store.counter ? store.counter.nextHoleIndex : store.nextHoleIndex || 0;
103
- }
104
- return 0;
105
- }
106
-
107
- export function runInSuspense(callback, explicitHoleId = null) {
108
- const store = getPprStore();
109
- if (!store) {
110
- return callback(null, null);
111
- }
112
- let holeId = explicitHoleId;
113
- if (!holeId) {
114
- if (store.counter) {
115
- store.counter.nextHoleIndex++;
116
- holeId = `ppr-hole-${store.counter.nextHoleIndex}`;
117
- } else {
118
- store.nextHoleIndex++;
119
- holeId = `ppr-hole-${store.nextHoleIndex}`;
120
- }
121
- }
122
- const nextStack = Array.isArray(store.holeStack)
123
- ? [...store.holeStack, holeId]
124
- : [holeId];
125
- const pendingEffects = [];
126
- const childStore = {
127
- ...store,
128
- suspenseDepth: store.suspenseDepth + 1,
129
- currentHoleId: holeId,
130
- holeStack: nextStack,
131
- pendingEffects,
132
- parentPendingEffects: Array.isArray(store.pendingEffects)
133
- ? store.pendingEffects
134
- : null,
135
- };
136
- return pprStorage.run(childStore, () => callback(holeId, childStore));
137
- }
138
-
139
- export function deferPprSuspenseEffect(effectFn) {
140
- const store = getPprStore();
141
- if (
142
- store &&
143
- store.isPpr &&
144
- store.suspenseDepth > 0 &&
145
- Array.isArray(store.pendingEffects) &&
146
- typeof effectFn === "function"
147
- ) {
148
- store.pendingEffects.push(effectFn);
149
- return true;
150
- }
151
- return false;
152
- }
153
-
154
- export async function commitPprSuspenseEffects(childStore) {
155
- if (!childStore || !Array.isArray(childStore.pendingEffects)) return;
156
- const effects = childStore.pendingEffects.splice(0);
157
- if (effects.length === 0) return;
158
- if (Array.isArray(childStore.parentPendingEffects)) {
159
- childStore.parentPendingEffects.push(...effects);
160
- return;
161
- }
162
- for (const fn of effects) {
163
- await fn();
164
- }
165
- }
166
-
167
- export function enterSuspense(holeId = null) {
168
- const store = getPprStore();
169
- if (store) {
170
- store.suspenseDepth++;
171
- if (!holeId) {
172
- if (store.counter) {
173
- store.counter.nextHoleIndex++;
174
- holeId = `ppr-hole-${store.counter.nextHoleIndex}`;
175
- } else {
176
- store.nextHoleIndex++;
177
- holeId = `ppr-hole-${store.nextHoleIndex}`;
178
- }
179
- }
180
- if (Array.isArray(store.holeStack)) {
181
- store.holeStack.push(holeId);
182
- }
183
- store.currentHoleId = holeId;
184
- return holeId;
185
- }
186
- return null;
187
- }
188
-
189
- export function exitSuspense() {
190
- const store = getPprStore();
191
- if (store) {
192
- store.suspenseDepth = Math.max(0, store.suspenseDepth - 1);
193
- if (Array.isArray(store.holeStack) && store.holeStack.length > 0) {
194
- store.holeStack.pop();
195
- store.currentHoleId =
196
- store.holeStack.length > 0
197
- ? store.holeStack[store.holeStack.length - 1]
198
- : null;
199
- } else if (store.suspenseDepth === 0) {
200
- store.currentHoleId = null;
201
- }
202
- }
203
- }
204
-
205
- export function markDynamicAccess(type = "dynamic") {
206
- const store = getPprStore();
207
- if (store && store.isPpr && store.suspenseDepth > 0) {
208
- const idx = store.counter ? store.counter.nextHoleIndex : store.nextHoleIndex;
209
- const holeId = store.currentHoleId || `ppr-hole-${idx}`;
210
- const error = new Error(
211
- `[Dinou PPR] Dynamic access to '${type}' postponed inside Suspense`
212
- );
213
- error.$$typeof = Symbol.for("dinou.ppr.postpone");
214
- error.pprType = type;
215
- error.holeId = holeId;
216
- throw error;
217
- }
218
- }
219
-
220
- export function registerHole(holeId, meta = {}) {
221
- const store = getPprStore();
222
- if (store && holeId) {
223
- store.holes.set(holeId, {
224
- id: holeId,
225
- registeredAt: Date.now(),
226
- ...meta,
227
- });
228
- }
229
- }
230
-
231
- export function getRegisteredHoles() {
232
- const store = getPprStore();
233
- if (store) {
234
- return Array.from(store.holes.keys());
235
- }
236
- return [];
237
- }
238
-
239
- export default {
240
- runInPageSegment,
241
- isInsidePageSegment,
242
- runWithPprContext,
243
- getPprStore,
244
- isPprBuildActive,
245
- isInsideSuspense,
246
- resetPprHoles,
247
- getPprHoleCounter,
248
- runInSuspense,
249
- deferPprSuspenseEffect,
250
- commitPprSuspenseEffects,
251
- enterSuspense,
252
- exitSuspense,
253
- markDynamicAccess,
254
- registerHole,
255
- getRegisteredHoles,
256
- };
1
+ // dinou/core/ppr-context.js
2
+ // PPR Pre-rendering Context and Suspense Hole Tracker for Dinou.
3
+
4
+ import { AsyncLocalStorage } from "node:async_hooks";
5
+
6
+ const pprStorage = new AsyncLocalStorage();
7
+ const pageSegmentStorage = new AsyncLocalStorage();
8
+ const layoutSegmentStorage = new AsyncLocalStorage();
9
+ const cachedSlotStorage = new AsyncLocalStorage();
10
+ const slotDiscoveryStorage = new AsyncLocalStorage();
11
+ const runtimeStaticSuspenseStorage = new AsyncLocalStorage();
12
+ const pageRootElements = new WeakSet();
13
+ const layoutRootElements = new WeakSet();
14
+ const layoutChildrenPlaceholders = new WeakSet();
15
+
16
+ const NO_DYNAMIC_HOOK_KEY = Symbol.for("dinou.ppr.noDynamic.hook");
17
+ export const SKIP_STATIC_SUSPENSE_SYMBOL = Symbol.for("dinou.ppr.skipStatic");
18
+ let currentComponentNoDynamic = false;
19
+
20
+ export function runInRuntimeStaticSuspense(callback) {
21
+ const prev = runtimeStaticSuspenseStorage.getStore();
22
+ return runtimeStaticSuspenseStorage.run(
23
+ { active: true, depth: (prev?.depth || 0) + 1 },
24
+ callback
25
+ );
26
+ }
27
+
28
+ export function runInRuntimeDynamicHole(callback, holeId = null) {
29
+ const prev = runtimeStaticSuspenseStorage.getStore();
30
+ return runtimeStaticSuspenseStorage.run(
31
+ {
32
+ active: false,
33
+ depth: 0,
34
+ holeId: holeId || prev?.holeId || null,
35
+ idCount: 0,
36
+ childHoleCount: 0,
37
+ },
38
+ callback
39
+ );
40
+ }
41
+
42
+ export function getActiveRuntimeDynamicHoleStore() {
43
+ const store = runtimeStaticSuspenseStorage.getStore();
44
+ return store && store.holeId ? store : null;
45
+ }
46
+
47
+ export function isRuntimeStaticSuspenseActive() {
48
+ const store = runtimeStaticSuspenseStorage.getStore();
49
+ return Boolean(store && store.active && store.depth > 0);
50
+ }
51
+
52
+ export function noDynamic() {
53
+ if (isRuntimeStaticSuspenseActive() && !isPprBuildActive()) {
54
+ const err = new Error(
55
+ "[Dinou PPR] Skipping static noDynamic() subtree during runtime hole traversal"
56
+ );
57
+ err.$$typeof = SKIP_STATIC_SUSPENSE_SYMBOL;
58
+ throw err;
59
+ }
60
+ currentComponentNoDynamic = true;
61
+ const store = pprStorage.getStore();
62
+ if (store && store.suspenseDepth > 0) {
63
+ store.noDynamic = true;
64
+ }
65
+ }
66
+
67
+ if (typeof globalThis !== "undefined") {
68
+ globalThis[NO_DYNAMIC_HOOK_KEY] = noDynamic;
69
+ }
70
+
71
+ export function resetComponentNoDynamicFlag() {
72
+ currentComponentNoDynamic = false;
73
+ }
74
+
75
+ export function consumeComponentNoDynamicFlag() {
76
+ const val = currentComponentNoDynamic;
77
+ currentComponentNoDynamic = false;
78
+ return val;
79
+ }
80
+
81
+ export function isNoDynamicActive() {
82
+ if (currentComponentNoDynamic) return true;
83
+ const store = pprStorage.getStore();
84
+ return Boolean(store && store.noDynamic);
85
+ }
86
+
87
+ export function runInCachedSlot(callback, options = {}) {
88
+ const prev = cachedSlotStorage.getStore();
89
+ const isCached = options?.cached !== false;
90
+ const slotId =
91
+ typeof options === "string"
92
+ ? options
93
+ : options?.slotId || prev?.slotId || null;
94
+ return cachedSlotStorage.run(
95
+ {
96
+ depth: (prev?.depth || 0) + (isCached ? 1 : 0),
97
+ slotId,
98
+ idCount: 0,
99
+ },
100
+ callback
101
+ );
102
+ }
103
+
104
+ export function getActiveCachedSlotStore() {
105
+ return cachedSlotStorage.getStore() || null;
106
+ }
107
+
108
+ export function isInsideCachedSlot() {
109
+ return Boolean((cachedSlotStorage.getStore()?.depth || 0) > 0);
110
+ }
111
+
112
+ export function runInSlotDiscovery(callback) {
113
+ return slotDiscoveryStorage.run({ active: true }, callback);
114
+ }
115
+
116
+ export function isSlotDiscoveryActive() {
117
+ return Boolean(slotDiscoveryStorage.getStore()?.active);
118
+ }
119
+
120
+ export function markPageRootElement(el) {
121
+ if (el && typeof el === "object") {
122
+ pageRootElements.add(el);
123
+ }
124
+ return el;
125
+ }
126
+
127
+ export function isPageRootElement(el) {
128
+ return Boolean(el && typeof el === "object" && pageRootElements.has(el));
129
+ }
130
+
131
+ export function markLayoutRootElement(el) {
132
+ if (el && typeof el === "object") {
133
+ layoutRootElements.add(el);
134
+ }
135
+ return el;
136
+ }
137
+
138
+ export function isLayoutRootElement(el) {
139
+ return Boolean(el && typeof el === "object" && layoutRootElements.has(el));
140
+ }
141
+
142
+ export function createLayoutChildrenPlaceholder() {
143
+ const placeholder = {
144
+ $$typeof: Symbol.for("react.transitional.element"),
145
+ type: Symbol.for("dinou.layout.children.placeholder"),
146
+ key: null,
147
+ ref: null,
148
+ props: {},
149
+ };
150
+ layoutChildrenPlaceholders.add(placeholder);
151
+ return placeholder;
152
+ }
153
+
154
+ export function isLayoutChildrenPlaceholder(el) {
155
+ return Boolean(
156
+ el &&
157
+ typeof el === "object" &&
158
+ (layoutChildrenPlaceholders.has(el) ||
159
+ el.type === Symbol.for("dinou.layout.children.placeholder"))
160
+ );
161
+ }
162
+
163
+ export function runInPageSegment(callback, storeOverride = null) {
164
+ const prev = pageSegmentStorage.getStore();
165
+ const store =
166
+ storeOverride || prev || { active: true, idCount: 0, holeCount: 0 };
167
+ return pageSegmentStorage.run(store, callback);
168
+ }
169
+
170
+ export function getActivePageSegmentStore() {
171
+ return pageSegmentStorage.getStore() || null;
172
+ }
173
+
174
+ export function isInsidePageSegment() {
175
+ return Boolean(pageSegmentStorage.getStore()?.active);
176
+ }
177
+
178
+ export function runInLayoutSegment(callback, storeOverride = null) {
179
+ const prev = layoutSegmentStorage.getStore();
180
+ const store =
181
+ storeOverride || prev || { active: true, idCount: 0, holeCount: 0 };
182
+ return layoutSegmentStorage.run(store, callback);
183
+ }
184
+
185
+ export function getActiveLayoutSegmentStore() {
186
+ return layoutSegmentStorage.getStore() || null;
187
+ }
188
+
189
+ export function isInsideLayoutSegment() {
190
+ return Boolean(
191
+ layoutSegmentStorage.getStore()?.active && !isInsidePageSegment()
192
+ );
193
+ }
194
+
195
+ /**
196
+ * Executes a function within a PPR pre-render context.
197
+ * @param {object} options
198
+ * @param {Function} callback
199
+ * @returns {Promise<any>}
200
+ */
201
+ export function runWithPprContext(options, callback) {
202
+ const sharedCounter = { nextHoleIndex: 0 };
203
+ const sharedHoles = new Map();
204
+ const store = {
205
+ isPpr: Boolean(options?.isPpr),
206
+ suspenseDepth: 0,
207
+ currentHoleId: null,
208
+ holeStack: [],
209
+ holes: sharedHoles,
210
+ counter: sharedCounter,
211
+ get nextHoleIndex() {
212
+ return sharedCounter.nextHoleIndex;
213
+ },
214
+ set nextHoleIndex(val) {
215
+ sharedCounter.nextHoleIndex = val;
216
+ },
217
+ ...options,
218
+ };
219
+ return pprStorage.run(store, callback);
220
+ }
221
+
222
+ export function getPprStore() {
223
+ return pprStorage.getStore() || null;
224
+ }
225
+
226
+ export function isPprBuildActive() {
227
+ const store = getPprStore();
228
+ return Boolean(store && store.isPpr);
229
+ }
230
+
231
+ export function isInsideSuspense() {
232
+ const store = getPprStore();
233
+ return Boolean(store && store.suspenseDepth > 0);
234
+ }
235
+
236
+ export function isInsideOuterSuspenseOutsideSlot() {
237
+ const store = getPprStore();
238
+ return Boolean(
239
+ store && store.suspenseDepth > 0 && store.hasOuterSuspenseOutsideSlot
240
+ );
241
+ }
242
+
243
+ export function rollbackPprHolesAfter(countBefore) {
244
+ const store = getPprStore();
245
+ if (!store) return;
246
+ const target = Number(countBefore) || 0;
247
+ const current = store.counter
248
+ ? store.counter.nextHoleIndex
249
+ : store.nextHoleIndex || 0;
250
+ if (current > target) {
251
+ for (let i = target + 1; i <= current; i++) {
252
+ store.holes.delete(`ppr-hole-${i}`);
253
+ }
254
+ if (store.counter) {
255
+ store.counter.nextHoleIndex = target;
256
+ } else {
257
+ store.nextHoleIndex = target;
258
+ }
259
+ }
260
+ }
261
+
262
+ export function resetPprHoles(startIndex = 0) {
263
+ const store = getPprStore();
264
+ if (store) {
265
+ const startVal = Number(startIndex) || 0;
266
+ if (store.counter) {
267
+ store.counter.nextHoleIndex = startVal;
268
+ } else {
269
+ store.nextHoleIndex = startVal;
270
+ }
271
+ if (store.holes && typeof store.holes.clear === "function") {
272
+ store.holes.clear();
273
+ }
274
+ store.suspenseDepth = 0;
275
+ store.currentHoleId = null;
276
+ if (Array.isArray(store.holeStack)) {
277
+ store.holeStack.length = 0;
278
+ }
279
+ }
280
+ }
281
+
282
+ export function getPprHoleCounter() {
283
+ const store = getPprStore();
284
+ if (store) {
285
+ return store.counter ? store.counter.nextHoleIndex : store.nextHoleIndex || 0;
286
+ }
287
+ return 0;
288
+ }
289
+
290
+ export function runInSuspense(callback, explicitHoleId = null) {
291
+ const store = getPprStore();
292
+ if (!store) {
293
+ let holeId = explicitHoleId;
294
+ if (!holeId) {
295
+ const holeStore = getActiveRuntimeDynamicHoleStore();
296
+ const layoutStore = getActiveLayoutSegmentStore();
297
+ const pageStore = getActivePageSegmentStore();
298
+ if (holeStore && holeStore.holeId) {
299
+ holeStore.childHoleCount = (holeStore.childHoleCount || 0) + 1;
300
+ holeId = `${holeStore.holeId}-${holeStore.childHoleCount}`;
301
+ } else if (
302
+ layoutStore &&
303
+ layoutStore.active &&
304
+ !isInsidePageSegment()
305
+ ) {
306
+ layoutStore.holeCount = (layoutStore.holeCount || 0) + 1;
307
+ holeId = `layout-hole-${layoutStore.holeCount}`;
308
+ } else if (pageStore && pageStore.active) {
309
+ pageStore.holeCount = (pageStore.holeCount || 0) + 1;
310
+ holeId = `ppr-hole-${pageStore.holeCount}`;
311
+ } else {
312
+ holeId = "ppr-hole-1";
313
+ }
314
+ }
315
+ return callback(holeId, null);
316
+ }
317
+ let holeId = explicitHoleId;
318
+ if (!holeId) {
319
+ if (store.counter) {
320
+ store.counter.nextHoleIndex++;
321
+ holeId = `ppr-hole-${store.counter.nextHoleIndex}`;
322
+ } else {
323
+ store.nextHoleIndex++;
324
+ holeId = `ppr-hole-${store.nextHoleIndex}`;
325
+ }
326
+ }
327
+ const nextStack = Array.isArray(store.holeStack)
328
+ ? [...store.holeStack, holeId]
329
+ : [holeId];
330
+ const pendingEffects = [];
331
+ const slotDepthAtSuspense = cachedSlotStorage.getStore()?.depth || 0;
332
+ const hasOuterSuspenseOutsideSlot = Boolean(
333
+ store.hasOuterSuspenseOutsideSlot || slotDepthAtSuspense === 0
334
+ );
335
+ const childStore = {
336
+ ...store,
337
+ suspenseDepth: store.suspenseDepth + 1,
338
+ currentHoleId: holeId,
339
+ holeStack: nextStack,
340
+ noDynamic: false,
341
+ settled: false,
342
+ slotDepthAtSuspense,
343
+ hasOuterSuspenseOutsideSlot,
344
+ pendingEffects,
345
+ parentPendingEffects: Array.isArray(store.pendingEffects)
346
+ ? store.pendingEffects
347
+ : null,
348
+ };
349
+ return pprStorage.run(childStore, () => callback(holeId, childStore));
350
+ }
351
+
352
+ export function deferPprSuspenseEffect(effectFn) {
353
+ const store = getPprStore();
354
+ if (
355
+ store &&
356
+ store.isPpr &&
357
+ store.suspenseDepth > 0 &&
358
+ Array.isArray(store.pendingEffects) &&
359
+ typeof effectFn === "function"
360
+ ) {
361
+ if (store.settled) {
362
+ return true;
363
+ }
364
+ store.pendingEffects.push(effectFn);
365
+ return true;
366
+ }
367
+ return false;
368
+ }
369
+
370
+ export async function commitPprSuspenseEffects(childStore) {
371
+ if (!childStore || !Array.isArray(childStore.pendingEffects)) return;
372
+ const effects = childStore.pendingEffects.splice(0);
373
+ if (effects.length === 0) return;
374
+ if (Array.isArray(childStore.parentPendingEffects)) {
375
+ childStore.parentPendingEffects.push(...effects);
376
+ return;
377
+ }
378
+ for (const fn of effects) {
379
+ await fn();
380
+ }
381
+ }
382
+
383
+ export function enterSuspense(holeId = null) {
384
+ const store = getPprStore();
385
+ if (store) {
386
+ store.suspenseDepth++;
387
+ if (!holeId) {
388
+ if (store.counter) {
389
+ store.counter.nextHoleIndex++;
390
+ holeId = `ppr-hole-${store.counter.nextHoleIndex}`;
391
+ } else {
392
+ store.nextHoleIndex++;
393
+ holeId = `ppr-hole-${store.nextHoleIndex}`;
394
+ }
395
+ }
396
+ if (Array.isArray(store.holeStack)) {
397
+ store.holeStack.push(holeId);
398
+ }
399
+ store.currentHoleId = holeId;
400
+ return holeId;
401
+ }
402
+ return null;
403
+ }
404
+
405
+ export function exitSuspense() {
406
+ const store = getPprStore();
407
+ if (store) {
408
+ store.suspenseDepth = Math.max(0, store.suspenseDepth - 1);
409
+ if (Array.isArray(store.holeStack) && store.holeStack.length > 0) {
410
+ store.holeStack.pop();
411
+ store.currentHoleId =
412
+ store.holeStack.length > 0
413
+ ? store.holeStack[store.holeStack.length - 1]
414
+ : null;
415
+ } else if (store.suspenseDepth === 0) {
416
+ store.currentHoleId = null;
417
+ }
418
+ }
419
+ }
420
+
421
+ export function markDynamicAccess(type = "dynamic") {
422
+ const store = getPprStore();
423
+ if (
424
+ store &&
425
+ store.isPpr &&
426
+ store.suspenseDepth > 0 &&
427
+ store.hasOuterSuspenseOutsideSlot
428
+ ) {
429
+ const idx = store.counter ? store.counter.nextHoleIndex : store.nextHoleIndex;
430
+ const holeId = store.currentHoleId || `ppr-hole-${idx}`;
431
+ const error = new Error(
432
+ `[Dinou PPR] Dynamic access to '${type}' postponed inside Suspense`
433
+ );
434
+ error.$$typeof = Symbol.for("dinou.ppr.postpone");
435
+ error.pprType = type;
436
+ error.holeId = holeId;
437
+ throw error;
438
+ }
439
+ }
440
+
441
+ export function registerHole(holeId, meta = {}) {
442
+ const store = getPprStore();
443
+ if (store && holeId) {
444
+ store.holes.set(holeId, {
445
+ id: holeId,
446
+ registeredAt: Date.now(),
447
+ ...meta,
448
+ });
449
+ }
450
+ }
451
+
452
+ export function getRegisteredHoles() {
453
+ const store = getPprStore();
454
+ if (store) {
455
+ return Array.from(store.holes.keys());
456
+ }
457
+ return [];
458
+ }
459
+
460
+ export default {
461
+ noDynamic,
462
+ SKIP_STATIC_SUSPENSE_SYMBOL,
463
+ runInRuntimeStaticSuspense,
464
+ runInRuntimeDynamicHole,
465
+ getActiveRuntimeDynamicHoleStore,
466
+ isRuntimeStaticSuspenseActive,
467
+ resetComponentNoDynamicFlag,
468
+ consumeComponentNoDynamicFlag,
469
+ isNoDynamicActive,
470
+ runInCachedSlot,
471
+ isInsideCachedSlot,
472
+ runInSlotDiscovery,
473
+ isSlotDiscoveryActive,
474
+ markPageRootElement,
475
+ isPageRootElement,
476
+ markLayoutRootElement,
477
+ isLayoutRootElement,
478
+ createLayoutChildrenPlaceholder,
479
+ isLayoutChildrenPlaceholder,
480
+ runInPageSegment,
481
+ isInsidePageSegment,
482
+ runInLayoutSegment,
483
+ isInsideLayoutSegment,
484
+ runWithPprContext,
485
+ getPprStore,
486
+ isPprBuildActive,
487
+ isInsideSuspense,
488
+ isInsideOuterSuspenseOutsideSlot,
489
+ rollbackPprHolesAfter,
490
+ resetPprHoles,
491
+ getPprHoleCounter,
492
+ runInSuspense,
493
+ deferPprSuspenseEffect,
494
+ commitPprSuspenseEffects,
495
+ enterSuspense,
496
+ exitSuspense,
497
+ markDynamicAccess,
498
+ registerHole,
499
+ getRegisteredHoles,
500
+ };