@@ -27,10 +27,10 @@ import {
27
27
set_hydrate_node
28
28
} from '../hydration.js' ;
29
29
import { get_next_sibling } from '../operations.js' ;
30
- import { queue_micro_task } from '../task.js' ;
30
+ import { queue_boundary_micro_task } from '../task.js' ;
31
31
32
- const SUSPEND_INCREMENT = Symbol ( ) ;
33
- const SUSPEND_DECREMENT = Symbol ( ) ;
32
+ const ASYNC_INCREMENT = Symbol ( ) ;
33
+ const ASYNC_DECREMENT = Symbol ( ) ;
34
34
35
35
/**
36
36
* @param {Effect } boundary
@@ -70,10 +70,10 @@ export function boundary(node, props, boundary_fn) {
70
70
/** @type {Effect } */
71
71
var boundary_effect ;
72
72
/** @type {Effect | null } */
73
- var suspended_effect = null ;
73
+ var async_effect = null ;
74
74
/** @type {DocumentFragment | null } */
75
- var suspended_fragment = null ;
76
- var suspend_count = 0 ;
75
+ var async_fragment = null ;
76
+ var async_count = 0 ;
77
77
78
78
block ( ( ) => {
79
79
var boundary = /** @type {Effect } */ ( active_effect ) ;
@@ -101,36 +101,36 @@ export function boundary(node, props, boundary_fn) {
101
101
boundary . fn = ( /** @type {unknown } */ input ) => {
102
102
let pending = props . pending ;
103
103
104
- if ( input === SUSPEND_INCREMENT ) {
104
+ if ( input === ASYNC_INCREMENT ) {
105
105
if ( ! pending ) {
106
106
// TODO in this case we need to find the parent boundary
107
107
return false ;
108
108
}
109
109
110
- if ( suspend_count ++ === 0 ) {
111
- queue_micro_task ( ( ) => {
112
- if ( suspended_effect ) {
110
+ if ( async_count ++ === 0 ) {
111
+ queue_boundary_micro_task ( ( ) => {
112
+ if ( async_effect ) {
113
113
return ;
114
114
}
115
115
116
116
var effect = boundary_effect ;
117
- suspended_effect = boundary_effect ;
117
+ async_effect = boundary_effect ;
118
118
119
119
pause_effect (
120
- suspended_effect ,
120
+ async_effect ,
121
121
( ) => {
122
122
/** @type {TemplateNode | null } */
123
123
var node = effect . nodes_start ;
124
124
var end = effect . nodes_end ;
125
- suspended_fragment = document . createDocumentFragment ( ) ;
125
+ async_fragment = document . createDocumentFragment ( ) ;
126
126
127
127
while ( node !== null ) {
128
128
/** @type {TemplateNode | null } */
129
129
var sibling =
130
130
node === end ? null : /** @type {TemplateNode } */ ( get_next_sibling ( node ) ) ;
131
131
132
132
node . remove ( ) ;
133
- suspended_fragment . append ( node ) ;
133
+ async_fragment . append ( node ) ;
134
134
node = sibling ;
135
135
}
136
136
} ,
@@ -146,23 +146,23 @@ export function boundary(node, props, boundary_fn) {
146
146
return true ;
147
147
}
148
148
149
- if ( input === SUSPEND_DECREMENT ) {
149
+ if ( input === ASYNC_DECREMENT ) {
150
150
if ( ! pending ) {
151
151
// TODO in this case we need to find the parent boundary
152
152
return false ;
153
153
}
154
154
155
- if ( -- suspend_count === 0 ) {
156
- queue_micro_task ( ( ) => {
157
- if ( ! suspended_effect ) {
155
+ if ( -- async_count === 0 ) {
156
+ queue_boundary_micro_task ( ( ) => {
157
+ if ( ! async_effect ) {
158
158
return ;
159
159
}
160
160
if ( boundary_effect ) {
161
161
destroy_effect ( boundary_effect ) ;
162
162
}
163
- boundary_effect = suspended_effect ;
164
- suspended_effect = null ;
165
- anchor . before ( /** @type {DocumentFragment } */ ( suspended_fragment ) ) ;
163
+ boundary_effect = async_effect ;
164
+ async_effect = null ;
165
+ anchor . before ( /** @type {DocumentFragment } */ ( async_fragment ) ) ;
166
166
resume_effect ( boundary_effect ) ;
167
167
} ) ;
168
168
}
@@ -201,7 +201,7 @@ export function boundary(node, props, boundary_fn) {
201
201
}
202
202
203
203
if ( failed ) {
204
- queue_micro_task ( ( ) => {
204
+ queue_boundary_micro_task ( ( ) => {
205
205
render_snippet ( ( ) => {
206
206
failed (
207
207
anchor ,
@@ -228,9 +228,9 @@ export function boundary(node, props, boundary_fn) {
228
228
229
229
/**
230
230
* @param {Effect | null } effect
231
- * @param {typeof SUSPEND_INCREMENT | typeof SUSPEND_DECREMENT } trigger
231
+ * @param {typeof ASYNC_INCREMENT | typeof ASYNC_DECREMENT } trigger
232
232
*/
233
- function trigger_suspense ( effect , trigger ) {
233
+ export function trigger_async_boundary ( effect , trigger ) {
234
234
var current = effect ;
235
235
236
236
while ( current !== null ) {
@@ -244,20 +244,6 @@ function trigger_suspense(effect, trigger) {
244
244
}
245
245
}
246
246
247
- export function create_suspense ( ) {
248
- var current = active_effect ;
249
-
250
- const suspend = ( ) => {
251
- trigger_suspense ( current , SUSPEND_INCREMENT ) ;
252
- } ;
253
-
254
- const unsuspend = ( ) => {
255
- trigger_suspense ( current , SUSPEND_DECREMENT ) ;
256
- } ;
257
-
258
- return [ suspend , unsuspend ] ;
259
- }
260
-
261
247
/**
262
248
* @template T
263
249
* @param {Promise<T> } promise
@@ -282,7 +268,7 @@ export async function preserve_context(promise) {
282
268
}
283
269
284
270
// @ts -ignore
285
- boundary . fn ( SUSPEND_INCREMENT ) ;
271
+ boundary . fn ( ASYNC_INCREMENT ) ;
286
272
287
273
const value = await promise ;
288
274
@@ -293,7 +279,7 @@ export async function preserve_context(promise) {
293
279
set_component_context ( previous_component_context ) ;
294
280
295
281
// @ts -ignore
296
- boundary . fn ( SUSPEND_DECREMENT ) ;
282
+ boundary . fn ( ASYNC_DECREMENT ) ;
297
283
298
284
return value ;
299
285
}
0 commit comments