@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,323 @@
1
+ -- Compiled with roblox-ts v3.0.0
2
+ --* @internal A path segment as TypeScript wrote it: a field or map key, or an array index from 0.
3
+ --* @internal Rule 116: TypeScript indices reach a handle as written; Luau arrays start at 1.
4
+ local function luaKey(segment)
5
+ local _segment = segment
6
+ return if type(_segment) == "number" then segment + 1 else segment
7
+ end
8
+ --* @internal The value at `path`, or undefined where a table on the way is absent. Never throws.
9
+ local function getPath(root, path, from)
10
+ if from == nil then
11
+ from = 0
12
+ end
13
+ local current = root
14
+ do
15
+ local i = from
16
+ local _shouldIncrement = false
17
+ while true do
18
+ if _shouldIncrement then
19
+ i += 1
20
+ else
21
+ _shouldIncrement = true
22
+ end
23
+ if not (i < #path) then
24
+ break
25
+ end
26
+ local _current = current
27
+ if not (type(_current) == "table") then
28
+ return nil
29
+ end
30
+ current = current[luaKey(path[i + 1])]
31
+ end
32
+ end
33
+ return current
34
+ end
35
+ --[[
36
+ *
37
+ * @internal Rule 118's path copy: each table on the path is `table.clone` of the stored one with one field replaced,
38
+ * which is what a spread compiles to, so undeclared keys stay in place at every level (rule 78). A leaf rawequal to the
39
+ * stored one returns `root` itself, which is no revision (rule 12). Admission freezes what this builds (rule 15).
40
+
41
+ ]]
42
+ local function setPath(root, path, leaf, from)
43
+ if from == nil then
44
+ from = 0
45
+ end
46
+ if from >= #path then
47
+ return leaf
48
+ end
49
+ local current = root
50
+ local key = luaKey(path[from + 1])
51
+ local child = current[key]
52
+ local replaced = setPath(child, path, leaf, from + 1)
53
+ if rawequal(replaced, child) then
54
+ return root
55
+ end
56
+ local copy = table.clone(current)
57
+ copy[key] = replaced
58
+ return copy
59
+ end
60
+ --* @internal `FD.Players.career.jobs[0].coins`: keys after dots, indices from 0 in brackets.
61
+ local function describePath(name, path, upTo)
62
+ if upTo == nil then
63
+ upTo = #path
64
+ end
65
+ local text = name
66
+ do
67
+ local i = 0
68
+ local _shouldIncrement = false
69
+ while true do
70
+ if _shouldIncrement then
71
+ i += 1
72
+ else
73
+ _shouldIncrement = true
74
+ end
75
+ if not (i < upTo) then
76
+ break
77
+ end
78
+ local segment = path[i + 1]
79
+ text ..= if type(segment) == "number" then `[{segment}]` else `.{segment}`
80
+ end
81
+ end
82
+ return text
83
+ end
84
+ --* @internal The one table branch of an optional table (`V | undefined`), which keeps its children (rule 116).
85
+ local function tableBranch(node)
86
+ if node == nil or node.kind ~= "union" then
87
+ return node
88
+ end
89
+ local found
90
+ for _, branch in node.branches do
91
+ if branch.kind == "nil" then
92
+ continue
93
+ end
94
+ if found ~= nil then
95
+ return nil
96
+ end
97
+ found = branch
98
+ end
99
+ return if found == nil or found.kind == "variant" then nil else found
100
+ end
101
+ --* @internal The descriptor below `node` at `segment`, or undefined below a leaf or a union of several types.
102
+ local function childNode(node, segment)
103
+ local at = tableBranch(node)
104
+ if at == nil then
105
+ return nil
106
+ end
107
+ local _exp = at.kind
108
+ repeat
109
+ if _exp == "object" then
110
+ local _segment = segment
111
+ if not (type(_segment) == "string") then
112
+ return nil
113
+ end
114
+ for _, _binding in at.fields do
115
+ local name = _binding[1]
116
+ local child = _binding[2]
117
+ if name == segment then
118
+ return child
119
+ end
120
+ end
121
+ return nil
122
+ end
123
+ if _exp == "map" then
124
+ local _segment = segment
125
+ return if type(_segment) == "string" then at.value else nil
126
+ end
127
+ if _exp == "array" then
128
+ local _segment = segment
129
+ return if type(_segment) == "number" then at.element else nil
130
+ end
131
+ if _exp == "tuple" then
132
+ local _segment = segment
133
+ return if type(_segment) == "number" then at.elements[segment + 1] else nil
134
+ end
135
+ return nil
136
+ until true
137
+ end
138
+ --* True when `a` sorts before `b` by bytes.
139
+ local function bytesLess(a, b)
140
+ local length = math.min(#a, #b)
141
+ do
142
+ local i = 1
143
+ local _shouldIncrement = false
144
+ while true do
145
+ if _shouldIncrement then
146
+ i += 1
147
+ else
148
+ _shouldIncrement = true
149
+ end
150
+ if not (i <= length) then
151
+ break
152
+ end
153
+ local x = string.byte(a, i)
154
+ local y = string.byte(b, i)
155
+ if x ~= y then
156
+ return x < y
157
+ end
158
+ end
159
+ end
160
+ return #a < #b
161
+ end
162
+ --* @internal Rule 131's order: segment by segment, each by bytes, a prefix first.
163
+ local function pathLess(a, b)
164
+ local length = math.min(#a, #b)
165
+ do
166
+ local i = 0
167
+ local _shouldIncrement = false
168
+ while true do
169
+ if _shouldIncrement then
170
+ i += 1
171
+ else
172
+ _shouldIncrement = true
173
+ end
174
+ if not (i < length) then
175
+ break
176
+ end
177
+ if a[i + 1] ~= b[i + 1] then
178
+ return bytesLess(a[i + 1], b[i + 1])
179
+ end
180
+ end
181
+ end
182
+ return #a < #b
183
+ end
184
+ --* @internal Two segment arrays are equal segment by segment, never as joined text (rules 4, 131).
185
+ local function samePath(a, b)
186
+ if #a ~= #b then
187
+ return false
188
+ end
189
+ for i = 0, #a - 1 do
190
+ if a[i + 1] ~= b[i + 1] then
191
+ return false
192
+ end
193
+ end
194
+ return true
195
+ end
196
+ --* `{ "career", "a.b" }`, as rule 131's messages print a path.
197
+ local function showPath(path)
198
+ -- ▼ ReadonlyArray.map ▼
199
+ local _newValue = table.create(#path)
200
+ local _callback = function(segment)
201
+ return `"{segment}"`
202
+ end
203
+ for _k, _v in path do
204
+ _newValue[_k] = _callback(_v, _k - 1, path)
205
+ end
206
+ -- ▲ ReadonlyArray.map ▲
207
+ return `\{ {table.concat(_newValue, ", ")} \}`
208
+ end
209
+ --* A key that is "[]" or "*", or starts with a backslash, takes one more backslash, so no key stands for a marker.
210
+ local function escape(key)
211
+ return if key == "[]" or key == "*" or string.sub(key, 1, 1) == "\\" then `\\{key}` else key
212
+ end
213
+ --[[
214
+ *
215
+ * @internal Rule 131: every object field path of `node`, one key per level, "[]" for an array element and "*" for a
216
+ * map value, deduplicated across union members and sorted.
217
+
218
+ ]]
219
+ local function fieldPaths(node)
220
+ local found = {}
221
+ local add = function(path)
222
+ local identity = ""
223
+ for _, segment in path do
224
+ identity ..= `{#segment}:{segment}`
225
+ end
226
+ local _identity = identity
227
+ if not (found[_identity] ~= nil) then
228
+ local _identity_1 = identity
229
+ local _path = path
230
+ found[_identity_1] = _path
231
+ end
232
+ end
233
+ local walk
234
+ walk = function(at, prefix)
235
+ local _exp = at.kind
236
+ repeat
237
+ if _exp == "object" then
238
+ for _, _binding in at.fields do
239
+ local key = _binding[1]
240
+ local child = _binding[2]
241
+ local _array = {}
242
+ local _length = #_array
243
+ local _prefixLength = #prefix
244
+ table.move(prefix, 1, _prefixLength, _length + 1, _array)
245
+ _length += _prefixLength
246
+ _array[_length + 1] = escape(key)
247
+ local path = _array
248
+ add(path)
249
+ walk(child, path)
250
+ end
251
+ return nil
252
+ end
253
+ if _exp == "array" then
254
+ local _exp_1 = at.element
255
+ local _array = {}
256
+ local _length = #_array
257
+ local _prefixLength = #prefix
258
+ table.move(prefix, 1, _prefixLength, _length + 1, _array)
259
+ _length += _prefixLength
260
+ _array[_length + 1] = "[]"
261
+ return walk(_exp_1, _array)
262
+ end
263
+ if _exp == "tuple" then
264
+ for _, element in at.elements do
265
+ local _array = {}
266
+ local _length = #_array
267
+ local _prefixLength = #prefix
268
+ table.move(prefix, 1, _prefixLength, _length + 1, _array)
269
+ _length += _prefixLength
270
+ _array[_length + 1] = "[]"
271
+ walk(element, _array)
272
+ end
273
+ return nil
274
+ end
275
+ if _exp == "map" then
276
+ local _exp_1 = at.value
277
+ local _array = {}
278
+ local _length = #_array
279
+ local _prefixLength = #prefix
280
+ table.move(prefix, 1, _prefixLength, _length + 1, _array)
281
+ _length += _prefixLength
282
+ _array[_length + 1] = "*"
283
+ return walk(_exp_1, _array)
284
+ end
285
+ if _exp == "union" then
286
+ for _, branch in at.branches do
287
+ walk(branch, prefix)
288
+ end
289
+ return nil
290
+ end
291
+ if _exp == "variant" then
292
+ local _array = {}
293
+ local _length = #_array
294
+ local _prefixLength = #prefix
295
+ table.move(prefix, 1, _prefixLength, _length + 1, _array)
296
+ _length += _prefixLength
297
+ _array[_length + 1] = escape(at.key)
298
+ add(_array)
299
+ return walk(at.body, prefix)
300
+ end
301
+ until true
302
+ end
303
+ walk(node, {})
304
+ local paths = {}
305
+ for _, path in found do
306
+ local _arg0 = table.freeze(path)
307
+ table.insert(paths, _arg0)
308
+ end
309
+ table.sort(paths, pathLess)
310
+ return table.freeze(paths)
311
+ end
312
+ return {
313
+ luaKey = luaKey,
314
+ getPath = getPath,
315
+ setPath = setPath,
316
+ describePath = describePath,
317
+ tableBranch = tableBranch,
318
+ childNode = childNode,
319
+ pathLess = pathLess,
320
+ samePath = samePath,
321
+ showPath = showPath,
322
+ fieldPaths = fieldPaths,
323
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,290 @@
1
+ -- Compiled with roblox-ts v3.0.0
2
+ --* @internal A stored value with the platform data UpdateAsync clears unless the transform returns it (rule 41).
3
+ --* @internal `retryable`: throttle or transient. `ambiguous`: the write may have committed.
4
+ --* @internal Transforms may run several times and never yield; returning undefined cancels.
5
+ --[[
6
+ *
7
+ * @internal
8
+ * Everything data asks of the engine (rule 105). It has no monotonic clock: data reads `bootClock()`, the clock core's
9
+ * shutdown sweep uses (rule 25). `wall` is for leases and id times only.
10
+
11
+ ]]
12
+ local port
13
+ --* @internal
14
+ local function installDataPort(value)
15
+ local _arg0 = port == nil
16
+ assert(_arg0, "Data port already selected")
17
+ port = value
18
+ end
19
+ --* @internal
20
+ local createRobloxDataPort
21
+ local function dataPort()
22
+ if port == nil then
23
+ port = createRobloxDataPort()
24
+ end
25
+ return port
26
+ end
27
+ --* @internal 301 to 306 are throttles that sent nothing; 5xx and codeless errors may have committed.
28
+ local function classify(message)
29
+ local digits = string.match(tostring(message), "^(%d+):")
30
+ local code = if digits == nil then 0 else tonumber(digits)
31
+ if code >= 301 and code <= 306 then
32
+ return {
33
+ kind = "error",
34
+ code = code,
35
+ retryable = true,
36
+ ambiguous = false,
37
+ }
38
+ end
39
+ if code == 0 or (code >= 500 and code <= 599) then
40
+ return {
41
+ kind = "error",
42
+ code = code,
43
+ retryable = true,
44
+ ambiguous = true,
45
+ }
46
+ end
47
+ return {
48
+ kind = "error",
49
+ code = code,
50
+ retryable = false,
51
+ ambiguous = false,
52
+ }
53
+ end
54
+ local function liveBacking()
55
+ local service = game:GetService("DataStoreService")
56
+ return {
57
+ update = function(store, key, transform)
58
+ local ok, result = pcall(function()
59
+ local value = service:GetDataStore(store):UpdateAsync(key, function(value, info)
60
+ local _fn = transform
61
+ local _result
62
+ if value == nil and info == nil then
63
+ _result = nil
64
+ else
65
+ local _object = {
66
+ value = value,
67
+ }
68
+ local _left = "userIds"
69
+ local _result_1 = info
70
+ if _result_1 ~= nil then
71
+ _result_1 = _result_1:GetUserIds()
72
+ end
73
+ local _condition = _result_1
74
+ if _condition == nil then
75
+ _condition = {}
76
+ end
77
+ _object[_left] = _condition
78
+ local _left_1 = "metadata"
79
+ local _result_2 = info
80
+ if _result_2 ~= nil then
81
+ _result_2 = _result_2:GetMetadata()
82
+ end
83
+ local _condition_1 = _result_2
84
+ if _condition_1 == nil then
85
+ _condition_1 = {}
86
+ end
87
+ _object[_left_1] = _condition_1
88
+ _result = _object
89
+ end
90
+ local written = _fn(_result)
91
+ if written == nil then
92
+ return nil
93
+ end
94
+ return written.value, written.userIds, written.metadata
95
+ end)
96
+ return value
97
+ end)
98
+ if not ok then
99
+ return classify(result)
100
+ end
101
+ return {
102
+ kind = "ok",
103
+ value = if result == nil then nil else {
104
+ value = result,
105
+ userIds = {},
106
+ metadata = {},
107
+ },
108
+ }
109
+ end,
110
+ read = function(store, key)
111
+ local ok, value, info = pcall(function()
112
+ return service:GetDataStore(store):GetAsync(key)
113
+ end)
114
+ if not ok then
115
+ return classify(value)
116
+ end
117
+ if value == nil then
118
+ return {
119
+ kind = "ok",
120
+ value = nil,
121
+ }
122
+ end
123
+ local keyInfo = info
124
+ local _object = {
125
+ kind = "ok",
126
+ }
127
+ local _left = "value"
128
+ local _object_1 = {
129
+ value = value,
130
+ }
131
+ local _left_1 = "userIds"
132
+ local _result = keyInfo
133
+ if _result ~= nil then
134
+ _result = _result:GetUserIds()
135
+ end
136
+ local _condition = _result
137
+ if _condition == nil then
138
+ _condition = {}
139
+ end
140
+ _object_1[_left_1] = _condition
141
+ local _left_2 = "metadata"
142
+ local _result_1 = keyInfo
143
+ if _result_1 ~= nil then
144
+ _result_1 = _result_1:GetMetadata()
145
+ end
146
+ local _condition_1 = _result_1
147
+ if _condition_1 == nil then
148
+ _condition_1 = {}
149
+ end
150
+ _object_1[_left_2] = _condition_1
151
+ _object[_left] = _object_1
152
+ return _object
153
+ end,
154
+ budget = function(kind)
155
+ return service:GetRequestBudgetForRequestType(if kind == "update" then Enum.DataStoreRequestType.UpdateAsync else Enum.DataStoreRequestType.GetAsync)
156
+ end,
157
+ }
158
+ end
159
+ --* Studio's store: the same transforms over an in-process table, so Studio runs lease.ts (rule 106).
160
+ local function memoryBacking()
161
+ local stores = {}
162
+ local keys = function(store)
163
+ local _store = store
164
+ local found = stores[_store]
165
+ if found == nil then
166
+ found = {}
167
+ local _store_1 = store
168
+ local _found = found
169
+ stores[_store_1] = _found
170
+ end
171
+ return found
172
+ end
173
+ return {
174
+ update = function(store, key, transform)
175
+ local ok, result = pcall(function()
176
+ local _fn = transform
177
+ local _exp = keys(store)
178
+ local _key = key
179
+ local written = _fn(_exp[_key])
180
+ if written ~= nil then
181
+ local _exp_1 = keys(store)
182
+ local _key_1 = key
183
+ _exp_1[_key_1] = written
184
+ end
185
+ return written
186
+ end)
187
+ if not ok then
188
+ return {
189
+ kind = "error",
190
+ code = 0,
191
+ retryable = false,
192
+ ambiguous = false,
193
+ }
194
+ end
195
+ return {
196
+ kind = "ok",
197
+ value = result,
198
+ }
199
+ end,
200
+ read = function(store, key)
201
+ local _object = {
202
+ kind = "ok",
203
+ }
204
+ local _left = "value"
205
+ local _exp = keys(store)
206
+ local _key = key
207
+ _object[_left] = _exp[_key]
208
+ return _object
209
+ end,
210
+ budget = function()
211
+ return math.huge
212
+ end,
213
+ }
214
+ end
215
+ --* @internal
216
+ function createRobloxDataPort()
217
+ local runService = game:GetService("RunService")
218
+ local players = game:GetService("Players")
219
+ local http = game:GetService("HttpService")
220
+ local live = not runService:IsStudio() or game:GetService("ServerStorage"):GetAttribute("CrucibleLiveData") == true
221
+ local backing = if live then liveBacking() else memoryBacking()
222
+ local random = Random.new()
223
+ local _object = table.clone(backing)
224
+ setmetatable(_object, nil)
225
+ _object.wall = function()
226
+ return DateTime.now().UnixTimestampMillis / 1000
227
+ end
228
+ _object.serverId = http:GenerateGUID(false)
229
+ _object.jobId = game.JobId
230
+ _object.guid = function()
231
+ return http:GenerateGUID(false)
232
+ end
233
+ _object.random = function()
234
+ return random:NextNumber()
235
+ end
236
+ _object.spawn = function(work)
237
+ task.spawn(work)
238
+ end
239
+ _object.delay = function(seconds, work)
240
+ return task.delay(seconds, work)
241
+ end
242
+ _object.cancel = function(thread)
243
+ return task.cancel(thread)
244
+ end
245
+ _object.resume = function(thread)
246
+ task.spawn(thread)
247
+ end
248
+ _object.wait = function(seconds)
249
+ task.wait(seconds)
250
+ end
251
+ _object.players = {
252
+ count = function()
253
+ return #players:GetPlayers()
254
+ end,
255
+ present = function(player)
256
+ return player.Parent == players
257
+ end,
258
+ byUserId = function(userId)
259
+ return players:GetPlayerByUserId(userId)
260
+ end,
261
+ kick = function(player, message)
262
+ return player:Kick(message)
263
+ end,
264
+ all = function()
265
+ return players:GetPlayers()
266
+ end,
267
+ onAdded = function(listener)
268
+ local connection = players.PlayerAdded:Connect(listener)
269
+ return function()
270
+ return connection:Disconnect()
271
+ end
272
+ end,
273
+ onRemoving = function(listener)
274
+ local connection = players.PlayerRemoving:Connect(listener)
275
+ return function()
276
+ return connection:Disconnect()
277
+ end
278
+ end,
279
+ }
280
+ _object.marketplace = function()
281
+ return game:GetService("MarketplaceService")
282
+ end
283
+ return _object
284
+ end
285
+ return {
286
+ installDataPort = installDataPort,
287
+ dataPort = dataPort,
288
+ classify = classify,
289
+ createRobloxDataPort = createRobloxDataPort,
290
+ }
@@ -0,0 +1 @@
1
+ export {};