@trioforge/crucible 0.0.0-stage → 0.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.
Files changed (183) hide show
  1. package/LICENSE +21 -0
  2. package/client/package.json +4 -0
  3. package/emit/package.json +4 -0
  4. package/out/all.d.ts +7 -0
  5. package/out/all.luau +2 -0
  6. package/out/attribute.d.ts +7 -0
  7. package/out/attribute.luau +7 -0
  8. package/out/client/index.d.ts +10 -0
  9. package/out/client/init.luau +55 -0
  10. package/out/configs.d.ts +37 -0
  11. package/out/configs.luau +46 -0
  12. package/out/crucible-behaviour.d.ts +16 -0
  13. package/out/crucible-behaviour.luau +78 -0
  14. package/out/crucible-object.d.ts +10 -0
  15. package/out/crucible-object.luau +69 -0
  16. package/out/data.d.ts +224 -0
  17. package/out/data.luau +97 -0
  18. package/out/emit/configs.d.ts +4 -0
  19. package/out/emit/configs.luau +22 -0
  20. package/out/emit/data.d.ts +6 -0
  21. package/out/emit/data.luau +19 -0
  22. package/out/emit/index.d.ts +45 -0
  23. package/out/emit/init.luau +101 -0
  24. package/out/emit/network.d.ts +6 -0
  25. package/out/emit/network.luau +36 -0
  26. package/out/emit/replicated.d.ts +4 -0
  27. package/out/emit/replicated.luau +13 -0
  28. package/out/index.d.ts +20 -0
  29. package/out/init.luau +34 -0
  30. package/out/inject.d.ts +1 -0
  31. package/out/inject.luau +7 -0
  32. package/out/internal/binding.d.ts +1 -0
  33. package/out/internal/binding.luau +615 -0
  34. package/out/internal/boot.d.ts +1 -0
  35. package/out/internal/boot.luau +562 -0
  36. package/out/internal/configs/limits.d.ts +10 -0
  37. package/out/internal/configs/limits.luau +25 -0
  38. package/out/internal/configs/port.d.ts +29 -0
  39. package/out/internal/configs/port.luau +99 -0
  40. package/out/internal/configs/runtime.d.ts +21 -0
  41. package/out/internal/configs/runtime.luau +981 -0
  42. package/out/internal/construction-claim.d.ts +1 -0
  43. package/out/internal/construction-claim.luau +26 -0
  44. package/out/internal/data/admission.d.ts +1 -0
  45. package/out/internal/data/admission.luau +673 -0
  46. package/out/internal/data/declarations.d.ts +1 -0
  47. package/out/internal/data/declarations.luau +384 -0
  48. package/out/internal/data/envelope.d.ts +1 -0
  49. package/out/internal/data/envelope.luau +318 -0
  50. package/out/internal/data/handles.d.ts +1 -0
  51. package/out/internal/data/handles.luau +255 -0
  52. package/out/internal/data/inbox-transforms.d.ts +1 -0
  53. package/out/internal/data/inbox-transforms.luau +458 -0
  54. package/out/internal/data/inbox.d.ts +1 -0
  55. package/out/internal/data/inbox.luau +437 -0
  56. package/out/internal/data/lease.d.ts +1 -0
  57. package/out/internal/data/lease.luau +304 -0
  58. package/out/internal/data/limits.d.ts +1 -0
  59. package/out/internal/data/limits.luau +234 -0
  60. package/out/internal/data/messages.d.ts +1 -0
  61. package/out/internal/data/messages.luau +69 -0
  62. package/out/internal/data/operation-id.d.ts +1 -0
  63. package/out/internal/data/operation-id.luau +61 -0
  64. package/out/internal/data/paths.d.ts +2 -0
  65. package/out/internal/data/paths.luau +323 -0
  66. package/out/internal/data/port.d.ts +1 -0
  67. package/out/internal/data/port.luau +290 -0
  68. package/out/internal/data/profiles.d.ts +1 -0
  69. package/out/internal/data/profiles.luau +862 -0
  70. package/out/internal/data/receipts.d.ts +1 -0
  71. package/out/internal/data/receipts.luau +190 -0
  72. package/out/internal/data/record-bindings.d.ts +1 -0
  73. package/out/internal/data/record-bindings.luau +92 -0
  74. package/out/internal/data/record-declarations.d.ts +1 -0
  75. package/out/internal/data/record-declarations.luau +140 -0
  76. package/out/internal/data/records.d.ts +1 -0
  77. package/out/internal/data/records.luau +400 -0
  78. package/out/internal/data/runtime.d.ts +1 -0
  79. package/out/internal/data/runtime.luau +918 -0
  80. package/out/internal/data/scheduler.d.ts +1 -0
  81. package/out/internal/data/scheduler.luau +507 -0
  82. package/out/internal/data/session.d.ts +1 -0
  83. package/out/internal/data/session.luau +234 -0
  84. package/out/internal/data/shutdown.d.ts +1 -0
  85. package/out/internal/data/shutdown.luau +91 -0
  86. package/out/internal/data/waiters.d.ts +1 -0
  87. package/out/internal/data/waiters.luau +65 -0
  88. package/out/internal/dense-list.d.ts +1 -0
  89. package/out/internal/dense-list.luau +155 -0
  90. package/out/internal/diagnostics.d.ts +1 -0
  91. package/out/internal/diagnostics.luau +29 -0
  92. package/out/internal/hooks.d.ts +1 -0
  93. package/out/internal/hooks.luau +53 -0
  94. package/out/internal/implementers.d.ts +1 -0
  95. package/out/internal/implementers.luau +119 -0
  96. package/out/internal/lifecycle.d.ts +1 -0
  97. package/out/internal/lifecycle.luau +912 -0
  98. package/out/internal/log-output.d.ts +1 -0
  99. package/out/internal/log-output.luau +106 -0
  100. package/out/internal/network/catalog.d.ts +26 -0
  101. package/out/internal/network/catalog.luau +182 -0
  102. package/out/internal/network/claims.d.ts +1 -0
  103. package/out/internal/network/claims.luau +154 -0
  104. package/out/internal/network/client-session.d.ts +1 -0
  105. package/out/internal/network/client-session.luau +403 -0
  106. package/out/internal/network/codec.d.ts +63 -0
  107. package/out/internal/network/codec.luau +1183 -0
  108. package/out/internal/network/envelope.d.ts +1 -0
  109. package/out/internal/network/envelope.luau +247 -0
  110. package/out/internal/network/limits.d.ts +26 -0
  111. package/out/internal/network/limits.luau +55 -0
  112. package/out/internal/network/port.d.ts +1 -0
  113. package/out/internal/network/port.luau +19 -0
  114. package/out/internal/network/roblox-network-port.d.ts +1 -0
  115. package/out/internal/network/roblox-network-port.luau +105 -0
  116. package/out/internal/network/schema.d.ts +72 -0
  117. package/out/internal/network/schema.luau +386 -0
  118. package/out/internal/network/server-session.d.ts +1 -0
  119. package/out/internal/network/server-session.luau +393 -0
  120. package/out/internal/network/session.d.ts +1 -0
  121. package/out/internal/network/session.luau +266 -0
  122. package/out/internal/port.d.ts +1 -0
  123. package/out/internal/port.luau +12 -0
  124. package/out/internal/reactive/context.d.ts +1 -0
  125. package/out/internal/reactive/context.luau +149 -0
  126. package/out/internal/reactive/flush.d.ts +1 -0
  127. package/out/internal/reactive/flush.luau +355 -0
  128. package/out/internal/reactive/graph.d.ts +1 -0
  129. package/out/internal/reactive/graph.luau +626 -0
  130. package/out/internal/reactive/limits.d.ts +1 -0
  131. package/out/internal/reactive/limits.luau +54 -0
  132. package/out/internal/reactive/ownership.d.ts +1 -0
  133. package/out/internal/reactive/ownership.luau +626 -0
  134. package/out/internal/registry.d.ts +1 -0
  135. package/out/internal/registry.luau +455 -0
  136. package/out/internal/roblox-port.d.ts +1 -0
  137. package/out/internal/roblox-port.luau +117 -0
  138. package/out/internal/runner.d.ts +1 -0
  139. package/out/internal/runner.luau +86 -0
  140. package/out/internal/scheduler.d.ts +1 -0
  141. package/out/internal/scheduler.luau +207 -0
  142. package/out/internal/state.d.ts +1 -0
  143. package/out/internal/state.luau +41 -0
  144. package/out/internal/sync/client-sync.d.ts +1 -0
  145. package/out/internal/sync/client-sync.luau +157 -0
  146. package/out/internal/sync/declarations.d.ts +1 -0
  147. package/out/internal/sync/declarations.luau +276 -0
  148. package/out/internal/sync/frame.d.ts +1 -0
  149. package/out/internal/sync/frame.luau +91 -0
  150. package/out/internal/sync/server-sync.d.ts +1 -0
  151. package/out/internal/sync/server-sync.luau +502 -0
  152. package/out/internal/sync/values.d.ts +1 -0
  153. package/out/internal/sync/values.luau +930 -0
  154. package/out/log-level.d.ts +7 -0
  155. package/out/log-level.luau +21 -0
  156. package/out/logging.d.ts +34 -0
  157. package/out/logging.luau +233 -0
  158. package/out/network.d.ts +66 -0
  159. package/out/network.luau +24 -0
  160. package/out/reactive.d.ts +76 -0
  161. package/out/reactive.luau +136 -0
  162. package/out/replicated.d.ts +38 -0
  163. package/out/replicated.luau +45 -0
  164. package/out/server/data.d.ts +54 -0
  165. package/out/server/data.luau +44 -0
  166. package/out/server/index.d.ts +18 -0
  167. package/out/server/init.luau +62 -0
  168. package/out/server/publish.d.ts +20 -0
  169. package/out/server/publish.luau +24 -0
  170. package/out/subsystem.d.ts +4 -0
  171. package/out/subsystem.luau +30 -0
  172. package/out/vide/index.d.ts +7 -0
  173. package/out/vide/init.luau +50 -0
  174. package/package.json +52 -5
  175. package/server/package.json +4 -0
  176. package/transformer/data.cjs +72 -0
  177. package/transformer/declarations.cjs +153 -0
  178. package/transformer/diagnostics.cjs +19 -0
  179. package/transformer/index.js +741 -0
  180. package/transformer/network.cjs +961 -0
  181. package/transformer/type-id.cjs +80 -0
  182. package/vide/package.json +4 -0
  183. package/README.md +0 -3
@@ -0,0 +1,615 @@
1
+ -- Compiled with roblox-ts v3.0.0
2
+ local TS = _G[script]
3
+ local runtimeDiagnostic = TS.import(script, script.Parent, "diagnostics").runtimeDiagnostic
4
+ local _construction_claim = TS.import(script, script.Parent, "construction-claim")
5
+ local clearClaim = _construction_claim.clearClaim
6
+ local setClaim = _construction_claim.setClaim
7
+ local _lifecycle = TS.import(script, script.Parent, "lifecycle")
8
+ local drain = _lifecycle.drain
9
+ local fault = _lifecycle.fault
10
+ local hasEnded = _lifecycle.hasEnded
11
+ local isDraining = _lifecycle.isDraining
12
+ local isLive = _lifecycle.isLive
13
+ local notePairs = _lifecycle.notePairs
14
+ local request = _lifecycle.request
15
+ local track = _lifecycle.track
16
+ local recordOf = TS.import(script, script.Parent, "registry").recordOf
17
+ local call = TS.import(script, script.Parent, "runner").call
18
+ local installed
19
+ local pairsByRecord = {}
20
+ local wrongClasses = {}
21
+ local byTag = {}
22
+ local queued = {}
23
+ local scheduled = false
24
+ local getWarnings = {}
25
+ local scopeRejected = false
26
+ local scopeTarget
27
+ local function port()
28
+ return installed or error("Crucible binding used before boot")
29
+ end
30
+ --* @internal The port boot installed, for framework Subsystems that connect engine events.
31
+ local function enginePort()
32
+ return port()
33
+ end
34
+ --* @internal
35
+ local function useEngine(engine)
36
+ installed = engine
37
+ end
38
+ --* @internal
39
+ local function defaultAccepts(instance)
40
+ local ok = port().bindingScope(instance)
41
+ if not ok and instance == scopeTarget then
42
+ scopeRejected = true
43
+ end
44
+ return ok
45
+ end
46
+ --* @internal
47
+ local function construct(state)
48
+ local record = state.record
49
+ local _exp = record.resolved
50
+ -- ▼ ReadonlyArray.map ▼
51
+ local _newValue = table.create(#_exp)
52
+ local _callback = function(dep)
53
+ local _result
54
+ if dep.all then
55
+ _result = dep.set
56
+ else
57
+ local _result_1 = dep.record.state
58
+ if _result_1 ~= nil then
59
+ _result_1 = _result_1.object
60
+ end
61
+ _result = _result_1
62
+ end
63
+ return _result
64
+ end
65
+ for _k, _v in _exp do
66
+ _newValue[_k] = _callback(_v, _k - 1, _exp)
67
+ end
68
+ -- ▲ ReadonlyArray.map ▲
69
+ local args = _newValue
70
+ local worker
71
+ local result, value = call(function()
72
+ worker = coroutine.running()
73
+ setClaim(state)
74
+ return record.klass.new(unpack(args))
75
+ end, nil, nil, state)
76
+ -- The constructor worker can be cancelled before its own cleanup runs.
77
+ if worker ~= nil then
78
+ clearClaim(worker)
79
+ end
80
+ if result ~= 0 then
81
+ error(value, 0)
82
+ end
83
+ return value
84
+ end
85
+ local function pairFor(record, instance)
86
+ local _record = record
87
+ local instances = pairsByRecord[_record]
88
+ if instances == nil then
89
+ instances = {}
90
+ local _record_1 = record
91
+ local _instances = instances
92
+ pairsByRecord[_record_1] = _instances
93
+ end
94
+ local _instances = instances
95
+ local _instance = instance
96
+ local pair = _instances[_instance]
97
+ if pair == nil then
98
+ local _object = {
99
+ record = record,
100
+ instance = instance,
101
+ queued = false,
102
+ parked = false,
103
+ running = false,
104
+ reset = false,
105
+ rejected = nil,
106
+ }
107
+ local _left = "wrongClass"
108
+ local _record_1 = record
109
+ local _result = wrongClasses[_record_1]
110
+ if _result ~= nil then
111
+ local _instance_1 = instance
112
+ _result = _result[_instance_1] ~= nil
113
+ end
114
+ local _condition = _result
115
+ if _condition == nil then
116
+ _condition = false
117
+ end
118
+ _object[_left] = _condition
119
+ _object.warnings = {}
120
+ pair = _object
121
+ local _instances_1 = instances
122
+ local _instance_1 = instance
123
+ local _pair = pair
124
+ _instances_1[_instance_1] = _pair
125
+ end
126
+ return pair
127
+ end
128
+ local function queue(pair)
129
+ if pair.running then
130
+ return nil
131
+ end
132
+ if pair.rejected == "accepts" then
133
+ pair.rejected = nil
134
+ end
135
+ if pair.parked then
136
+ pair.parked = false
137
+ pair.queued = false
138
+ end
139
+ if not pair.queued then
140
+ pair.queued = true
141
+ local _queued = queued
142
+ local _pair = pair
143
+ table.insert(_queued, _pair)
144
+ end
145
+ notePairs()
146
+ end
147
+ local function schedule()
148
+ if scheduled then
149
+ return nil
150
+ end
151
+ scheduled = true
152
+ port().defer(function()
153
+ scheduled = false
154
+ drain()
155
+ end)
156
+ end
157
+ local function disconnect(pair)
158
+ local connections = pair.connections
159
+ pair.connections = nil
160
+ if connections ~= nil then
161
+ for _, stop in connections do
162
+ stop()
163
+ end
164
+ end
165
+ end
166
+ local function warning(pair, field, condition, message)
167
+ local _warnings = pair.warnings
168
+ local _field = field
169
+ if _warnings[_field] == condition then
170
+ return nil
171
+ end
172
+ local _warnings_1 = pair.warnings
173
+ local _field_1 = field
174
+ local _condition = condition
175
+ _warnings_1[_field_1] = _condition
176
+ runtimeDiagnostic("warning", message)
177
+ end
178
+ local function valueFor(pair, field, state)
179
+ local _descriptor = pair.record.attributes
180
+ if _descriptor ~= nil then
181
+ local _field = field
182
+ _descriptor = _descriptor[_field]
183
+ end
184
+ local descriptor = _descriptor
185
+ if descriptor == nil then
186
+ return true, nil
187
+ end
188
+ local value = port().getAttribute(pair.instance, descriptor.name)
189
+ local valid = if value == nil then not descriptor.required else descriptor.check(value)
190
+ if valid then
191
+ local _warnings = pair.warnings
192
+ local _field = field
193
+ _warnings[_field] = nil
194
+ return true, value
195
+ end
196
+ local condition = typeof(value)
197
+ warning(pair, field, condition, `{pair.record.id} on {port().describe(pair.instance)}: attribute {descriptor.name} is invalid ({condition}); {if state == nil then "not bound" else "keeping the last valid value"}`)
198
+ return false, value
199
+ end
200
+ --* @internal
201
+ local function applyAttribute(state, field)
202
+ local record = state.record
203
+ if record.kind ~= 1 or state.instance == nil or state.attributes == nil then
204
+ return nil
205
+ end
206
+ local pair = pairFor(record, state.instance)
207
+ local valid, value = valueFor(pair, field, state)
208
+ if not valid then
209
+ return nil
210
+ end
211
+ state.attributes[field] = value
212
+ if state.object ~= nil then
213
+ (state.object)[field] = value
214
+ end
215
+ end
216
+ local reset
217
+ local function connect(pair)
218
+ if pair.connections ~= nil then
219
+ return nil
220
+ end
221
+ local _binding = pair
222
+ local record = _binding.record
223
+ local instance = _binding.instance
224
+ pair.connections = { port().onAncestryChanged(instance, function()
225
+ if not port().inWorld(instance) then
226
+ reset(pair)
227
+ end
228
+ queue(pair)
229
+ schedule()
230
+ end) }
231
+ for field, descriptor in record.attributes or {} do
232
+ local _connections = pair.connections
233
+ local _arg0 = port().onAttributeChanged(instance, descriptor.name, function()
234
+ local state = record.bound[instance]
235
+ if state ~= nil and not hasEnded(state) then
236
+ applyAttribute(state, field)
237
+ else
238
+ queue(pair)
239
+ schedule()
240
+ end
241
+ end)
242
+ table.insert(_connections, _arg0)
243
+ end
244
+ local state = record.bound[instance]
245
+ if state ~= nil then
246
+ for field in record.attributes or {} do
247
+ applyAttribute(state, field)
248
+ end
249
+ end
250
+ end
251
+ function reset(pair)
252
+ pair.reset = true
253
+ local _suppressed = pair.record.suppressed
254
+ local _instance = pair.instance
255
+ _suppressed[_instance] = nil
256
+ table.clear(pair.warnings)
257
+ disconnect(pair)
258
+ end
259
+ local function callAccepts(klass, instance)
260
+ return klass:accepts(instance)
261
+ end
262
+ local function accepted(pair, state)
263
+ local result, value = call(callAccepts, pair.record.klass, pair.instance, state)
264
+ if result == 0 then
265
+ return value == true
266
+ end
267
+ local _suppressed = pair.record.suppressed
268
+ local _instance = pair.instance
269
+ _suppressed[_instance] = true
270
+ if state ~= nil then
271
+ fault(state, 7, value)
272
+ else
273
+ runtimeDiagnostic("error", `{pair.record.id}.accepts failed on {port().describe(pair.instance)}: {value}`)
274
+ end
275
+ return false
276
+ end
277
+ local function evaluate(pair)
278
+ local _binding = pair
279
+ local record = _binding.record
280
+ local instance = _binding.instance
281
+ local engine = port()
282
+ pair.rejected = nil
283
+ local present = engine.inWorld(instance) and engine.hasTag(instance, record.tag)
284
+ if not present then
285
+ reset(pair)
286
+ end
287
+ local have = record.bound[instance]
288
+ if have ~= nil then
289
+ if present then
290
+ connect(pair)
291
+ end
292
+ if pair.reset or not present or record.suppressed[instance] ~= nil then
293
+ request(have, 2)
294
+ return nil
295
+ end
296
+ scopeRejected = false
297
+ scopeTarget = instance
298
+ local ok = accepted(pair, have)
299
+ if not ok then
300
+ pair.rejected = if scopeRejected then "scope" else "accepts"
301
+ end
302
+ if not ok or pair.reset or not engine.inWorld(instance) or not engine.hasTag(instance, record.tag) or record.suppressed[instance] ~= nil then
303
+ request(have, 2)
304
+ end
305
+ return nil
306
+ end
307
+ if pair.reset then
308
+ pair.reset = false
309
+ record.suppressed[instance] = nil
310
+ end
311
+ if not present then
312
+ local _result = pairsByRecord[record]
313
+ if _result ~= nil then
314
+ _result[instance] = nil
315
+ end
316
+ return nil
317
+ end
318
+ connect(pair)
319
+ if record.suppressed[instance] ~= nil then
320
+ return nil
321
+ end
322
+ local _exp = record.instanceClasses
323
+ -- ▼ ReadonlyArray.some ▼
324
+ local _result = false
325
+ local _callback = function(name)
326
+ return engine.isA(instance, name)
327
+ end
328
+ for _k, _v in _exp do
329
+ if _callback(_v, _k - 1, _exp) then
330
+ _result = true
331
+ break
332
+ end
333
+ end
334
+ -- ▲ ReadonlyArray.some ▲
335
+ if not _result then
336
+ pair.rejected = "class"
337
+ if not pair.wrongClass then
338
+ pair.wrongClass = true
339
+ local warned = wrongClasses[record]
340
+ if warned == nil then
341
+ warned = setmetatable({}, {
342
+ __mode = "k",
343
+ })
344
+ local _warned = warned
345
+ wrongClasses[record] = _warned
346
+ end
347
+ warned[instance] = true
348
+ local _exp_1 = string.split(record.id, ":")
349
+ -- ▼ Array.pop ▼
350
+ local _length = #_exp_1
351
+ local _result_1 = _exp_1[_length]
352
+ _exp_1[_length] = nil
353
+ -- ▲ Array.pop ▲
354
+ local _condition = _result_1
355
+ if _condition == nil then
356
+ _condition = record.id
357
+ end
358
+ local className = _condition
359
+ runtimeDiagnostic("warning", `{engine.describe(instance)} is a {instance.ClassName}; {className} needs a {table.concat(record.instanceClasses, " or ")}`)
360
+ end
361
+ return nil
362
+ end
363
+ local attributes = {}
364
+ local valid = true
365
+ for field in record.attributes or {} do
366
+ local ok, value = valueFor(pair, field)
367
+ if not ok then
368
+ valid = false
369
+ end
370
+ attributes[field] = value
371
+ end
372
+ if not valid then
373
+ pair.rejected = "attributes"
374
+ return nil
375
+ end
376
+ scopeRejected = false
377
+ scopeTarget = instance
378
+ if not accepted(pair) then
379
+ pair.rejected = if scopeRejected then "scope" else "accepts"
380
+ return nil
381
+ end
382
+ if pair.reset or not engine.inWorld(instance) or not engine.hasTag(instance, record.tag) or record.suppressed[instance] ~= nil then
383
+ return nil
384
+ end
385
+ local state = track(record, instance, attributes)
386
+ record.bound[instance] = state
387
+ return state
388
+ end
389
+ --* @internal
390
+ local function reconcile()
391
+ local taken = queued
392
+ queued = {}
393
+ local created = {}
394
+ for _, pair in taken do
395
+ pair.queued = false
396
+ pair.running = true
397
+ local state = evaluate(pair)
398
+ pair.running = false
399
+ local _condition = pair.reset
400
+ if _condition then
401
+ local _bound = pair.record.bound
402
+ local _instance = pair.instance
403
+ _condition = not (_bound[_instance] ~= nil)
404
+ end
405
+ if _condition then
406
+ queue(pair)
407
+ end
408
+ if state ~= nil then
409
+ table.insert(created, state)
410
+ end
411
+ end
412
+ return created
413
+ end
414
+ --* @internal
415
+ local function watch(records)
416
+ local connections = {}
417
+ for _, record in records do
418
+ local _tag = record.tag
419
+ local list = byTag[_tag]
420
+ if list == nil then
421
+ local _tag_1 = record.tag
422
+ local _arg1 = { record }
423
+ byTag[_tag_1] = _arg1
424
+ else
425
+ table.insert(list, record)
426
+ end
427
+ end
428
+ for tag, records in byTag do
429
+ local _arg0 = port().onTagAdded(tag, function(instance)
430
+ for _, record in records do
431
+ queue(pairFor(record, instance))
432
+ end
433
+ schedule()
434
+ end)
435
+ table.insert(connections, _arg0)
436
+ local _arg0_1 = port().onTagRemoved(tag, function(instance)
437
+ for _, record in records do
438
+ local pair = pairFor(record, instance)
439
+ reset(pair)
440
+ queue(pair)
441
+ end
442
+ schedule()
443
+ end)
444
+ table.insert(connections, _arg0_1)
445
+ for _, instance in port().tagged(tag) do
446
+ for _1, record in records do
447
+ queue(pairFor(record, instance))
448
+ end
449
+ end
450
+ end
451
+ return function()
452
+ for _, stop in connections do
453
+ stop()
454
+ end
455
+ for _, instances in pairsByRecord do
456
+ for _1, pair in instances do
457
+ disconnect(pair)
458
+ end
459
+ end
460
+ table.clear(byTag)
461
+ end
462
+ end
463
+ --* @internal
464
+ local function refresh(instance)
465
+ for tag, records in byTag do
466
+ for _, record in records do
467
+ local _condition = port().hasTag(instance, tag)
468
+ if not _condition then
469
+ local _bound = record.bound
470
+ local _instance = instance
471
+ _condition = _bound[_instance] ~= nil
472
+ end
473
+ if _condition then
474
+ queue(pairFor(record, instance))
475
+ end
476
+ end
477
+ end
478
+ drain()
479
+ end
480
+ --* @internal
481
+ local function boundTo(klass, instance)
482
+ local record = recordOf(klass)
483
+ if record == nil or record.kind ~= 1 then
484
+ return nil
485
+ end
486
+ local pair = pairFor(record, instance)
487
+ if isDraining() then
488
+ local _bound = record.bound
489
+ local _instance = instance
490
+ local state = _bound[_instance]
491
+ local attributesValid = true
492
+ if pair.rejected == "attributes" then
493
+ for _, descriptor in record.attributes or {} do
494
+ local value = port().getAttribute(instance, descriptor.name)
495
+ if if value == nil then descriptor.required else not descriptor.check(value) then
496
+ attributesValid = false
497
+ end
498
+ end
499
+ end
500
+ local _condition = (state == nil or not isLive(state)) and (pair.rejected == nil or (pair.rejected == "attributes" and attributesValid) or (pair.rejected == "scope" and port().bindingScope(instance))) and port().inWorld(instance) and port().hasTag(instance, record.tag)
501
+ if _condition then
502
+ local _suppressed = record.suppressed
503
+ local _instance_1 = instance
504
+ _condition = not (_suppressed[_instance_1] ~= nil)
505
+ end
506
+ if _condition then
507
+ local source, line = debug.info(3, "sl")
508
+ local site = `{source}:{line}`
509
+ if not (getWarnings[site] ~= nil) then
510
+ getWarnings[site] = true
511
+ runtimeDiagnostic("warning", `Crucible get pending at {site}`)
512
+ end
513
+ end
514
+ local rejected = pair.rejected
515
+ queue(pair)
516
+ pair.rejected = rejected
517
+ else
518
+ queue(pair)
519
+ -- ▼ ReadonlyArray.filter ▼
520
+ local _newValue = {}
521
+ local _callback = function(other)
522
+ return other ~= pair
523
+ end
524
+ local _length = 0
525
+ for _k, _v in queued do
526
+ if _callback(_v, _k - 1, queued) == true then
527
+ _length += 1
528
+ _newValue[_length] = _v
529
+ end
530
+ end
531
+ -- ▲ ReadonlyArray.filter ▲
532
+ local held = _newValue
533
+ for _, other in held do
534
+ other.parked = true
535
+ end
536
+ queued = { pair }
537
+ drain()
538
+ local _array = {}
539
+ local _length_1 = #_array
540
+ -- ▼ ReadonlyArray.filter ▼
541
+ local _newValue_1 = {}
542
+ local _callback_1 = function(other)
543
+ return other.parked
544
+ end
545
+ local _length_2 = 0
546
+ for _k, _v in held do
547
+ if _callback_1(_v, _k - 1, held) == true then
548
+ _length_2 += 1
549
+ _newValue_1[_length_2] = _v
550
+ end
551
+ end
552
+ -- ▲ ReadonlyArray.filter ▲
553
+ local _Length = #_newValue_1
554
+ table.move(_newValue_1, 1, _Length, _length_1 + 1, _array)
555
+ _length_1 += _Length
556
+ table.move(queued, 1, #queued, _length_1 + 1, _array)
557
+ queued = _array
558
+ for _, other in held do
559
+ other.parked = false
560
+ end
561
+ if #queued > 0 then
562
+ notePairs()
563
+ schedule()
564
+ end
565
+ end
566
+ local _bound = record.bound
567
+ local _instance = instance
568
+ return _bound[_instance]
569
+ end
570
+ --* @internal
571
+ local function remove(state)
572
+ local record = state.record
573
+ if record.kind == 1 and state.instance ~= nil and not hasEnded(state) then
574
+ local _suppressed = record.suppressed
575
+ local _instance = state.instance
576
+ _suppressed[_instance] = true
577
+ end
578
+ request(state, 2)
579
+ end
580
+ --* @internal
581
+ local function forget(state)
582
+ local record = state.record
583
+ if record.kind ~= 1 or state.instance == nil then
584
+ return nil
585
+ end
586
+ local _bound = record.bound
587
+ local _instance = state.instance
588
+ if _bound[_instance] == state then
589
+ local _bound_1 = record.bound
590
+ local _instance_1 = state.instance
591
+ _bound_1[_instance_1] = nil
592
+ end
593
+ local pair = pairFor(record, state.instance)
594
+ if state.phase == 5 and not pair.reset then
595
+ local _suppressed = record.suppressed
596
+ local _instance_1 = state.instance
597
+ _suppressed[_instance_1] = true
598
+ end
599
+ if pair.reset then
600
+ queue(pair)
601
+ end
602
+ end
603
+ return {
604
+ enginePort = enginePort,
605
+ useEngine = useEngine,
606
+ defaultAccepts = defaultAccepts,
607
+ construct = construct,
608
+ applyAttribute = applyAttribute,
609
+ reconcile = reconcile,
610
+ watch = watch,
611
+ refresh = refresh,
612
+ boundTo = boundTo,
613
+ remove = remove,
614
+ forget = forget,
615
+ }
@@ -0,0 +1 @@
1
+ export {};