@atom.io/spa 0.0.2 → 0.0.3

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 (87) hide show
  1. package/README.md +63 -10
  2. package/README.mdx +26 -5
  3. package/dist/astro-application.d.ts +1 -1
  4. package/dist/astro-application.js +2 -2
  5. package/dist/astro-application.js.map +1 -1
  6. package/dist/astro-client.d.ts +1 -1
  7. package/dist/astro-client.js +2 -2
  8. package/dist/{astro-shared-DyzbUi6c.d.ts → astro-shared-BkWvVZWZ.d.ts} +2 -2
  9. package/dist/{astro-shared-DyzbUi6c.d.ts.map → astro-shared-BkWvVZWZ.d.ts.map} +1 -1
  10. package/dist/astro.d.ts +1 -1
  11. package/dist/capabilities-BkQ2i0vV.js +63 -0
  12. package/dist/capabilities-BkQ2i0vV.js.map +1 -0
  13. package/dist/{capabilities-yC9TsHDI.d.ts → capabilities-CFP-HIuY.d.ts} +54 -1
  14. package/dist/capabilities-CFP-HIuY.d.ts.map +1 -0
  15. package/dist/client.min.js +1 -1
  16. package/dist/{capabilities-BuZUQpiD.js → core-DCmqLZQP.js} +16 -59
  17. package/dist/core-DCmqLZQP.js.map +1 -0
  18. package/dist/development/astro-application.js +2 -2
  19. package/dist/development/astro-application.js.map +1 -1
  20. package/dist/development/astro-client.js +2 -2
  21. package/dist/development/capabilities-BkQ2i0vV.js +63 -0
  22. package/dist/development/capabilities-BkQ2i0vV.js.map +1 -0
  23. package/dist/development/{capabilities-DhOJmeoJ.js → core-p9vciX9C.js} +16 -59
  24. package/dist/development/core-p9vciX9C.js.map +1 -0
  25. package/dist/development/{dom-BKc6V_Kz.js → dom-Ci1XvbVJ.js} +16 -7
  26. package/dist/development/dom-Ci1XvbVJ.js.map +1 -0
  27. package/dist/development/index.js +3 -3
  28. package/dist/development/konva.js +25 -3
  29. package/dist/development/konva.js.map +1 -1
  30. package/dist/development/motion.js +392 -8
  31. package/dist/development/motion.js.map +1 -1
  32. package/dist/development/renderer.js +23 -10
  33. package/dist/development/renderer.js.map +1 -1
  34. package/dist/development/server.js +2 -1
  35. package/dist/development/server.js.map +1 -1
  36. package/dist/development/{src-Dh-d6w4y.js → src-DG0xjuS5.js} +2 -2
  37. package/dist/development/{src-Dh-d6w4y.js.map → src-DG0xjuS5.js.map} +1 -1
  38. package/dist/development/three.js +24 -10
  39. package/dist/development/three.js.map +1 -1
  40. package/dist/{dom-B2rm8o2L.js → dom-dHQM0O7Q.js} +16 -7
  41. package/dist/dom-dHQM0O7Q.js.map +1 -0
  42. package/dist/{index-BdwxmSKg.d.ts → index-CJJXcKaw.d.ts} +3 -3
  43. package/dist/{index-BdwxmSKg.d.ts.map → index-CJJXcKaw.d.ts.map} +1 -1
  44. package/dist/index.d.ts +3 -3
  45. package/dist/index.js +3 -3
  46. package/dist/{jsx-runtime-CZU7F8Qz.d.ts → jsx-runtime-CREZYKDC.d.ts} +2 -2
  47. package/dist/{jsx-runtime-CZU7F8Qz.d.ts.map → jsx-runtime-CREZYKDC.d.ts.map} +1 -1
  48. package/dist/jsx-runtime.d.ts +1 -1
  49. package/dist/konva.d.ts +3 -3
  50. package/dist/konva.d.ts.map +1 -1
  51. package/dist/konva.js +25 -3
  52. package/dist/konva.js.map +1 -1
  53. package/dist/motion.d.ts +2 -1
  54. package/dist/motion.d.ts.map +1 -1
  55. package/dist/motion.js +392 -8
  56. package/dist/motion.js.map +1 -1
  57. package/dist/renderer.d.ts +3 -3
  58. package/dist/renderer.d.ts.map +1 -1
  59. package/dist/renderer.js +23 -10
  60. package/dist/renderer.js.map +1 -1
  61. package/dist/server.d.ts +1 -1
  62. package/dist/server.js +2 -1
  63. package/dist/server.js.map +1 -1
  64. package/dist/size.json +12 -12
  65. package/dist/{src-BZxX4xbU.js → src-DCQa6qxs.js} +2 -2
  66. package/dist/{src-BZxX4xbU.js.map → src-DCQa6qxs.js.map} +1 -1
  67. package/dist/three.d.ts +3 -3
  68. package/dist/three.d.ts.map +1 -1
  69. package/dist/three.js +24 -10
  70. package/dist/three.js.map +1 -1
  71. package/package.json +8 -6
  72. package/src/astro-application.ts +2 -2
  73. package/src/capabilities.ts +21 -2
  74. package/src/core.ts +27 -2
  75. package/src/dom.ts +35 -4
  76. package/src/konva.ts +41 -14
  77. package/src/motion-tween.ts +106 -0
  78. package/src/motion.ts +122 -9
  79. package/src/presence.ts +324 -0
  80. package/src/renderer.ts +51 -14
  81. package/src/three-events.ts +13 -1
  82. package/src/three.ts +38 -15
  83. package/dist/capabilities-BuZUQpiD.js.map +0 -1
  84. package/dist/capabilities-yC9TsHDI.d.ts.map +0 -1
  85. package/dist/development/capabilities-DhOJmeoJ.js.map +0 -1
  86. package/dist/development/dom-BKc6V_Kz.js.map +0 -1
  87. package/dist/dom-B2rm8o2L.js.map +0 -1
@@ -0,0 +1,324 @@
1
+ import type { CapabilityBinding } from "./capabilities.ts"
2
+ import type { Cleanup, Root, Scope } from "./core.ts"
3
+ import { dispose, fail, invalidate, isPresent, untrack } from "./core.ts"
4
+
5
+ export interface ExitHandle {
6
+ finished: Promise<void>
7
+ cancel(): void
8
+ }
9
+ export interface ExitParticipant {
10
+ exit(): ExitHandle | undefined
11
+ resume(): void
12
+ }
13
+ export interface PresenceTarget {
14
+ kind: string
15
+ node: unknown
16
+ suspend?(): Cleanup
17
+ }
18
+ export interface PresenceCollection<T, V> {
19
+ take(key: unknown, value: V): T | undefined
20
+ remove(
21
+ record: T,
22
+ key: unknown,
23
+ eligible: boolean,
24
+ index: number,
25
+ done: Cleanup,
26
+ ): void
27
+ merge(records: T[]): T[]
28
+ }
29
+ export interface PresenceCoordinator {
30
+ collection<T, V>(
31
+ scope: (record: T) => Scope,
32
+ compatible: (record: T, value: V) => boolean,
33
+ ): PresenceCollection<T, V>
34
+ target(scope: Scope, target: PresenceTarget): void
35
+ bind(
36
+ scope: Scope,
37
+ binding: CapabilityBinding,
38
+ read: () => Record<string, unknown>,
39
+ namespace: string,
40
+ ): void
41
+ unbind(binding: CapabilityBinding): void
42
+ event(scope: Scope, handler: Function): Function
43
+ remove(scope: Scope, done: Cleanup): boolean
44
+ resume(scope: Scope): void
45
+ forget(scope: Scope): void
46
+ }
47
+ interface Session {
48
+ scope: Scope
49
+ participant: ExitParticipant
50
+ handle: ExitHandle
51
+ done: boolean
52
+ cancelled: boolean
53
+ }
54
+ interface Group {
55
+ scope: Scope
56
+ sessions: Session[]
57
+ done: Cleanup
58
+ }
59
+
60
+ /** Optional coordinator: only imported by integrations that support retention. */
61
+ export function createPresence(root: Root): PresenceCoordinator {
62
+ const releases = new Map<CapabilityBinding, Cleanup>()
63
+ const handlers = new WeakMap<Scope, WeakMap<Function, Function>>()
64
+ // Groups own absent ranges; sessions can be shared when a parent adopts a child exit.
65
+ const groups = new Map<Scope, Group>()
66
+ const sessions = new Set<Session>()
67
+ const active = new Map<ExitParticipant, Session>()
68
+ const suspended = new Map<PresenceTarget, { scope: Scope; restore: Cleanup }>()
69
+ const suspend = (target: PresenceTarget): Cleanup => {
70
+ if (target.kind !== `dom`) return target.suspend!()
71
+ const node = target.node as HTMLElement
72
+ const inert = node.getAttribute(`inert`),
73
+ hidden = node.getAttribute(`aria-hidden`)
74
+ const pointer = node.style.getPropertyValue(`pointer-events`),
75
+ priority = node.style.getPropertyPriority(`pointer-events`)
76
+ const focused = node.ownerDocument.activeElement as HTMLElement | null
77
+ if (focused && node.contains(focused)) focused.blur()
78
+ node.setAttribute(`inert`, ``)
79
+ node.setAttribute(`aria-hidden`, `true`)
80
+ node.style.setProperty(`pointer-events`, `none`, `important`)
81
+ return () => {
82
+ for (const [key, value] of [
83
+ [`inert`, inert],
84
+ [`aria-hidden`, hidden],
85
+ ] as const) {
86
+ if (value === null) node.removeAttribute(key)
87
+ else node.setAttribute(key, value)
88
+ }
89
+ if (pointer) node.style.setProperty(`pointer-events`, pointer, priority)
90
+ else node.style.removeProperty(`pointer-events`)
91
+ }
92
+ }
93
+ const walk = (scope: Scope, visit: (scope: Scope) => void) => {
94
+ const descend = (at: Scope) => {
95
+ visit(at)
96
+ for (const child of at._cleanups)
97
+ if (typeof child !== `function`) descend(child)
98
+ }
99
+ descend(scope)
100
+ }
101
+ const ancestor = (scope: Scope, parent: Scope) => {
102
+ for (let at: Scope | undefined = scope; at; at = at._parent)
103
+ if (at === parent) return true
104
+ return false
105
+ }
106
+ const report = (error: unknown) => {
107
+ if (root._dead) return
108
+ try {
109
+ fail(root, error)
110
+ } catch (failure) {
111
+ root.error(failure)
112
+ }
113
+ }
114
+ const finish = () => {
115
+ for (const group of [...groups.values()]) {
116
+ if (group.scope._dead || group.sessions.some((session) => !session.done))
117
+ continue
118
+ if (
119
+ [...groups.keys()].some(
120
+ (scope) => scope !== group.scope && ancestor(group.scope, scope),
121
+ )
122
+ )
123
+ continue
124
+ groups.delete(group.scope)
125
+ try {
126
+ group.done()
127
+ } catch (error) {
128
+ report(error)
129
+ }
130
+ }
131
+ }
132
+ const cancel = (session: Session) => {
133
+ session.cancelled = true
134
+ sessions.delete(session)
135
+ active.delete(session.participant)
136
+ session.handle.cancel()
137
+ }
138
+ const coordinator: PresenceCoordinator = {
139
+ target(scope, target) {
140
+ ;(scope._targets ??= new Set()).add(target)
141
+ scope._cleanups.add(() => {
142
+ scope._targets!.delete(target)
143
+ })
144
+ },
145
+ bind(scope, binding, props, namespace) {
146
+ const read = () =>
147
+ Object.fromEntries(
148
+ Object.entries(props())
149
+ .filter(([key]) => key.startsWith(`${namespace}:`))
150
+ .map(([key, value]) => [key.slice(namespace.length + 1), value]),
151
+ )
152
+ if (!binding.exit) return
153
+ const participant = {
154
+ exit: () => binding.exit!(untrack(read)),
155
+ resume() {
156
+ binding.update(untrack(read))
157
+ binding.resume?.()
158
+ },
159
+ }
160
+ ;(scope._exits ??= new Set()).add(participant)
161
+ const release = () => {
162
+ scope._exits!.delete(participant)
163
+ scope._cleanups.delete(release)
164
+ releases.delete(binding)
165
+ }
166
+ releases.set(binding, release)
167
+ scope._cleanups.add(release)
168
+ },
169
+ unbind(binding) {
170
+ releases.get(binding)?.()
171
+ },
172
+ event(scope, handler) {
173
+ const cached = handlers.get(scope) ?? new WeakMap<Function, Function>()
174
+ handlers.set(scope, cached)
175
+ if (!cached.has(handler))
176
+ cached.set(handler, function (this: unknown, ...args: unknown[]) {
177
+ if (isPresent(scope)) return handler.apply(this, args)
178
+ })
179
+ return cached.get(handler)!
180
+ },
181
+ collection<T, V>(
182
+ scopeOf: (record: T) => Scope,
183
+ compatible: (record: T, value: V) => boolean,
184
+ ): PresenceCollection<T, V> {
185
+ let order: T[] = []
186
+ const exiting = new Map<
187
+ T,
188
+ { key: unknown; eligible: boolean; index: number }
189
+ >()
190
+ return {
191
+ take(key, value) {
192
+ // Empty conditional children do not replace an exiting generation.
193
+ if (value == null || typeof value === `boolean`) return undefined
194
+ for (const [record, state] of exiting)
195
+ if (state.eligible && state.key === key) {
196
+ if (!compatible(record, value)) {
197
+ state.eligible = false
198
+ return undefined
199
+ }
200
+ exiting.delete(record)
201
+ return record
202
+ }
203
+ return undefined
204
+ },
205
+ remove(record, key, eligible, index, done) {
206
+ const position = order.indexOf(record)
207
+ const state = { key, eligible, index: position < 0 ? index : position }
208
+ exiting.set(record, state)
209
+ let pending = false
210
+ const release = () => {
211
+ dispose(scopeOf(record))
212
+ exiting.delete(record)
213
+ order = order.filter((item) => item !== record)
214
+ for (const other of exiting.values())
215
+ if (other.index > state.index) other.index--
216
+ if (pending) done()
217
+ }
218
+ pending = coordinator.remove(scopeOf(record), release)
219
+ if (!pending) release()
220
+ },
221
+ merge(records) {
222
+ const rendered = [...records]
223
+ for (const [record, state] of [...exiting].sort(
224
+ (a, b) => a[1].index - b[1].index,
225
+ )) {
226
+ rendered.splice(Math.min(state.index, rendered.length), 0, record)
227
+ state.index = rendered.indexOf(record)
228
+ }
229
+ // DOM reconciliation reverses its result while moving ranges. Keep a snapshot.
230
+ order = [...rendered]
231
+ return rendered
232
+ },
233
+ }
234
+ },
235
+ remove(scope, done) {
236
+ const collected: Session[] = []
237
+ walk(scope, (at) => {
238
+ for (const participant of at._exits ?? []) {
239
+ let session = active.get(participant)
240
+ if (!session) {
241
+ const handle = untrack(() => participant.exit())
242
+ if (!handle) continue
243
+ session = {
244
+ scope: at,
245
+ participant,
246
+ handle,
247
+ done: false,
248
+ cancelled: false,
249
+ }
250
+ sessions.add(session)
251
+ active.set(participant, session)
252
+ const held = session
253
+ void handle.finished.then(
254
+ () => {
255
+ if (held.cancelled || root._dead) return
256
+ held.done = true
257
+ finish()
258
+ },
259
+ (error) => {
260
+ if (!held.cancelled) report(error)
261
+ },
262
+ )
263
+ }
264
+ collected.push(session)
265
+ }
266
+ })
267
+ if (!collected.some((session) => !session.done)) return false
268
+ scope._exiting = true
269
+ groups.set(scope, { scope, sessions: collected, done })
270
+ walk(scope, (at) => {
271
+ for (const target of at._targets ?? [])
272
+ if (
273
+ !suspended.has(target) &&
274
+ (target.kind === `dom` || target.suspend)
275
+ )
276
+ suspended.set(target, { scope: at, restore: suspend(target) })
277
+ })
278
+ return true
279
+ },
280
+ resume(scope) {
281
+ if (!groups.delete(scope)) return
282
+ scope._exiting = false
283
+ for (const session of [...sessions])
284
+ if (ancestor(session.scope, scope) && isPresent(session.scope)) {
285
+ cancel(session)
286
+ }
287
+ walk(scope, (at) => {
288
+ if (isPresent(at))
289
+ for (const participant of at._exits ?? []) participant.resume()
290
+ })
291
+ for (const [target, state] of suspended)
292
+ if (isPresent(state.scope)) {
293
+ suspended.delete(target)
294
+ state.restore()
295
+ }
296
+ invalidate(scope)
297
+ // Reconcile returning descendants before releasing their adopted, completed exits.
298
+ queueMicrotask(finish)
299
+ },
300
+ forget(scope) {
301
+ const errors: unknown[] = []
302
+ for (const session of [...sessions])
303
+ if (ancestor(session.scope, scope)) {
304
+ try {
305
+ cancel(session)
306
+ } catch (error) {
307
+ errors.push(error)
308
+ }
309
+ }
310
+ for (const at of groups.keys()) if (ancestor(at, scope)) groups.delete(at)
311
+ for (const [target, state] of suspended)
312
+ if (ancestor(state.scope, scope)) {
313
+ suspended.delete(target)
314
+ try {
315
+ state.restore()
316
+ } catch (error) {
317
+ errors.push(error)
318
+ }
319
+ }
320
+ if (errors.length) throw new AggregateError(errors)
321
+ },
322
+ }
323
+ return coordinator
324
+ }
package/src/renderer.ts CHANGED
@@ -7,6 +7,7 @@ import {
7
7
  dispose,
8
8
  fail,
9
9
  invalidate,
10
+ isPresent,
10
11
  observe,
11
12
  owner,
12
13
  untrack,
@@ -22,13 +23,15 @@ export interface SceneHost<N> {
22
23
  props: Record<string, any>,
23
24
  previous: Record<string, any>,
24
25
  ): void
25
- children(parent: N, children: N[]): void
26
+ children(parent: N, children: N[], activeChildren: N[]): void
26
27
  destroy(node: N): void
27
28
  }
29
+ type SceneNodes<N> = (activeOnly?: boolean) => N[]
30
+
28
31
  interface Entry<N> {
29
32
  scope: Scope
30
33
  value: Child
31
- nodes: () => N[]
34
+ nodes: SceneNodes<N>
32
35
  }
33
36
 
34
37
  export interface SceneRenderer<N> {
@@ -46,12 +49,29 @@ export function createSceneRenderer<N>(host: SceneHost<N>): SceneRenderer<N> {
46
49
  source: () => Child,
47
50
  scope: Scope,
48
51
  changed: () => void,
49
- ): () => N[] {
52
+ ): SceneNodes<N> {
50
53
  let entries: Entry<N>[] = []
54
+ const presence = scope._root._presence?.collection<Entry<N>, Child>(
55
+ (entry) => entry.scope,
56
+ (entry, value) => same(entry.value, value),
57
+ )
58
+ const retire = (
59
+ entry: Entry<N>,
60
+ id: string,
61
+ eligible: boolean,
62
+ index: number,
63
+ ) => {
64
+ if (presence)
65
+ presence.remove(entry, id, eligible, index, () => {
66
+ if (!scope._dead) changed()
67
+ })
68
+ else dispose(entry.scope)
69
+ }
51
70
  observe(scope, source, (next) => {
52
71
  const values = (
53
72
  Array.isArray(next) ? next.flat(Infinity) : [next]
54
73
  ) as Child[]
74
+ const previous = entries
55
75
  const old = new Map(
56
76
  entries.map((entry, i) => [key(entry.value, i), entry]),
57
77
  )
@@ -63,11 +83,18 @@ export function createSceneRenderer<N>(host: SceneHost<N>): SceneRenderer<N> {
63
83
  let entry = old.get(id)
64
84
  old.delete(id)
65
85
  if (entry && !same(entry.value, value)) {
66
- dispose(entry.scope)
86
+ retire(
87
+ entry,
88
+ id,
89
+ value == null || typeof value === `boolean`,
90
+ previous.indexOf(entry),
91
+ )
67
92
  entry = undefined
68
93
  }
94
+ entry ??= presence?.take(id, value)
69
95
  if (entry) {
70
96
  entry.value = value
97
+ scope._root._presence?.resume(entry.scope)
71
98
  invalidate(entry.scope)
72
99
  return entry
73
100
  }
@@ -76,10 +103,16 @@ export function createSceneRenderer<N>(host: SceneHost<N>): SceneRenderer<N> {
76
103
  created.nodes = build(() => created.value, childScope, changed)
77
104
  return created
78
105
  })
79
- for (const entry of old.values()) dispose(entry.scope)
106
+ for (const [id, entry] of old)
107
+ retire(entry, id, true, previous.indexOf(entry))
80
108
  changed()
81
109
  })
82
- return () => entries.flatMap((entry) => entry.nodes())
110
+ return (activeOnly = false) => {
111
+ const rendered = activeOnly
112
+ ? entries
113
+ : (presence?.merge(entries) ?? entries)
114
+ return rendered.flatMap((entry) => entry.nodes(activeOnly))
115
+ }
83
116
  }
84
117
  function key(value: Child, i: number): string {
85
118
  const explicit = (value as VNode | null)?.props?.[`key`]
@@ -95,7 +128,7 @@ export function createSceneRenderer<N>(host: SceneHost<N>): SceneRenderer<N> {
95
128
  source: () => Child,
96
129
  scope: Scope,
97
130
  changed: () => void,
98
- ): () => N[] {
131
+ ): SceneNodes<N> {
99
132
  const value = untrack(source)
100
133
  if (typeof value === `function`)
101
134
  return mount(() => (source() as () => Child)(), scope, changed)
@@ -124,6 +157,7 @@ export function createSceneRenderer<N>(host: SceneHost<N>): SceneRenderer<N> {
124
157
  const nativeProps = capabilityProps(
125
158
  scope,
126
159
  host.target?.(node) ?? { kind: `scene`, node },
160
+ () => ({ ...props }),
127
161
  )
128
162
  let previous: Record<string, any> = {}
129
163
  observe(
@@ -135,9 +169,9 @@ export function createSceneRenderer<N>(host: SceneHost<N>): SceneRenderer<N> {
135
169
  previous = next
136
170
  },
137
171
  )
138
- let children: () => N[] = () => []
172
+ let children: SceneNodes<N> = () => []
139
173
  const sync = () => {
140
- host.children(node, children())
174
+ host.children(node, children(), children(true))
141
175
  }
142
176
  children = mount(() => props[`children`], scope, sync)
143
177
  sync()
@@ -152,14 +186,14 @@ export function createSceneRenderer<N>(host: SceneHost<N>): SceneRenderer<N> {
152
186
  return () => [node]
153
187
  }
154
188
  function attach(setup: () => Child, parent: N, scope: Scope) {
155
- let nodes: () => N[] = () => []
189
+ let nodes: SceneNodes<N> = () => []
156
190
  const sync = () => {
157
- host.children(parent, nodes())
191
+ host.children(parent, nodes(), nodes(true))
158
192
  }
159
193
  nodes = mount(() => untrack(setup), scope, sync)
160
194
  sync()
161
195
  scope._cleanups.add(() => {
162
- host.children(parent, [])
196
+ host.children(parent, [], [])
163
197
  })
164
198
  }
165
199
  return {
@@ -204,7 +238,10 @@ export function bindScene<T>(read: () => T, apply: (value: T) => void): void {
204
238
  }
205
239
 
206
240
  /** Scene drawing follows an installed capability clock, or the browser clock. */
207
- export function onSceneFrame(callback: (time: number) => void): void {
241
+ export function onSceneFrame(
242
+ callback: (time: number) => void,
243
+ infrastructure = false,
244
+ ): void {
208
245
  const scope = owner!
209
246
  const clocks = [...scope._root._capabilities.values()].filter(
210
247
  (capability) => capability.scheduleFrame,
@@ -212,7 +249,7 @@ export function onSceneFrame(callback: (time: number) => void): void {
212
249
  if (clocks.length > 1)
213
250
  throw new Error(`spa: multiple frame clock capabilities`)
214
251
  const draw = (time: number) => {
215
- if (scope._dead) return
252
+ if (scope._dead || (!infrastructure && !isPresent(scope))) return
216
253
  try {
217
254
  callback(time)
218
255
  } catch (error) {
@@ -36,6 +36,14 @@ export interface ThreeEventAttributes<
36
36
  }
37
37
  type Hit = { node: THREE.Object3D; intersection: THREE.Intersection }
38
38
  type Handler = ThreeEventHandler
39
+ const suspended = new WeakSet<THREE.Object3D>()
40
+ export function suspendThree(node: THREE.Object3D): () => void {
41
+ suspended.add(node)
42
+ for (const manager of managers) manager.remove(node)
43
+ return () => {
44
+ suspended.delete(node)
45
+ }
46
+ }
39
47
  const listeners = new WeakMap<THREE.Object3D, Map<string, Set<Handler>>>()
40
48
  const managers = new Set<{ remove(node: THREE.Object3D): void }>()
41
49
 
@@ -105,7 +113,11 @@ export function createThreeEvents(
105
113
  }
106
114
  const eligible = (intersection: THREE.Intersection) => {
107
115
  const nodes = path(intersection.object)
108
- if (!nodes.length || nodes.some((node) => !node.visible)) return false
116
+ if (
117
+ !nodes.length ||
118
+ nodes.some((node) => !node.visible || suspended.has(node))
119
+ )
120
+ return false
109
121
  const material = (intersection.object as THREE.Mesh).material
110
122
  return (
111
123
  !material ||
package/src/three.ts CHANGED
@@ -1,6 +1,11 @@
1
- import { fail, owner } from "./core.ts"
1
+ import { fail, isPresent, owner } from "./core.ts"
2
2
  import type { ThreeEventAttributes, ThreeEventHandler } from "./three-events.ts"
3
- import { createThreeEvents, forgetThree, listenThree } from "./three-events.ts"
3
+ import {
4
+ createThreeEvents,
5
+ forgetThree,
6
+ listenThree,
7
+ suspendThree,
8
+ } from "./three-events.ts"
4
9
 
5
10
  export type {
6
11
  ThreeEventAttributes,
@@ -81,6 +86,7 @@ const renderer = createSceneRenderer<Resource>({
81
86
  node,
82
87
  ...(node instanceof THREE.Object3D
83
88
  ? {
89
+ suspend: () => suspendThree(node),
84
90
  listen: (type: string, listener: () => void) =>
85
91
  listenThree(node, type, listener),
86
92
  }
@@ -160,7 +166,7 @@ const renderer = createSceneRenderer<Resource>({
160
166
  }
161
167
  if (node instanceof THREE.PerspectiveCamera) node.updateProjectionMatrix()
162
168
  },
163
- children(parent, children) {
169
+ children(parent, children, activeChildren) {
164
170
  if (!(parent instanceof THREE.Object3D)) {
165
171
  if (children.length)
166
172
  throw new Error(`spa/three: resources cannot contain children`)
@@ -185,7 +191,13 @@ const renderer = createSceneRenderer<Resource>({
185
191
  const materials = resources.filter(
186
192
  (child) => child instanceof THREE.Material,
187
193
  )
188
- if (geometries.length > 1 || materials.length > 1)
194
+ const activeGeometries = activeChildren.filter(
195
+ (child) => child instanceof THREE.BufferGeometry,
196
+ )
197
+ const activeMaterials = activeChildren.filter(
198
+ (child) => child instanceof THREE.Material,
199
+ )
200
+ if (activeGeometries.length > 1 || activeMaterials.length > 1)
189
201
  throw new Error(
190
202
  `spa/three: each Mesh accepts one geometry and one material`,
191
203
  )
@@ -195,8 +207,17 @@ const renderer = createSceneRenderer<Resource>({
195
207
  baseline = { geometry: parent.geometry, material: parent.material }
196
208
  borrowedMeshDefaults.set(parent, baseline)
197
209
  }
198
- parent.geometry = geometries[0] ?? baseline.geometry
199
- parent.material = materials[0] ?? baseline.material
210
+ // Retention owns outgoing resources without occupying incoming attachment slots.
211
+ parent.geometry =
212
+ activeGeometries[0] ??
213
+ geometries.find((geometry) => geometry === parent.geometry) ??
214
+ geometries.at(-1) ??
215
+ baseline.geometry
216
+ parent.material =
217
+ activeMaterials[0] ??
218
+ materials.find((material) => material === parent.material) ??
219
+ materials.at(-1) ??
220
+ baseline.material
200
221
  if (!owned && children.length === 0) borrowedMeshDefaults.delete(parent)
201
222
  }
202
223
  },
@@ -256,7 +277,8 @@ export function Canvas(props: CanvasProps): VNode {
256
277
  },
257
278
  )
258
279
  renderer.mount(() => props.children, scene)
259
- const root = owner!._root
280
+ const scope = owner!
281
+ const root = scope._root
260
282
  const events = createThreeEvents(
261
283
  canvas!,
262
284
  scene,
@@ -277,16 +299,17 @@ export function Canvas(props: CanvasProps): VNode {
277
299
  const active = props.camera ?? camera
278
300
  const delta = last === undefined ? 0 : (time - last) / 1000
279
301
  last = time
280
- props.onFrame?.({
281
- scene,
282
- camera: active,
283
- renderer: webgl,
284
- delta,
285
- time: time / 1000,
286
- })
302
+ if (isPresent(scope))
303
+ props.onFrame?.({
304
+ scene,
305
+ camera: active,
306
+ renderer: webgl,
307
+ delta,
308
+ time: time / 1000,
309
+ })
287
310
  events.update()
288
311
  webgl.render(scene, active)
289
- })
312
+ }, true)
290
313
  })
291
314
  return jsx(`canvas`, {
292
315
  ref: (element: HTMLCanvasElement | null) => {
@@ -1 +0,0 @@
1
- {"version":3,"file":"capabilities-BuZUQpiD.js","names":[],"sources":["../src/core.ts","../src/capabilities.ts"],"sourcesContent":["import type {\n\tReadableFamilyToken,\n\tReadableToken,\n\tRegularAtomFamilyToken,\n\tRegularAtomToken,\n\tSetter,\n\tTimelineFamilyToken,\n\tTimelineManageable,\n\tTimelineToken,\n\tTransactionToken,\n\tViewOf,\n\tWritableFamilyToken,\n\tWritableToken,\n} from \"atom.io\"\nimport type { Canonical } from \"atom.io/foundations/canonical\"\nimport type { RootStore } from \"atom.io/internal\"\nimport {\n\tactUponStore,\n\tclearTimelineInStore,\n\tfindInStore,\n\tfindTimelineInStore,\n\tgetFromStore,\n\tgetTimelineTransactionAtHead,\n\tIMPLICIT,\n\tinspectTimelineInStore,\n\tsetIntoStore,\n\tsubscribeToState,\n\tsubscribeToTimeline,\n\ttimeTravel,\n\ttimeTravelTransactionGroupInStore,\n} from \"atom.io/internal\"\n\nimport type { Capability } from \"./capabilities.ts\"\n\nexport type Cleanup = () => void\n// A callable interface permits the recursive Child union. A type alias does not.\n/* oxlint-disable typescript/prefer-function-type -- A callable interface is required for recursive Child. */\nexport interface Accessor<T> {\n\t(): T\n}\n/* oxlint-enable typescript/prefer-function-type */\nexport type Component<P = any> = (props: P) => Child\nexport interface VNode {\n\ttype: string | Component | null\n\tprops: Record<string, any>\n}\nexport type Child =\n\t| VNode\n\t| string\n\t| number\n\t| bigint\n\t| boolean\n\t| null\n\t| undefined\n\t| readonly Child[]\n\t| Accessor<Child>\nexport interface RootOptions {\n\tcapabilities?: readonly Capability[]\n\tstore?: RootStore\n\tidPrefix?: string\n\tonError?: (error: unknown) => void\n}\nexport interface Scope {\n\t_root: Root\n\t_parent?: Scope | undefined\n\t_cleanups: Set<Cleanup | Scope>\n\t_updates: Cleanup[]\n\t_dead: boolean\n}\nexport interface Root extends Scope {\n\t_capabilities: Map<string, Capability>\n\t_store: RootStore\n\t_prefix: string\n\t_id: number\n\t_queue: Set<Cleanup>\n\t_mounts: Cleanup[] | undefined\n\tflush: Cleanup\n\terror: (error: unknown) => void\n}\n\nexport let owner: Scope | undefined\ntype Subscribe = (notify: Cleanup) => Cleanup\nlet tracking: ((subscribe: Subscribe) => void) | undefined\nlet serial = 0\n\nexport function within<T>(scope: Scope, run: () => T): T {\n\tconst previous = owner\n\towner = scope\n\ttry {\n\t\treturn run()\n\t} finally {\n\t\towner = previous\n\t}\n}\nexport function untrack<T>(run: () => T): T {\n\tconst previous = tracking\n\ttracking = undefined\n\ttry {\n\t\treturn run()\n\t} finally {\n\t\ttracking = previous\n\t}\n}\nexport function createScope(parent?: Scope): Scope {\n\tconst child: Scope = {\n\t\t_root: parent?._root as Root,\n\t\t_parent: parent,\n\t\t_cleanups: new Set(),\n\t\t_updates: [],\n\t\t_dead: false,\n\t}\n\tparent?._cleanups.add(child)\n\treturn child\n}\nexport function fail(scope: Scope, error: unknown): never {\n\ttry {\n\t\tdispose(scope)\n\t} catch (cleanup) {\n\t\tthrow new AggregateError([error, cleanup])\n\t}\n\tthrow error\n}\nexport function dispose(scope: Scope): void {\n\tif (scope._dead) return\n\tscope._dead = true\n\tconst errors: unknown[] = []\n\tfor (const cleanup of [...scope._cleanups].reverse()) {\n\t\ttry {\n\t\t\ttypeof cleanup === `function` ? cleanup() : dispose(cleanup)\n\t\t} catch (error) {\n\t\t\terrors.push(error)\n\t\t}\n\t}\n\tscope._parent?._cleanups.delete(scope)\n\tscope._cleanups.clear()\n\tscope._updates.length = 0\n\tif (errors.length) throw new AggregateError(errors)\n}\nexport function invalidate(scope: Scope): void {\n\tfor (const run of scope._updates) enqueue(scope, run)\n\tfor (const child of scope._cleanups)\n\t\tif (typeof child !== `function`) invalidate(child)\n}\nfunction enqueue(scope: Scope, run: Cleanup): void {\n\tif (scope._dead) return\n\tconst root = scope._root\n\tif (!root._queue.size)\n\t\tqueueMicrotask(() => {\n\t\t\ttry {\n\t\t\t\troot.flush()\n\t\t\t} catch (error) {\n\t\t\t\troot.error(error)\n\t\t\t}\n\t\t})\n\troot._queue.add(run)\n}\nexport function createRoot(options: RootOptions = {}, server = false): Root {\n\tconst capabilities = new Map<string, Capability>()\n\tfor (const capability of options.capabilities ?? []) {\n\t\tif (capabilities.has(capability.namespace))\n\t\t\tthrow new Error(`spa: duplicate capability ${capability.namespace}`)\n\t\tcapabilities.set(capability.namespace, capability)\n\t}\n\tconst root = {\n\t\t_capabilities: capabilities,\n\t\t_store: options.store ?? IMPLICIT.STORE,\n\t\t_prefix: options.idPrefix ?? `w${serial++}`,\n\t\t_id: 0,\n\t\t...createScope(),\n\t\t_queue: new Set(),\n\t\t_mounts: server ? undefined : [],\n\t} as unknown as Root\n\troot._root = root\n\troot.error =\n\t\toptions.onError ??\n\t\t((error) => {\n\t\t\tthrow error\n\t\t})\n\troot.flush = () => {\n\t\ttry {\n\t\t\tlet passes = 0\n\t\t\twhile (root._queue.size || root._mounts!.length) {\n\t\t\t\tif (import.meta.env.DEV && ++passes > 100)\n\t\t\t\t\tthrow new Error(`spa: update loop`)\n\t\t\t\tfor (const run of [...root._queue]) if (root._queue.delete(run)) run()\n\t\t\t\tfor (const run of root._mounts!.splice(0)) run()\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tfail(root, error)\n\t\t}\n\t}\n\treturn root\n}\n/** Return the atom.io store selected by the current root. */\nexport function useStore(): RootStore {\n\treturn owner!._root._store\n}\nexport function onCleanup(cleanup: Cleanup): void {\n\towner!._cleanups.add(cleanup)\n}\nexport function onMount(run: Cleanup): void {\n\tconst scope = owner!\n\tscope._root._mounts?.push(() => {\n\t\tif (!scope._dead)\n\t\t\twithin(scope, () => {\n\t\t\t\tuntrack(run)\n\t\t\t})\n\t})\n}\nexport function useId(): string {\n\tconst root = owner!._root\n\treturn `${root._prefix}-${root._id++}`\n}\n\nexport function observe<T>(\n\tscope: Scope,\n\tread: Accessor<T>,\n\tapply: (value: T) => void,\n): void {\n\tconst subscriptions = new Map<Subscribe, Cleanup>()\n\tconst run = () => {\n\t\tif (scope._dead) return\n\t\tconst used = new Set<Subscribe>()\n\t\tconst previous = tracking\n\t\ttracking = (subscribe) => {\n\t\t\tused.add(subscribe)\n\t\t\tif (!subscriptions.has(subscribe))\n\t\t\t\tsubscriptions.set(\n\t\t\t\t\tsubscribe,\n\t\t\t\t\tsubscribe(() => {\n\t\t\t\t\t\tenqueue(scope, run)\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t}\n\t\tlet value: T\n\t\ttry {\n\t\t\tvalue = within(scope, read)\n\t\t} finally {\n\t\t\ttracking = previous\n\t\t\tfor (const [subscribe, unsubscribe] of subscriptions)\n\t\t\t\tif (!used.has(subscribe)) {\n\t\t\t\t\tunsubscribe()\n\t\t\t\t\tsubscriptions.delete(subscribe)\n\t\t\t\t}\n\t\t}\n\t\tuntrack(() => {\n\t\t\tapply(value)\n\t\t})\n\t}\n\tscope._updates.push(run)\n\tscope._cleanups.add(() => {\n\t\tscope._root._queue.delete(run)\n\t\tfor (const unsubscribe of subscriptions.values()) unsubscribe()\n\t})\n\trun()\n}\n\n/** Resolve a fixed family key in the current owner's store. */\nexport function resolveStateToken(token: any, key?: Canonical): any {\n\tconst store = owner!._root._store\n\treturn token.type.endsWith(`_family`) ? findInStore(store, token, key!) : token\n}\n\n/** Capture a token for this instance. Change the component key to change its token. */\nexport function useValue<T, E = never>(\n\ttoken: ReadableToken<T, any, E>,\n): Accessor<ViewOf<T | E>>\nexport function useValue<T, K extends Canonical, E = never>(\n\tfamily: ReadableFamilyToken<T, K, E>,\n\tkey: NoInfer<K>,\n): Accessor<ViewOf<T | E>>\nexport function useValue(token: any, key?: Canonical): Accessor<any> {\n\ttoken = resolveStateToken(token, key)\n\tconst store = owner!._root._store\n\tconst subscribe: Subscribe = (notify) =>\n\t\tsubscribeToState(store, token, `spa:${serial++}`, notify)\n\treturn () => {\n\t\tconst value = getFromStore(store, token)\n\t\ttracking?.(subscribe)\n\t\treturn value\n\t}\n}\nexport function useSetter<T>(\n\ttoken: WritableToken<T, any, any>,\n): (value: T | Setter<T>) => void\nexport function useSetter<T, K extends Canonical>(\n\tfamily: WritableFamilyToken<T, K, any>,\n\tkey: NoInfer<K>,\n): (value: T | Setter<T>) => void\nexport function useSetter(token: any, key?: Canonical): (value: any) => void {\n\ttoken = resolveStateToken(token, key)\n\tconst store = owner!._root._store\n\treturn (value) => {\n\t\tsetIntoStore(store, token, value)\n\t}\n}\nexport function useTransaction<F extends (...args: any[]) => any>(\n\ttoken: TransactionToken<F>,\n): (...args: Parameters<F>) => ReturnType<F> {\n\treturn actUponStore(owner!._root._store, token, `spa:${serial++}`)\n}\n\nconst refs = new WeakMap<RootStore, Map<string, object>>()\nexport function useRef<E extends Element>(\n\ttoken: RegularAtomToken<E | null>,\n): (element: E | null) => void\nexport function useRef<E extends Element, K extends Canonical>(\n\tfamily: RegularAtomFamilyToken<E | null, K>,\n\tkey: NoInfer<K>,\n): (element: E | null) => void\nexport function useRef<E extends Element>(\n\ttoken: any,\n\tkey?: Canonical,\n): (element: E | null) => void {\n\ttoken = resolveStateToken(token, key)\n\tconst store = owner!._root._store\n\tconst owners = refs.get(store) ?? new Map<string, object>()\n\trefs.set(store, owners)\n\tconst identity = {}\n\tlet held: E | null = null\n\treturn (element) => {\n\t\tif (element) {\n\t\t\theld = element\n\t\t\towners.set(token.key, identity)\n\t\t\tsetIntoStore(store, token, element)\n\t\t} else if (owners.get(token.key) === identity) {\n\t\t\towners.delete(token.key)\n\t\t\tif (getFromStore(store, token) === held) setIntoStore(store, token, null)\n\t\t\theld = null\n\t\t}\n\t}\n}\nexport interface TimelineValue {\n\tat: number\n\tlength: number\n\tundo(): void\n\tredo(): void\n\tclear(): void\n\tundoTransaction?: Cleanup\n\tredoTransaction?: Cleanup\n}\nexport function useTimeline<M extends TimelineManageable>(\n\ttoken: TimelineToken<M>,\n): Accessor<TimelineValue>\nexport function useTimeline<K extends Canonical, M extends TimelineManageable>(\n\tfamily: TimelineFamilyToken<K, M>,\n\tkey: NoInfer<K>,\n): Accessor<TimelineValue>\nexport function useTimeline(\n\ttoken: any,\n\tkey?: Canonical,\n): Accessor<TimelineValue> {\n\tconst store = owner!._root._store\n\tif (token.type === `timeline_family`)\n\t\ttoken = findTimelineInStore(store, token, key!)\n\tconst subscribe: Subscribe = (notify) =>\n\t\tsubscribeToTimeline(store, token, `spa:${serial++}`, notify)\n\tconst controls = {\n\t\tundo: () => {\n\t\t\ttimeTravel(store, `undo`, token)\n\t\t},\n\t\tredo: () => {\n\t\t\ttimeTravel(store, `redo`, token)\n\t\t},\n\t\tclear: () => {\n\t\t\tclearTimelineInStore(store, token)\n\t\t},\n\t}\n\treturn () => {\n\t\tconst value: TimelineValue = {\n\t\t\t...inspectTimelineInStore(store, token),\n\t\t\t...controls,\n\t\t}\n\t\ttracking?.(subscribe)\n\t\tfor (const direction of [`undo`, `redo`] as const) {\n\t\t\tconst group = getTimelineTransactionAtHead(\n\t\t\t\tstore.timelines.get(token.key)!,\n\t\t\t\tdirection,\n\t\t\t)\n\t\t\tif (group)\n\t\t\t\tvalue[`${direction}Transaction`] = () =>\n\t\t\t\t\ttimeTravelTransactionGroupInStore(store, direction, group)\n\t\t}\n\t\treturn value\n\t}\n}\n\nexport function plain(value: Child): string {\n\tif (typeof value === `function`) return plain(value())\n\tif (Array.isArray(value)) return value.map(plain).join(``)\n\tif (value == null || typeof value === `boolean`) return ``\n\tif (import.meta.env.DEV && typeof value === `object`)\n\t\tthrow new Error(`spa: text required`)\n\t// oxlint-disable-next-line typescript/no-base-to-string -- Valid text children are primitives here; development rejects malformed object children.\n\treturn String(value)\n}\n","import type { Cleanup, Scope } from \"./core.ts\"\n\n/** Native renderers expose property access without importing capability engines. */\nexport interface CapabilityTarget {\n\tkind: string\n\tnode: unknown\n\tread?(key: string): unknown\n\twrite?(key: string, value: unknown): void\n\tlisten?(event: string, listener: () => void): Cleanup\n}\nexport interface CapabilityBinding {\n\tupdate(props: Record<string, unknown>): void\n\tdispose(): void\n}\nexport interface Capability {\n\tnamespace: string\n\tscheduleFrame?(callback: (time: number) => void): Cleanup\n\tattach(target: CapabilityTarget): CapabilityBinding\n}\n\nexport function capabilityNamespace(key: string): string | undefined {\n\tconst colon = key.indexOf(`:`)\n\tif (colon < 0) return undefined\n\tconst namespace = key.slice(0, colon)\n\treturn /^(xml|xmlns|xlink)$/.test(namespace) ? undefined : namespace\n}\nexport function validateCapabilities(\n\tscope: Scope,\n\tprops: Record<string, unknown>,\n): void {\n\tfor (const key of Object.keys(props)) {\n\t\tconst namespace = capabilityNamespace(key)\n\t\tif (namespace && !scope._root._capabilities.has(namespace))\n\t\t\tthrow new Error(\n\t\t\t\t`spa: capability \"${namespace}\" is not registered for this root`,\n\t\t\t)\n\t}\n}\n\n/** Separate framework properties from native attributes and own their bindings. */\nexport function capabilityProps(\n\tscope: Scope,\n\ttarget: CapabilityTarget,\n): (props: Record<string, any>) => Record<string, any> {\n\tconst bindings = new Map<string, CapabilityBinding>()\n\tconst cleanup: Cleanup = () => {\n\t\tconst errors: unknown[] = []\n\t\tfor (const binding of [...bindings.values()].reverse()) {\n\t\t\ttry {\n\t\t\t\tbinding.dispose()\n\t\t\t} catch (error) {\n\t\t\t\terrors.push(error)\n\t\t\t}\n\t\t}\n\t\tbindings.clear()\n\t\tif (errors.length) throw new AggregateError(errors)\n\t}\n\tscope._cleanups.add(cleanup)\n\treturn (props) => {\n\t\tvalidateCapabilities(scope, props)\n\t\tconst native: Record<string, any> = {}\n\t\tconst groups = new Map<string, Record<string, unknown>>()\n\t\tfor (const key of Object.keys(props)) {\n\t\t\tconst namespace = capabilityNamespace(key)\n\t\t\tif (!namespace) {\n\t\t\t\tnative[key] = props[key]\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst group = groups.get(namespace) ?? {}\n\t\t\tgroup[key.slice(namespace.length + 1)] = props[key]\n\t\t\tgroups.set(namespace, group)\n\t\t}\n\t\tfor (const [namespace, values] of groups) {\n\t\t\tlet binding = bindings.get(namespace)\n\t\t\tif (!binding) {\n\t\t\t\tbinding = scope._root._capabilities.get(namespace)!.attach(target)\n\t\t\t\tbindings.set(namespace, binding)\n\t\t\t}\n\t\t\tbinding.update(values)\n\t\t}\n\t\tfor (const [namespace, binding] of bindings)\n\t\t\tif (!groups.has(namespace)) {\n\t\t\t\tbindings.delete(namespace)\n\t\t\t\tbinding.dispose()\n\t\t\t}\n\t\treturn native\n\t}\n}\n"],"mappings":";;AAgFA,IAAW;AAEX,IAAI;AACJ,IAAI,SAAS;AAEb,SAAgB,OAAU,OAAc,KAAiB;CACxD,MAAM,WAAW;CACjB,QAAQ;CACR,IAAI;EACH,OAAO,IAAI;CACZ,UAAU;EACT,QAAQ;CACT;AACD;AACA,SAAgB,QAAW,KAAiB;CAC3C,MAAM,WAAW;CACjB,WAAW,KAAA;CACX,IAAI;EACH,OAAO,IAAI;CACZ,UAAU;EACT,WAAW;CACZ;AACD;AACA,SAAgB,YAAY,QAAuB;CAClD,MAAM,QAAe;EACpB,OAAO,QAAQ;EACf,SAAS;EACT,2BAAW,IAAI,IAAI;EACnB,UAAU,CAAC;EACX,OAAO;CACR;CACA,QAAQ,UAAU,IAAI,KAAK;CAC3B,OAAO;AACR;AACA,SAAgB,KAAK,OAAc,OAAuB;CACzD,IAAI;EACH,QAAQ,KAAK;CACd,SAAS,SAAS;EACjB,MAAM,IAAI,eAAe,CAAC,OAAO,OAAO,CAAC;CAC1C;CACA,MAAM;AACP;AACA,SAAgB,QAAQ,OAAoB;CAC3C,IAAI,MAAM,OAAO;CACjB,MAAM,QAAQ;CACd,MAAM,SAAoB,CAAC;CAC3B,KAAK,MAAM,WAAW,CAAC,GAAG,MAAM,SAAS,CAAC,CAAC,QAAQ,GAClD,IAAI;EACH,OAAO,YAAY,aAAa,QAAQ,IAAI,QAAQ,OAAO;CAC5D,SAAS,OAAO;EACf,OAAO,KAAK,KAAK;CAClB;CAED,MAAM,SAAS,UAAU,OAAO,KA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