@spearwolf/shadow-objects 0.33.0 → 0.35.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 (312) hide show
  1. package/CHANGELOG.md +350 -61
  2. package/README.md +66 -13
  3. package/bundle.js +6 -53
  4. package/package.json +15 -3
  5. package/src/ChangeTrailRefusedError.d.ts +27 -0
  6. package/src/ChangeTrailRefusedError.d.ts.map +1 -0
  7. package/src/ChangeTrailRefusedError.js +12 -0
  8. package/src/ChangeTrailRefusedError.js.map +7 -0
  9. package/src/EntityUuidInUseError.d.ts +19 -0
  10. package/src/EntityUuidInUseError.d.ts.map +1 -0
  11. package/src/EntityUuidInUseError.js +11 -0
  12. package/src/EntityUuidInUseError.js.map +7 -0
  13. package/src/WorkerTimeoutError.d.ts +26 -0
  14. package/src/WorkerTimeoutError.d.ts.map +1 -0
  15. package/src/WorkerTimeoutError.js +12 -0
  16. package/src/WorkerTimeoutError.js.map +7 -0
  17. package/src/bundle.d.ts +1 -1
  18. package/src/bundle.d.ts.map +1 -1
  19. package/src/bundle.js +1 -1
  20. package/src/bundle.js.map +2 -2
  21. package/src/constants.d.ts +13 -2
  22. package/src/constants.d.ts.map +1 -1
  23. package/src/constants.js +7 -1
  24. package/src/constants.js.map +2 -2
  25. package/src/create-worker.bundle.d.ts +1 -1
  26. package/src/create-worker.bundle.d.ts.map +1 -1
  27. package/src/create-worker.bundle.js.map +1 -1
  28. package/src/create-worker.d.ts +1 -1
  29. package/src/create-worker.d.ts.map +1 -1
  30. package/src/create-worker.js.map +1 -1
  31. package/src/elements/ShaeElement.d.ts +70 -2
  32. package/src/elements/ShaeElement.d.ts.map +1 -1
  33. package/src/elements/ShaeElement.js +129 -25
  34. package/src/elements/ShaeElement.js.map +3 -3
  35. package/src/elements/ShaeEntElement.d.ts +39 -1
  36. package/src/elements/ShaeEntElement.d.ts.map +1 -1
  37. package/src/elements/ShaeEntElement.js +397 -167
  38. package/src/elements/ShaeEntElement.js.map +2 -2
  39. package/src/elements/ShaeLifecycleElement.d.ts +71 -0
  40. package/src/elements/ShaeLifecycleElement.d.ts.map +1 -0
  41. package/src/elements/ShaeLifecycleElement.js +83 -0
  42. package/src/elements/ShaeLifecycleElement.js.map +7 -0
  43. package/src/elements/ShaePropElement.d.ts +61 -2
  44. package/src/elements/ShaePropElement.d.ts.map +1 -1
  45. package/src/elements/ShaePropElement.js +264 -219
  46. package/src/elements/ShaePropElement.js.map +2 -2
  47. package/src/elements/ShaeWorkerElement.d.ts +59 -5
  48. package/src/elements/ShaeWorkerElement.d.ts.map +1 -1
  49. package/src/elements/ShaeWorkerElement.js +271 -73
  50. package/src/elements/ShaeWorkerElement.js.map +2 -2
  51. package/src/elements/constants.d.ts +9 -0
  52. package/src/elements/constants.d.ts.map +1 -1
  53. package/src/elements/constants.js +18 -0
  54. package/src/elements/constants.js.map +2 -2
  55. package/src/elements/deferredTeardown.d.ts +24 -0
  56. package/src/elements/deferredTeardown.d.ts.map +1 -0
  57. package/src/elements/deferredTeardown.js +30 -0
  58. package/src/elements/deferredTeardown.js.map +7 -0
  59. package/src/elements/displayContentsRule.d.ts +25 -0
  60. package/src/elements/displayContentsRule.d.ts.map +1 -0
  61. package/src/elements/displayContentsRule.js +37 -0
  62. package/src/elements/displayContentsRule.js.map +7 -0
  63. package/src/elements/events.d.ts +10 -7
  64. package/src/elements/events.d.ts.map +1 -1
  65. package/src/elements/forwardCustomEvents.d.ts +19 -0
  66. package/src/elements/forwardCustomEvents.d.ts.map +1 -0
  67. package/src/elements/forwardCustomEvents.js +47 -0
  68. package/src/elements/forwardCustomEvents.js.map +7 -0
  69. package/src/elements/hostedSlots.d.ts +36 -0
  70. package/src/elements/hostedSlots.d.ts.map +1 -0
  71. package/src/elements/hostedSlots.js +118 -0
  72. package/src/elements/hostedSlots.js.map +7 -0
  73. package/src/elements/parentRemoval.d.ts +18 -0
  74. package/src/elements/parentRemoval.d.ts.map +1 -0
  75. package/src/elements/parentRemoval.js +60 -0
  76. package/src/elements/parentRemoval.js.map +7 -0
  77. package/src/elements/propValueConverters.d.ts +3 -0
  78. package/src/elements/propValueConverters.d.ts.map +1 -0
  79. package/src/elements/propValueConverters.js +54 -0
  80. package/src/elements/propValueConverters.js.map +7 -0
  81. package/src/elements/requestEntAncestor.d.ts +32 -0
  82. package/src/elements/requestEntAncestor.d.ts.map +1 -0
  83. package/src/elements/requestEntAncestor.js +16 -0
  84. package/src/elements/requestEntAncestor.js.map +7 -0
  85. package/src/elements.js.map +1 -1
  86. package/src/in-the-dark/Entity.d.ts +143 -3
  87. package/src/in-the-dark/Entity.d.ts.map +1 -1
  88. package/src/in-the-dark/Entity.js +330 -63
  89. package/src/in-the-dark/Entity.js.map +3 -3
  90. package/src/in-the-dark/Kernel.d.ts +98 -16
  91. package/src/in-the-dark/Kernel.d.ts.map +1 -1
  92. package/src/in-the-dark/Kernel.js +466 -379
  93. package/src/in-the-dark/Kernel.js.map +3 -3
  94. package/src/in-the-dark/Registry.d.ts +7 -1
  95. package/src/in-the-dark/Registry.d.ts.map +1 -1
  96. package/src/in-the-dark/Registry.js +112 -14
  97. package/src/in-the-dark/Registry.js.map +2 -2
  98. package/src/in-the-dark/ShadowObject.d.ts.map +1 -1
  99. package/src/in-the-dark/ShadowObject.js +1 -0
  100. package/src/in-the-dark/ShadowObject.js.map +2 -2
  101. package/src/in-the-dark/ShadowObjectCreationScope.d.ts +133 -0
  102. package/src/in-the-dark/ShadowObjectCreationScope.d.ts.map +1 -0
  103. package/src/in-the-dark/ShadowObjectCreationScope.js +603 -0
  104. package/src/in-the-dark/ShadowObjectCreationScope.js.map +7 -0
  105. package/src/in-the-dark/SignalsPath.d.ts +2 -0
  106. package/src/in-the-dark/SignalsPath.d.ts.map +1 -1
  107. package/src/in-the-dark/SignalsPath.js +6 -2
  108. package/src/in-the-dark/SignalsPath.js.map +2 -2
  109. package/src/in-the-dark/displayName.d.ts +4 -0
  110. package/src/in-the-dark/displayName.d.ts.map +1 -0
  111. package/src/in-the-dark/displayName.js +5 -0
  112. package/src/in-the-dark/displayName.js.map +7 -0
  113. package/src/in-the-dark/events.js.map +1 -1
  114. package/src/in-the-dark/importModule.d.ts +7 -0
  115. package/src/in-the-dark/importModule.d.ts.map +1 -1
  116. package/src/in-the-dark/importModule.js +5 -2
  117. package/src/in-the-dark/importModule.js.map +2 -2
  118. package/src/index.d.ts +9 -1
  119. package/src/index.d.ts.map +1 -1
  120. package/src/index.js +9 -1
  121. package/src/index.js.map +2 -2
  122. package/src/inspect/createKernelSnapshot.d.ts +17 -0
  123. package/src/inspect/createKernelSnapshot.d.ts.map +1 -0
  124. package/src/inspect/createKernelSnapshot.js +247 -0
  125. package/src/inspect/createKernelSnapshot.js.map +7 -0
  126. package/src/inspect/createViewSnapshot.d.ts +10 -0
  127. package/src/inspect/createViewSnapshot.d.ts.map +1 -0
  128. package/src/inspect/createViewSnapshot.js +143 -0
  129. package/src/inspect/createViewSnapshot.js.map +7 -0
  130. package/src/inspect/normalizeInspectRequest.d.ts +32 -0
  131. package/src/inspect/normalizeInspectRequest.d.ts.map +1 -0
  132. package/src/inspect/normalizeInspectRequest.js +55 -0
  133. package/src/inspect/normalizeInspectRequest.js.map +7 -0
  134. package/src/inspect/serializeValue.d.ts +13 -0
  135. package/src/inspect/serializeValue.d.ts.map +1 -0
  136. package/src/inspect/serializeValue.js +149 -0
  137. package/src/inspect/serializeValue.js.map +7 -0
  138. package/src/inspect/types.d.ts +260 -0
  139. package/src/inspect/types.d.ts.map +1 -0
  140. package/src/inspect/types.js +1 -0
  141. package/src/inspect/types.js.map +7 -0
  142. package/src/model-context/ModelContextLike.d.ts +59 -0
  143. package/src/model-context/ModelContextLike.d.ts.map +1 -0
  144. package/src/model-context/ModelContextLike.js +15 -0
  145. package/src/model-context/ModelContextLike.js.map +7 -0
  146. package/src/model-context/exposeShadowEnvsToModelContext.d.ts +48 -0
  147. package/src/model-context/exposeShadowEnvsToModelContext.d.ts.map +1 -0
  148. package/src/model-context/exposeShadowEnvsToModelContext.js +39 -0
  149. package/src/model-context/exposeShadowEnvsToModelContext.js.map +7 -0
  150. package/src/model-context/redactProps.d.ts +14 -0
  151. package/src/model-context/redactProps.d.ts.map +1 -0
  152. package/src/model-context/redactProps.js +22 -0
  153. package/src/model-context/redactProps.js.map +7 -0
  154. package/src/model-context/sharedExposure.d.ts +32 -0
  155. package/src/model-context/sharedExposure.d.ts.map +1 -0
  156. package/src/model-context/sharedExposure.js +108 -0
  157. package/src/model-context/sharedExposure.js.map +7 -0
  158. package/src/model-context/toolSupport.d.ts +72 -0
  159. package/src/model-context/toolSupport.d.ts.map +1 -0
  160. package/src/model-context/toolSupport.js +145 -0
  161. package/src/model-context/toolSupport.js.map +7 -0
  162. package/src/model-context/tools/findEntities.d.ts +15 -0
  163. package/src/model-context/tools/findEntities.d.ts.map +1 -0
  164. package/src/model-context/tools/findEntities.js +71 -0
  165. package/src/model-context/tools/findEntities.js.map +7 -0
  166. package/src/model-context/tools/getEntity.d.ts +16 -0
  167. package/src/model-context/tools/getEntity.d.ts.map +1 -0
  168. package/src/model-context/tools/getEntity.js +65 -0
  169. package/src/model-context/tools/getEntity.js.map +7 -0
  170. package/src/model-context/tools/getEntityTree.d.ts +4 -0
  171. package/src/model-context/tools/getEntityTree.d.ts.map +1 -0
  172. package/src/model-context/tools/getEntityTree.js +58 -0
  173. package/src/model-context/tools/getEntityTree.js.map +7 -0
  174. package/src/model-context/tools/getRegistry.d.ts +14 -0
  175. package/src/model-context/tools/getRegistry.d.ts.map +1 -0
  176. package/src/model-context/tools/getRegistry.js +39 -0
  177. package/src/model-context/tools/getRegistry.js.map +7 -0
  178. package/src/model-context/tools/index.d.ts +9 -0
  179. package/src/model-context/tools/index.d.ts.map +1 -0
  180. package/src/model-context/tools/index.js +16 -0
  181. package/src/model-context/tools/index.js.map +7 -0
  182. package/src/model-context/tools/listEnvs.d.ts +33 -0
  183. package/src/model-context/tools/listEnvs.d.ts.map +1 -0
  184. package/src/model-context/tools/listEnvs.js +37 -0
  185. package/src/model-context/tools/listEnvs.js.map +7 -0
  186. package/src/model-context.d.ts +13 -0
  187. package/src/model-context.d.ts.map +1 -0
  188. package/src/model-context.js +15 -0
  189. package/src/model-context.js.map +7 -0
  190. package/src/shadow-objects.d.ts +4 -0
  191. package/src/shadow-objects.d.ts.map +1 -1
  192. package/src/shadow-objects.js +6 -0
  193. package/src/shadow-objects.js.map +2 -2
  194. package/src/shadow-objects.worker.js +0 -1
  195. package/src/shadow-objects.worker.js.map +2 -2
  196. package/src/shae-ent.js.map +1 -1
  197. package/src/shae-prop.js +2 -2
  198. package/src/shae-prop.js.map +2 -2
  199. package/src/shae-worker.js.map +1 -1
  200. package/src/testing/TestEntity.d.ts +79 -0
  201. package/src/testing/TestEntity.d.ts.map +1 -0
  202. package/src/testing/TestEntity.js +135 -0
  203. package/src/testing/TestEntity.js.map +7 -0
  204. package/src/testing/createTestKernel.d.ts +11 -0
  205. package/src/testing/createTestKernel.d.ts.map +1 -0
  206. package/src/testing/createTestKernel.js +132 -0
  207. package/src/testing/createTestKernel.js.map +7 -0
  208. package/src/testing/mountShadowObject.d.ts +21 -0
  209. package/src/testing/mountShadowObject.d.ts.map +1 -0
  210. package/src/testing/mountShadowObject.js +72 -0
  211. package/src/testing/mountShadowObject.js.map +7 -0
  212. package/src/testing/recordKernelErrors.d.ts +21 -0
  213. package/src/testing/recordKernelErrors.d.ts.map +1 -0
  214. package/src/testing/recordKernelErrors.js +39 -0
  215. package/src/testing/recordKernelErrors.js.map +7 -0
  216. package/src/testing/settle.d.ts +15 -0
  217. package/src/testing/settle.d.ts.map +1 -0
  218. package/src/testing/settle.js +19 -0
  219. package/src/testing/settle.js.map +7 -0
  220. package/src/testing/types.d.ts +119 -0
  221. package/src/testing/types.d.ts.map +1 -0
  222. package/src/testing/types.js +1 -0
  223. package/src/testing/types.js.map +7 -0
  224. package/src/testing.d.ts +14 -0
  225. package/src/testing.d.ts.map +1 -0
  226. package/src/testing.js +11 -0
  227. package/src/testing.js.map +7 -0
  228. package/src/types.d.ts +185 -14
  229. package/src/types.d.ts.map +1 -1
  230. package/src/utils/ConsoleLogger.d.ts +45 -10
  231. package/src/utils/ConsoleLogger.d.ts.map +1 -1
  232. package/src/utils/ConsoleLogger.js +51 -26
  233. package/src/utils/ConsoleLogger.js.map +2 -2
  234. package/src/utils/FrameLoop.d.ts +42 -3
  235. package/src/utils/FrameLoop.d.ts.map +1 -1
  236. package/src/utils/FrameLoop.js +71 -10
  237. package/src/utils/FrameLoop.js.map +2 -2
  238. package/src/utils/MicrotaskCollector.d.ts +45 -0
  239. package/src/utils/MicrotaskCollector.d.ts.map +1 -0
  240. package/src/utils/MicrotaskCollector.js +33 -0
  241. package/src/utils/MicrotaskCollector.js.map +7 -0
  242. package/src/utils/MicrotaskGate.d.ts +17 -0
  243. package/src/utils/MicrotaskGate.d.ts.map +1 -0
  244. package/src/utils/MicrotaskGate.js +20 -0
  245. package/src/utils/MicrotaskGate.js.map +7 -0
  246. package/src/utils/array-utils.js.map +1 -1
  247. package/src/utils/attr-utils.d.ts +11 -0
  248. package/src/utils/attr-utils.d.ts.map +1 -1
  249. package/src/utils/attr-utils.js +5 -1
  250. package/src/utils/attr-utils.js.map +2 -2
  251. package/src/utils/constants.js.map +1 -1
  252. package/src/utils/generateUUID.d.ts +11 -0
  253. package/src/utils/generateUUID.d.ts.map +1 -1
  254. package/src/utils/generateUUID.js +31 -266
  255. package/src/utils/generateUUID.js.map +2 -2
  256. package/src/utils/props-utils.d.ts +3 -2
  257. package/src/utils/props-utils.d.ts.map +1 -1
  258. package/src/utils/props-utils.js +13 -24
  259. package/src/utils/props-utils.js.map +2 -2
  260. package/src/utils/runGuarded.d.ts +27 -0
  261. package/src/utils/runGuarded.d.ts.map +1 -0
  262. package/src/utils/runGuarded.js +11 -0
  263. package/src/utils/runGuarded.js.map +7 -0
  264. package/src/utils/toMaybe.d.ts.map +1 -1
  265. package/src/utils/toMaybe.js.map +1 -1
  266. package/src/utils/toNamespace.d.ts.map +1 -1
  267. package/src/utils/toNamespace.js.map +1 -1
  268. package/src/utils/toUrlString.d.ts +12 -0
  269. package/src/utils/toUrlString.d.ts.map +1 -1
  270. package/src/utils/toUrlString.js.map +2 -2
  271. package/src/utils/waitForMessageOfType.d.ts +12 -1
  272. package/src/utils/waitForMessageOfType.d.ts.map +1 -1
  273. package/src/utils/waitForMessageOfType.js +16 -1
  274. package/src/utils/waitForMessageOfType.js.map +2 -2
  275. package/src/view/ComponentChanges.d.ts +88 -1
  276. package/src/view/ComponentChanges.d.ts.map +1 -1
  277. package/src/view/ComponentChanges.js +243 -73
  278. package/src/view/ComponentChanges.js.map +2 -2
  279. package/src/view/ComponentContext.d.ts +206 -16
  280. package/src/view/ComponentContext.d.ts.map +1 -1
  281. package/src/view/ComponentContext.js +548 -91
  282. package/src/view/ComponentContext.js.map +2 -2
  283. package/src/view/ComponentMemory.d.ts +3 -3
  284. package/src/view/ComponentMemory.d.ts.map +1 -1
  285. package/src/view/ComponentMemory.js.map +1 -1
  286. package/src/view/IShadowObjectEnvProxy.d.ts +38 -3
  287. package/src/view/IShadowObjectEnvProxy.d.ts.map +1 -1
  288. package/src/view/LocalShadowObjectEnv.d.ts +8 -1
  289. package/src/view/LocalShadowObjectEnv.d.ts.map +1 -1
  290. package/src/view/LocalShadowObjectEnv.js +23 -7
  291. package/src/view/LocalShadowObjectEnv.js.map +2 -2
  292. package/src/view/RemoteWorkerEnv.d.ts +108 -5
  293. package/src/view/RemoteWorkerEnv.d.ts.map +1 -1
  294. package/src/view/RemoteWorkerEnv.js +244 -77
  295. package/src/view/RemoteWorkerEnv.js.map +2 -2
  296. package/src/view/ShadowEnv.d.ts +79 -2
  297. package/src/view/ShadowEnv.d.ts.map +1 -1
  298. package/src/view/ShadowEnv.js +323 -59
  299. package/src/view/ShadowEnv.js.map +3 -3
  300. package/src/view/ViewComponent.d.ts +78 -14
  301. package/src/view/ViewComponent.d.ts.map +1 -1
  302. package/src/view/ViewComponent.js +90 -14
  303. package/src/view/ViewComponent.js.map +2 -2
  304. package/src/view/cloneChangeTrail.js.map +2 -2
  305. package/src/worker/MessageRouter.d.ts +14 -0
  306. package/src/worker/MessageRouter.d.ts.map +1 -1
  307. package/src/worker/MessageRouter.js +98 -15
  308. package/src/worker/MessageRouter.js.map +2 -2
  309. package/src/worker/WorkerRuntime.d.ts +22 -1
  310. package/src/worker/WorkerRuntime.d.ts.map +1 -1
  311. package/src/worker/WorkerRuntime.js +60 -8
  312. package/src/worker/WorkerRuntime.js.map +2 -2
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/view/RemoteWorkerEnv.ts"],
4
- "sourcesContent": ["import {emit, once, retain} from '@spearwolf/eventize';\nimport {\n AppliedChangeTrail,\n ChangeTrail,\n Configure,\n Destroy,\n Destroyed,\n ImportedModule,\n Loaded,\n MessageToView,\n WorkerChangeTrailTimeout,\n WorkerConfigureTimeout,\n WorkerDestroyTimeout,\n WorkerLoadTimeout,\n} from '../constants.js';\nimport createWorker from '../create-worker.js';\nimport type {AppliedChangeTrailEvent, ChangeTrailType, ImportedModuleEvent, TransferablesType} from '../types.js';\nimport {CONSOLE_LOGGER, ConsoleLogger} from '../utils/ConsoleLogger.js';\nimport {toUrlString} from '../utils/toUrlString.js';\nimport {waitForMessageOfType} from '../utils/waitForMessageOfType.js';\nimport type {IShadowObjectEnvProxy} from './IShadowObjectEnvProxy.js';\n\nconst removeTransferables = (changeTrail: ChangeTrailType): TransferablesType | undefined => {\n let transferables: TransferablesType | undefined;\n\n if (changeTrail != null && Array.isArray(changeTrail)) {\n for (const changeItem of changeTrail) {\n if (changeItem.transferables) {\n if (!transferables) {\n transferables = changeItem.transferables;\n } else {\n transferables = [...transferables, ...changeItem.transferables];\n }\n delete changeItem.transferables;\n }\n }\n }\n\n return transferables;\n};\n\n/**\n * The reason every pending and every later worker request is rejected with\n * once the worker has failed.\n */\nexport class WorkerFailedError extends Error {\n /** `'error'` when the worker itself threw, `'messageerror'` when it sent something that could not be deserialized. */\n readonly type: 'error' | 'messageerror';\n\n constructor(type: 'error' | 'messageerror', message: string, options?: ErrorOptions) {\n super(message, options);\n this.name = 'WorkerFailedError';\n this.type = type;\n }\n}\n\n/**\n * The reason a request is rejected with once the environment has been torn down\n * with {@link RemoteWorkerEnv.destroy}. The worker is gone; no reply can arrive.\n */\nexport class WorkerDestroyedError extends Error {\n constructor(message = 'the worker environment has been destroyed') {\n super(message);\n this.name = 'WorkerDestroyedError';\n }\n}\n\n/** What {@link RemoteWorkerEnv.WorkerFailed} carries. */\nexport interface WorkerFailedEvent {\n /** the environment whose worker failed */\n env: RemoteWorkerEnv;\n /** what the worker reported */\n type: 'error' | 'messageerror';\n /** a readable description of the failure */\n message: string;\n /** the error every pending and every later request is rejected with */\n reason: WorkerFailedError;\n /** the worker event the failure was read from */\n event: ErrorEvent | MessageEvent;\n}\n\nexport class RemoteWorkerEnv implements IShadowObjectEnvProxy {\n static WorkerLoaded = 'workerLoaded';\n static WorkerFailed = 'workerFailed';\n\n #worker?: Worker;\n #isDestroyed = false;\n #changeTrailSerial = 0;\n\n /**\n * Aborted exactly once, with the {@link WorkerFailedError} that describes the failure.\n * It settles every request already waiting for a reply and turns away every later one.\n */\n readonly #workerFailure = new AbortController();\n\n readonly logger = new ConsoleLogger('RemoteWorkerEnv');\n\n get isDestroyed(): boolean {\n return this.#isDestroyed;\n }\n\n /**\n * Resolves once the worker is up.\n *\n * Every read hands out a promise that can reject, so a caller that only wants to\n * kick the environment off and never awaits the result should still attach a\n * `catch()` \u2014 otherwise a worker failure surfaces as an unhandled rejection.\n *\n * @throws {WorkerFailedError} if the worker fails before or after that happens\n */\n get workerLoaded(): Promise<RemoteWorkerEnv> {\n const {signal} = this.#workerFailure;\n if (signal.aborted) return Promise.reject(signal.reason);\n\n return new Promise<RemoteWorkerEnv>((resolve, reject) => {\n let unsubscribeLoaded: (() => void) | undefined;\n let settled = false;\n\n const onFailure = () => {\n if (settled) return;\n settled = true;\n unsubscribeLoaded?.();\n reject(signal.reason);\n };\n\n unsubscribeLoaded = once(this as RemoteWorkerEnv, RemoteWorkerEnv.WorkerLoaded, (env: RemoteWorkerEnv) => {\n if (settled) return;\n settled = true;\n signal.removeEventListener('abort', onFailure);\n resolve(env);\n });\n\n // a retained WorkerLoaded is replayed inside once(), before it returns \u2014\n // then there is nothing left to wait for and no abort listener to attach\n if (settled) return;\n\n signal.addEventListener('abort', onFailure, {once: true});\n });\n }\n\n constructor() {\n retain(this as RemoteWorkerEnv, RemoteWorkerEnv.WorkerLoaded);\n // a consumer that subscribes only after the failure still gets to hear about it\n retain(this as RemoteWorkerEnv, RemoteWorkerEnv.WorkerFailed);\n }\n\n async start(): Promise<void> {\n // both guards are needed, and in this order: a failure aborts the signal *and* marks the\n // environment destroyed, so asking about the teardown first would bury the more precise\n // reason \u2014 while a teardown leaves the signal untouched and would slip past it\n const {signal} = this.#workerFailure;\n if (signal.aborted) throw signal.reason;\n\n // a torn-down environment must not spawn a worker: nothing would ever reach it, and\n // nothing would ever shut it down again\n if (this.#isDestroyed) throw new WorkerDestroyedError();\n\n if (this.#worker) {\n if (this.logger.isWarn) {\n this.logger.warn('already started');\n }\n\n return this.workerLoaded.then((): void => {\n if (this.isDestroyed) {\n throw new WorkerDestroyedError();\n }\n });\n }\n\n const worker = (this.#worker = createWorker());\n\n // registered before the load handshake begins: a worker that dies while it is\n // still coming up must not leave the caller waiting for the load timeout\n worker.addEventListener('error', this.onWorkerError.bind(this));\n worker.addEventListener('messageerror', this.onWorkerMessageError.bind(this));\n\n this.configureConsoleLogger(worker);\n\n try {\n await waitForMessageOfType(worker, Loaded, WorkerLoadTimeout, undefined, signal);\n\n if (this.isDestroyed) {\n throw new WorkerDestroyedError();\n }\n\n worker.addEventListener('message', this.onMessageFromWorker.bind(this));\n\n queueMicrotask(() => {\n emit(this as RemoteWorkerEnv, RemoteWorkerEnv.WorkerLoaded, this);\n });\n } catch (error) {\n // the failure path reports with the worker event in hand; anything else is on us\n if (error !== signal.reason) {\n this.logger.error('failed to start', error);\n }\n\n this.#worker = undefined;\n\n // only a start that nobody else is unwinding owns this worker: the reference is gone,\n // nobody can reach it any more, and leaving it running would keep a thread open for an\n // environment that never started. A failure has already terminated it, and a teardown\n // in flight is waiting for its Destroyed reply \u2014 cutting that short here would leave\n // destroy() to sit out its timeout and skip the worker-side teardown entirely.\n if (!this.#isDestroyed) {\n worker.terminate();\n }\n\n throw error;\n }\n }\n\n applyChangeTrail(changeTrail: ChangeTrailType, waitForConfirmation: boolean): Promise<void> {\n const {signal} = this.#workerFailure;\n if (signal.aborted) return Promise.reject(signal.reason);\n\n const worker = this.#worker;\n if (worker == null) return Promise.reject(new WorkerDestroyedError());\n\n const transferables = removeTransferables(changeTrail);\n const message = {type: ChangeTrail, changeTrail} as any;\n\n const serial = ++this.#changeTrailSerial;\n if (waitForConfirmation) {\n message.serial = serial;\n }\n\n worker.postMessage(message, transferables ?? []);\n\n if (waitForConfirmation) {\n return waitForMessageOfType(\n worker,\n AppliedChangeTrail,\n WorkerChangeTrailTimeout,\n (data: AppliedChangeTrailEvent) => {\n if (data.error) throw data.error;\n return data.serial === serial;\n },\n signal,\n );\n } else {\n return Promise.resolve();\n }\n }\n\n importScript(url: URL | string): Promise<void> {\n const {signal} = this.#workerFailure;\n if (signal.aborted) return Promise.reject(signal.reason);\n\n const worker = this.#worker;\n if (worker == null) return Promise.reject(new WorkerDestroyedError());\n\n url = toUrlString(url);\n worker.postMessage({type: Configure, importModule: url});\n return waitForMessageOfType(\n worker,\n ImportedModule,\n WorkerConfigureTimeout,\n (data: ImportedModuleEvent) => {\n if (data.error) throw data.error;\n return data.url === url;\n },\n signal,\n );\n }\n\n destroy(): void {\n if (!this.#worker) return;\n\n const worker = this.#worker;\n this.#worker = undefined;\n\n this.#isDestroyed = true;\n\n worker.postMessage({type: Destroy});\n\n waitForMessageOfType(worker, Destroyed, WorkerDestroyTimeout).finally(() => {\n worker.terminate();\n });\n }\n\n private onWorkerError(event: ErrorEvent) {\n this.handleWorkerFailure('error', event, event.message || 'the worker reported an error');\n }\n\n private onWorkerMessageError(event: MessageEvent) {\n this.handleWorkerFailure('messageerror', event, 'the worker sent a message that could not be deserialized');\n }\n\n private handleWorkerFailure(type: 'error' | 'messageerror', event: ErrorEvent | MessageEvent, message: string): void {\n // a deliberate teardown, or a failure that was already reported: the first one wins\n if (this.#isDestroyed) return;\n\n this.#isDestroyed = true;\n\n const reason = new WorkerFailedError(type, message, {\n cause: type === 'error' ? ((event as ErrorEvent).error ?? event) : event,\n });\n\n this.logger.error(message, event);\n\n const worker = this.#worker;\n this.#worker = undefined;\n\n // settle everyone waiting for a reply before the worker goes away \u2014 it can no longer arrive\n this.#workerFailure.abort(reason);\n\n worker?.terminate();\n\n // the ShadowEnv is told first, so that the state it derives from this is already\n // settled when consumers hear about it. Whatever happens down that path stays\n // there \u2014 the public event is announced either way\n try {\n (this as IShadowObjectEnvProxy).onProxyFailed?.(reason);\n } catch (error) {\n this.logger.error('the proxy-failed callback threw', error);\n }\n\n emit(this as RemoteWorkerEnv, RemoteWorkerEnv.WorkerFailed, {\n env: this,\n type,\n message,\n reason,\n event,\n } as WorkerFailedEvent);\n }\n\n private onMessageFromWorker(event: MessageEvent) {\n if (event.data?.type === MessageToView) {\n (this as IShadowObjectEnvProxy).onMessageToView?.(event.data.data);\n } else if (this.logger.isDebug) {\n this.logger.debug('message from worker', event);\n }\n }\n\n private configureConsoleLogger(worker: Worker) {\n const workerConfigKey = `${CONSOLE_LOGGER}.RemoteWorkerEnv.workerConfig`;\n const workerConfig = JSON.parse(localStorage.getItem(workerConfigKey) ?? '{}');\n\n if (this.logger.isInfo) {\n this.logger.info('load console-logger worker config', {localStorageKey: workerConfigKey, workerConfig});\n }\n\n worker.postMessage({\n type: CONSOLE_LOGGER,\n config: {\n ...ConsoleLogger.sharedConfig,\n enable: this.logger.isEnabled,\n ...workerConfig,\n ...(ConsoleLogger.isEnabled ? {} : {enable: false}),\n },\n });\n }\n}"],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,OAAO;AACd,WAAK,OAAO,MAAM,mCAAmC,KAAK;AAAA,IAC5D;AAEA,SAAK,MAAyB,gBAAgB,cAAc;AAAA,MAC1D,KAAK;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAsB;AAAA,EACxB;AAAA,EAEQ,oBAAoB,OAAqB;AAC/C,QAAI,MAAM,MAAM,SAAS,eAAe;AACtC,MAAC,KAA+B,kBAAkB,MAAM,KAAK,IAAI;AAAA,IACnE,WAAW,KAAK,OAAO,SAAS;AAC9B,WAAK,OAAO,MAAM,uBAAuB,KAAK;AAAA,IAChD;AAAA,EACF;AAAA,EAEQ,uBAAuB,QAAgB;AAC7C,UAAM,kBAAkB,GAAG,cAAc;AACzC,UAAM,eAAe,KAAK,MAAM,aAAa,QAAQ,eAAe,KAAK,IAAI;AAE7E,QAAI,KAAK,OAAO,QAAQ;AACtB,WAAK,OAAO,KAAK,qCAAqC,EAAC,iBAAiB,iBAAiB,aAAY,CAAC;AAAA,IACxG;AAEA,WAAO,YAAY;AAAA,MACjB,MAAM;AAAA,MACN,QAAQ;AAAA,QACN,GAAG,cAAc;AAAA,QACjB,QAAQ,KAAK,OAAO;AAAA,QACpB,GAAG;AAAA,QACH,GAAI,cAAc,YAAY,CAAC,IAAI,EAAC,QAAQ,MAAK;AAAA,MACnD;AAAA,IACF,CAAC;AAAA,EACH;AACF;",
4
+ "sourcesContent": ["import {emitStrict, once, retain} from '@spearwolf/eventize';\nimport {ChangeTrailRefusedError} from '../ChangeTrailRefusedError.js';\nimport {\n AppliedChangeTrail,\n ChangeTrail,\n Configure,\n Destroy,\n Destroyed,\n ImportedModule,\n Inspect,\n Inspected,\n Loaded,\n MessageToView,\n WorkerChangeTrailTimeout,\n WorkerConfigureTimeout,\n WorkerDestroyTimeout,\n WorkerInspectTimeout,\n WorkerLoadTimeout,\n} from '../constants.js';\nimport createWorker from '../create-worker.js';\nimport type {InspectRequest, KernelSnapshot} from '../inspect/types.js';\nimport type {\n AppliedChangeTrailEvent,\n ChangeTrailType,\n ImportedModuleEvent,\n InspectEvent,\n InspectedEvent,\n SyncEvent,\n TransferablesType,\n} from '../types.js';\nimport {CONSOLE_LOGGER, ConsoleLogger, consoleLoggerConfigKey, loadConsoleLoggerConfig} from '../utils/ConsoleLogger.js';\nimport {toUrlString} from '../utils/toUrlString.js';\nimport {isTimeout, MaxWorkerTimeout, waitForMessageOfType} from '../utils/waitForMessageOfType.js';\nimport type {IShadowObjectEnvProxy} from './IShadowObjectEnvProxy.js';\n\n/**\n * Splits the transferables out of a change trail without writing to it. The trail handed in is a\n * snapshot that travels on after this call -- to the `ShadowEnv.AfterSync` consumers when the\n * environment applies it, to the `ShadowEnv.SyncFailed` consumers when it refuses it -- so an\n * entry carrying transferables is replaced by a shallow copy without them and every other\n * entry is passed through as it is. A trail that carries none is handed back object for\n * object.\n */\nconst splitTransferables = (\n changeTrail: ChangeTrailType,\n): {changeTrail: ChangeTrailType; transferables?: TransferablesType | undefined} => {\n if (!Array.isArray(changeTrail)) return {changeTrail};\n\n let outbound: ChangeTrailType | undefined;\n let transferables: TransferablesType | undefined;\n\n for (let i = 0; i < changeTrail.length; i++) {\n const changeItem = changeTrail[i];\n if (changeItem?.transferables) {\n transferables = transferables ? [...transferables, ...changeItem.transferables] : [...changeItem.transferables];\n\n outbound ??= [...changeTrail];\n const withoutTransferables = {...changeItem};\n delete withoutTransferables.transferables;\n outbound[i] = withoutTransferables;\n }\n }\n\n return {changeTrail: outbound ?? changeTrail, transferables};\n};\n\n/**\n * What actually goes on the wire for a `ChangeTrail` message. `SyncEvent` describes the shape a\n * change trail carries once it is inside the worker, without the `type` discriminant that gets\n * it there \u2014 its two neighbors on the wire (`ImportedModuleEvent`, `AppliedChangeTrailEvent`)\n * both require that field, so adding it to `SyncEvent` itself would either make it mandatory\n * where `LocalShadowObjectEnv` never sets it, or optional on a public type whose neighbors need\n * it required. Kept local instead: it says exactly what this message is without touching the\n * exported type surface.\n */\ninterface ChangeTrailMessage extends SyncEvent {\n type: typeof ChangeTrail;\n}\n\n/**\n * The reason every pending and every later worker request is rejected with\n * once the worker has failed.\n */\nexport class WorkerFailedError extends Error {\n /** `'error'` when the worker itself threw, `'messageerror'` when it sent something that could not be deserialized. */\n readonly type: 'error' | 'messageerror';\n\n constructor(type: 'error' | 'messageerror', message: string, options?: ErrorOptions) {\n super(message, options);\n this.name = 'WorkerFailedError';\n this.type = type;\n }\n}\n\n/**\n * The reason a request is rejected with once the environment has been torn down\n * with {@link RemoteWorkerEnv.destroy}. The worker is gone; no reply can arrive.\n */\nexport class WorkerDestroyedError extends Error {\n constructor(message = 'the worker environment has been destroyed') {\n super(message);\n this.name = 'WorkerDestroyedError';\n }\n}\n\n/**\n * The reason a request is rejected with when the worker reported a failure of its own -- a\n * module that would not import, a change trail its Kernel refused. An error does not survive\n * structured cloning as the object it is, so the two fields that do are rebuilt here, and\n * `name` is the name the error called itself inside the worker: a caller reads it the same\n * way it reads the name of an error a `LocalShadowObjectEnv` hands it. A name that is missing\n * or empty names no class, and `Error` is what such a reason is called -- the same name a\n * plain `new Error(message)` carries on the local side.\n *\n * What does not come across is the class and everything it added. `instanceof EntityUuidInUseError`\n * is `false` here and there is no `uuid` field, whatever `name` says; `instanceof WorkerReportedError`\n * is what tells such a reason apart from one raised on this side.\n */\nexport class WorkerReportedError extends Error {\n constructor(name: string | undefined, message: string) {\n super(message);\n this.name = name || 'Error';\n }\n}\n\n/**\n * How long a {@link RemoteWorkerEnv} waits for each of the five replies a worker owes it,\n * in milliseconds.\n */\nexport interface WorkerTimeouts {\n /** the `Loaded` handshake at the start */\n loadTimeout: number;\n /** the `ImportedModule` reply to an `importScript()` */\n configureTimeout: number;\n /** the `AppliedChangeTrail` confirmation of a change trail sent with `waitForConfirmation` */\n changeTrailTimeout: number;\n /** the `Inspected` answer to an `inspect()` */\n inspectTimeout: number;\n /** the `Destroyed` acknowledgement of a teardown */\n destroyTimeout: number;\n}\n\n/**\n * What {@link RemoteWorkerEnv} takes. Every value left out keeps its default \u2014 the five\n * `Worker*Timeout` constants. A value that is not a number of milliseconds from 1 to\n * 2147483647 \u2014 close to 25 days, the longest delay a timer keeps \u2014 is reported through the\n * logger and the default applies.\n */\nexport type RemoteWorkerEnvOptions = Partial<WorkerTimeouts>;\n\nconst DefaultWorkerTimeouts: WorkerTimeouts = {\n loadTimeout: WorkerLoadTimeout,\n configureTimeout: WorkerConfigureTimeout,\n changeTrailTimeout: WorkerChangeTrailTimeout,\n inspectTimeout: WorkerInspectTimeout,\n destroyTimeout: WorkerDestroyTimeout,\n};\n\n/**\n * Resolves the options against the defaults. A timeout is a number of milliseconds from 1 to\n * {@link MaxWorkerTimeout}; anything else is refused and reported, and the default stays.\n *\n * Zero and Infinity are refused along with the rest, and that is the point of the rule rather\n * than an oversight: `waitForMessageOfType()` arms no timer for either of them, so a teardown\n * given one of the two would wait for an acknowledgement a dead worker never sends \u2014 and the\n * `terminate()` that ends the teardown hangs on that very chain. One rule for all five values\n * is easier to hold on to than four that allow it and one that does not, and {@link MaxWorkerTimeout}\n * \u2014 close to 25 days \u2014 is as long as a wait can honestly be made.\n */\nconst resolveTimeouts = (options: RemoteWorkerEnvOptions | undefined, logger: ConsoleLogger): WorkerTimeouts => {\n const resolved: WorkerTimeouts = {...DefaultWorkerTimeouts};\n if (options == null) return resolved;\n\n for (const key of Object.keys(DefaultWorkerTimeouts) as (keyof WorkerTimeouts)[]) {\n // own keys only: what an object inherits from its prototype is not what its author wrote down\n if (!Object.hasOwn(options, key)) continue;\n\n const value = options[key];\n if (value === undefined) continue;\n\n if (isTimeout(value)) {\n resolved[key] = value;\n } else {\n logger.error(`ignoring the ${key} option: expected a number of milliseconds from 1 to ${MaxWorkerTimeout}, got`, value);\n }\n }\n\n return resolved;\n};\n\n/** What {@link RemoteWorkerEnv.WorkerFailed} carries. */\nexport interface WorkerFailedEvent {\n /** the environment whose worker failed */\n env: RemoteWorkerEnv;\n /** what the worker reported */\n type: 'error' | 'messageerror';\n /** a readable description of the failure */\n message: string;\n /** the error every pending and every later request is rejected with */\n reason: WorkerFailedError;\n /** the worker event the failure was read from */\n event: ErrorEvent | MessageEvent;\n}\n\nexport class RemoteWorkerEnv implements IShadowObjectEnvProxy {\n static WorkerLoaded = 'workerLoaded';\n static WorkerFailed = 'workerFailed';\n\n #worker?: Worker | undefined;\n #isDestroyed = false;\n #changeTrailSerial = 0;\n #inspectSerial = 0;\n\n /**\n * Aborted exactly once, with the error that ends this environment: a {@link WorkerFailedError}\n * when the worker broke down, a {@link WorkerDestroyedError} when it was torn down. Whichever\n * comes first keeps the signal, so a teardown never buries the failure that provoked it.\n * It settles every request already waiting for a reply and turns away every later one.\n */\n readonly #workerFailure = new AbortController();\n\n readonly #logger = new ConsoleLogger('RemoteWorkerEnv');\n\n /** The logger this environment reports through. */\n get logger(): ConsoleLogger {\n return this.#logger;\n }\n\n readonly #timeouts: Readonly<WorkerTimeouts>;\n\n /**\n * The five timeouts this environment holds itself to, resolved once when it is built. The\n * object is frozen and the slot holds no setter, so the constructor is the one way in --\n * and `resolveTimeouts()` vets every value that goes through it.\n */\n get timeouts(): Readonly<WorkerTimeouts> {\n return this.#timeouts;\n }\n\n get isDestroyed(): boolean {\n return this.#isDestroyed;\n }\n\n /**\n * Resolves once the worker is up.\n *\n * Every read hands out a promise that can reject, so a caller that only wants to\n * kick the environment off and never awaits the result should still attach a\n * `catch()` \u2014 otherwise a worker failure surfaces as an unhandled rejection.\n *\n * @throws {WorkerFailedError} if the worker fails before or after that happens\n * @throws {WorkerDestroyedError} once the environment has been torn down \u2014 including every\n * read after a load that had already succeeded, because there is no environment left to hand out\n */\n get workerLoaded(): Promise<RemoteWorkerEnv> {\n const {signal} = this.#workerFailure;\n if (signal.aborted) return Promise.reject(signal.reason);\n\n return new Promise<RemoteWorkerEnv>((resolve, reject) => {\n let unsubscribeLoaded: (() => void) | undefined;\n let settled = false;\n\n const onFailure = () => {\n if (settled) return;\n settled = true;\n unsubscribeLoaded?.();\n reject(signal.reason);\n };\n\n unsubscribeLoaded = once(this as RemoteWorkerEnv, RemoteWorkerEnv.WorkerLoaded, (env: RemoteWorkerEnv) => {\n if (settled) return;\n settled = true;\n signal.removeEventListener('abort', onFailure);\n resolve(env);\n });\n\n // a retained WorkerLoaded is replayed inside once(), before it returns \u2014\n // then there is nothing left to wait for and no abort listener to attach\n if (settled) return;\n\n signal.addEventListener('abort', onFailure, {once: true});\n });\n }\n\n constructor(options?: RemoteWorkerEnvOptions) {\n // the logger is a field initializer and is therefore already in place\n this.#timeouts = Object.freeze(resolveTimeouts(options, this.logger));\n\n retain(this as RemoteWorkerEnv, RemoteWorkerEnv.WorkerLoaded);\n // a consumer that subscribes only after the failure still gets to hear about it\n retain(this as RemoteWorkerEnv, RemoteWorkerEnv.WorkerFailed);\n }\n\n async start(): Promise<void> {\n // both endings of this environment abort the signal, and it keeps the reason of whichever\n // came first. A finished environment must not spawn a worker: nothing would ever reach it,\n // and nothing would ever shut it down again\n const {signal} = this.#workerFailure;\n if (signal.aborted) throw signal.reason;\n\n if (this.#worker) {\n this.logger.warn('already started');\n\n return this.workerLoaded.then((): void => {\n if (this.isDestroyed) {\n throw new WorkerDestroyedError();\n }\n });\n }\n\n const worker = (this.#worker = createWorker());\n\n // registered before the load handshake begins: a worker that dies while it is\n // still coming up must not leave the caller waiting for the load timeout\n worker.addEventListener('error', this.onWorkerError);\n worker.addEventListener('messageerror', this.onWorkerMessageError);\n\n this.configureConsoleLogger(worker);\n\n try {\n await waitForMessageOfType(worker, Loaded, this.timeouts.loadTimeout, undefined, signal);\n\n // the handshake completed but the environment ended while its reply was on the way here.\n // The reason of that ending is what the caller gets \u2014 a fresh error of our own would read\n // as a start that went wrong, and the catch below would report it as one\n if (this.isDestroyed) {\n throw signal.aborted ? signal.reason : new WorkerDestroyedError();\n }\n\n worker.addEventListener('message', this.onMessageFromWorker);\n\n queueMicrotask(() => {\n this.announceLoaded();\n });\n } catch (error) {\n // the failure path reports with the worker event in hand; anything else is on us\n if (error !== signal.reason) {\n this.logger.error('failed to start', error);\n }\n\n this.stopListeningTo(worker);\n this.#worker = undefined;\n\n // only a start that nobody else is unwinding owns this worker: the reference is gone,\n // nobody can reach it any more, and leaving it running would keep a thread open for an\n // environment that never started. A failure has already terminated it, and a teardown\n // in flight is waiting for its Destroyed reply \u2014 cutting that short here would leave\n // destroy() to sit out its timeout and skip the worker-side teardown entirely.\n if (!this.#isDestroyed) {\n worker.terminate();\n }\n\n throw error;\n }\n }\n\n applyChangeTrail(changeTrail: ChangeTrailType, waitForConfirmation: boolean): Promise<void> {\n const {signal} = this.#workerFailure;\n if (signal.aborted) return Promise.reject(signal.reason);\n\n const worker = this.#worker;\n if (worker == null) return Promise.reject(new WorkerDestroyedError());\n\n const {changeTrail: outbound, transferables} = splitTransferables(changeTrail);\n const message: ChangeTrailMessage = {type: ChangeTrail, changeTrail: outbound};\n\n if (!waitForConfirmation) {\n worker.postMessage(message, transferables ?? []);\n return Promise.resolve();\n }\n\n // the counter moves only where a number actually goes on the wire: it is the sole link\n // between a request and its confirmation, and a sequence with invisible jumps in it tells\n // a later diagnosis nothing\n const serial = ++this.#changeTrailSerial;\n message.serial = serial;\n\n worker.postMessage(message, transferables ?? []);\n\n return waitForMessageOfType(\n worker,\n AppliedChangeTrail,\n this.timeouts.changeTrailTimeout,\n (data: AppliedChangeTrailEvent) => {\n // the serial decides who a confirmation concerns -- an error belonging to another\n // trail would otherwise reject the request that happens to be waiting here\n if (data.serial !== serial) return false;\n if (data.error) {\n const reason = new WorkerReportedError(data.errorName, data.error);\n // Only a confirmation that names the count can move the line the view draws between\n // applied and pending; one that does not carries no more than the reason itself, and\n // is handed on as that reason.\n if (typeof data.appliedCount === 'number') {\n throw new ChangeTrailRefusedError(data.appliedCount, changeTrail.length, {cause: reason});\n }\n throw reason;\n }\n return true;\n },\n signal,\n );\n }\n\n importScript(url: URL | string): Promise<void> {\n const {signal} = this.#workerFailure;\n if (signal.aborted) return Promise.reject(signal.reason);\n\n const worker = this.#worker;\n if (worker == null) return Promise.reject(new WorkerDestroyedError());\n\n url = toUrlString(url);\n worker.postMessage({type: Configure, importModule: url});\n return waitForMessageOfType(\n worker,\n ImportedModule,\n this.timeouts.configureTimeout,\n (data: ImportedModuleEvent) => {\n if (data.url !== url) return false;\n if (data.error) throw new WorkerReportedError(data.errorName, data.error);\n return true;\n },\n signal,\n );\n }\n\n /**\n * Asks the worker for a snapshot of its Kernel. The request travels as an `Inspect` message\n * under a serial of its own, and the `Inspected` answer that carries the same serial settles\n * the call: with the snapshot, or with a `WorkerReportedError` rebuilt from the failure the\n * worker described. An answer that stays out past `inspectTimeout` rejects with a\n * `WorkerTimeoutError`; a worker that failed or an environment that was torn down rejects right\n * away, before or while the answer is awaited.\n *\n * The caller's `signal` ends the wait with its own reason. The worker is not told: an answer\n * that arrives afterwards carries a serial nobody waits for any more and is discarded like any\n * other unmatched message.\n *\n * The message runs through the same queue as the change trails, so the snapshot reflects every\n * trail posted before this call and none posted after it.\n */\n inspect(request: InspectRequest = {}, signal?: AbortSignal): Promise<KernelSnapshot> {\n const {signal: failure} = this.#workerFailure;\n if (failure.aborted) return Promise.reject(failure.reason);\n if (signal?.aborted) return Promise.reject(signal.reason);\n\n const worker = this.#worker;\n if (worker == null) return Promise.reject(new WorkerDestroyedError());\n\n // a sequence of its own next to the one the change trails count on: the two answers are told\n // apart by their type, so neither sequence has to know about the other\n const serial = ++this.#inspectSerial;\n const message: InspectEvent = {type: Inspect, serial, request};\n worker.postMessage(message);\n\n let snapshot: KernelSnapshot | undefined;\n\n return waitForMessageOfType(\n worker,\n Inspected,\n this.timeouts.inspectTimeout,\n (data: InspectedEvent) => {\n if (data.serial !== serial) return false;\n if (data.error) throw new WorkerReportedError(data.errorName, data.error);\n snapshot = data.snapshot;\n return true;\n },\n signal === undefined ? failure : AbortSignal.any([failure, signal]),\n ).then(() => {\n // a reply that names neither a snapshot nor an error comes from a sender that does not\n // speak this protocol; it is a rejection, not a value the caller then reads through\n if (snapshot === undefined) {\n throw new WorkerReportedError(undefined, 'the worker answered the inspection without a snapshot');\n }\n return snapshot;\n });\n }\n\n destroy(): void {\n // the teardown counts even when there is no worker to tear down: everything that comes\n // afterwards has to meet an environment that is gone\n this.#isDestroyed = true;\n\n // releasing the reference here is what makes the teardown idempotent: a repeated call finds\n // nothing left, sends no second Destroy and terminates nothing twice\n const worker = this.#worker;\n this.#worker = undefined;\n\n // settles everything still waiting for a reply: a start() in the middle of its load handshake\n // would otherwise sit out its load timeout, and workerLoaded would never hear anything again\n this.#workerFailure.abort(new WorkerDestroyedError());\n\n if (worker == null) return;\n\n this.stopListeningTo(worker);\n\n worker.postMessage({type: Destroy});\n\n waitForMessageOfType(worker, Destroyed, this.timeouts.destroyTimeout)\n .catch((error) => {\n // `.finally()` passes a rejection on, so without this the silence of a worker ends as an\n // unhandled rejection once the destroy timeout is up. It is terminated either way, and\n // by then there is nobody left to hand the error to\n this.logger.warn('the worker did not acknowledge the teardown', error);\n })\n .finally(() => {\n worker.terminate();\n });\n }\n\n private readonly onWorkerError = (event: ErrorEvent): void => {\n this.handleWorkerFailure('error', event, event.message || 'the worker reported an error');\n };\n\n private readonly onWorkerMessageError = (event: MessageEvent): void => {\n this.handleWorkerFailure('messageerror', event, 'the worker sent a message that could not be deserialized');\n };\n\n private handleWorkerFailure(type: 'error' | 'messageerror', event: ErrorEvent | MessageEvent, message: string): void {\n // a deliberate teardown, or a failure that was already reported: the first one wins\n if (this.#isDestroyed) return;\n\n this.#isDestroyed = true;\n\n const reason = new WorkerFailedError(type, message, {\n cause: type === 'error' ? ((event as ErrorEvent).error ?? event) : event,\n });\n\n this.logger.error(message, event);\n\n const worker = this.#worker;\n this.#worker = undefined;\n\n if (worker != null) this.stopListeningTo(worker);\n\n // settle everyone waiting for a reply before the worker goes away \u2014 it can no longer arrive\n this.#workerFailure.abort(reason);\n\n worker?.terminate();\n\n // the ShadowEnv is told first, so that the state it derives from this is already\n // settled when consumers hear about it. Whatever happens down that path stays\n // there \u2014 the public event is announced either way\n try {\n (this as IShadowObjectEnvProxy).onProxyFailed?.(reason);\n } catch (error) {\n this.logger.error('the proxy-failed callback threw', error);\n }\n\n this.announceFailure({env: this, type, message, reason, event});\n }\n\n /**\n * Announces the completed handshake to the consumers.\n *\n * `emitStrict()` rather than `emit()`, and the retain policy is what decides it. `workerLoaded`\n * reads the retained value, and eventize writes that value only once the dispatch has run\n * through: under the plain dispatch a single listener that throws would take the replay for\n * every later subscriber with it, and every later read of `workerLoaded` would wait for a\n * failure or a teardown instead of resolving. The guarded dispatch serves every listener and\n * writes the retained value, because the event was delivered.\n *\n * What the listeners threw arrives here afterwards -- one of them unchanged, several as an\n * `AggregateError` in dispatch order -- and is reported. It goes no further: this runs from a\n * microtask, where a throw has no caller left to reach and would surface as an unhandled error.\n */\n private announceLoaded(): void {\n try {\n emitStrict(this as RemoteWorkerEnv, RemoteWorkerEnv.WorkerLoaded, this);\n } catch (error) {\n this.logger.error('a workerLoaded listener threw', error);\n }\n }\n\n /**\n * Announces the failure to the consumers. The same guarded dispatch as\n * {@link RemoteWorkerEnv.announceLoaded}, for the same reason: `WorkerFailed` is documented as\n * retained, and a consumer that subscribes only after the failure has to be able to hear about\n * it. Every listener is served, the retained value is written, and whatever was thrown is\n * reported here and reaches no caller.\n */\n private announceFailure(payload: WorkerFailedEvent): void {\n try {\n emitStrict(this as RemoteWorkerEnv, RemoteWorkerEnv.WorkerFailed, payload);\n } catch (error) {\n this.logger.error('a workerFailed listener threw', error);\n }\n }\n\n private readonly onMessageFromWorker = (event: MessageEvent): void => {\n if (event.data?.type === MessageToView) {\n (this as IShadowObjectEnvProxy).onMessageToView?.(event.data.data);\n } else {\n this.logger.debug('message from worker', event);\n }\n };\n\n /**\n * Takes every listener of this environment off a worker. Whoever registered them takes them\n * off again -- between the teardown and the `terminate()` that ends it the worker stays\n * alive, and through its listeners it keeps this environment and everything it references\n * reachable for exactly that long.\n */\n private stopListeningTo(worker: Worker): void {\n worker.removeEventListener('error', this.onWorkerError);\n worker.removeEventListener('messageerror', this.onWorkerMessageError);\n worker.removeEventListener('message', this.onMessageFromWorker);\n }\n\n private configureConsoleLogger(worker: Worker) {\n const configKey = ['RemoteWorkerEnv', 'workerConfig'];\n const storageKey = consoleLoggerConfigKey(configKey);\n const workerConfig = this.readWorkerConfig(configKey, storageKey);\n\n this.logger.info('load console-logger worker config', {storageKey, workerConfig});\n\n worker.postMessage({\n type: CONSOLE_LOGGER,\n config: {\n ...ConsoleLogger.sharedConfig,\n enable: this.logger.isEnabled,\n ...workerConfig,\n ...(ConsoleLogger.isEnabled ? {} : {enable: false}),\n },\n });\n }\n\n /**\n * The console-logger config for the worker, read from the storage key this environment\n * announces. The key is a diagnostic switch, set by hand and sharing its namespace with\n * everything else on this origin, so its content decides nothing about whether the worker\n * comes up: anything that is not a plain JSON object counts as no config at all, exactly\n * like an absent key.\n */\n private readWorkerConfig(configKey: string[], storageKey: string): Record<string, unknown> {\n const stored = loadConsoleLoggerConfig(configKey, '{}');\n\n let parsed: unknown;\n try {\n parsed = JSON.parse(stored);\n } catch (error) {\n // error, not warn: whoever writes this key wants the worker to talk, and a silent\n // fallback would send them looking for the reason inside the worker\n this.logger.error(`ignoring the unreadable console-logger worker config at \"${storageKey}\"`, stored, error);\n return {};\n }\n\n if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {\n this.logger.error(`ignoring the console-logger worker config at \"${storageKey}\": expected a JSON object`, stored);\n return {};\n }\n\n return parsed as Record<string, unknown>;\n }\n}\n"],
5
+ "mappings": "AAAA,SAAQ,YAAY,MAAM,cAAa;AACvC,SAAQ,+BAA8B;AACtC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,OAAO,kBAAkB;AAWzB,SAAQ,gBAAgB,eAAe,wBAAwB,+B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;AAAA,MACnD;AAAA,IACF,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASQ,iBAAiB,WAAqB,YAA6C;AACzF,UAAM,SAAS,wBAAwB,WAAW,IAAI;AAEtD,QAAI;AACJ,QAAI;AACF,eAAS,KAAK,MAAM,MAAM;AAAA,IAC5B,SAAS,OAAO;AAGd,WAAK,OAAO,MAAM,4DAA4D,UAAU,KAAK,QAAQ,KAAK;AAC1G,aAAO,CAAC;AAAA,IACV;AAEA,QAAI,OAAO,WAAW,YAAY,WAAW,QAAQ,MAAM,QAAQ,MAAM,GAAG;AAC1E,WAAK,OAAO,MAAM,iDAAiD,UAAU,6BAA6B,MAAM;AAChH,aAAO,CAAC;AAAA,IACV;AAEA,WAAO;AAAA,EACT;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,3 +1,4 @@
1
+ import type { EnvSnapshot, InspectRequest } from '../inspect/types.js';
1
2
  import type { ChangeTrailType, NamespaceType } from '../types.js';
2
3
  import { ConsoleLogger } from '../utils/ConsoleLogger.js';
3
4
  import { ComponentContext } from './ComponentContext.js';
@@ -15,11 +16,31 @@ export declare class ShadowEnvDestroyedError extends Error {
15
16
  export declare class ShadowEnv {
16
17
  #private;
17
18
  static AfterSync: string;
19
+ static SyncFailed: string;
18
20
  static ContextLost: string;
19
21
  static ContextCreated: string;
20
22
  static ProxyFailed: string;
21
23
  static get(ns: NamespaceType): ShadowEnv | undefined;
22
- readonly logger: ConsoleLogger;
24
+ /**
25
+ * Every environment that holds a namespace, in registration order, each described by
26
+ * {@link ShadowEnv.inspect}. One environment that cannot answer costs its own entry and not the
27
+ * list: the per-environment failures are reported under `error`, and an environment destroyed
28
+ * while it answers drops out of the list. Rejects only for the caller's reasons -- an aborted
29
+ * signal.
30
+ *
31
+ * `only` narrows the list before anything is asked: it is called with the namespace an
32
+ * environment is registered under, and an environment it refuses is neither inspected nor
33
+ * listed. That is what lets a caller keep an environment out of a picture without touching it.
34
+ */
35
+ static inspectAll(request?: InspectRequest, signal?: AbortSignal, only?: (ns: NamespaceType) => boolean): Promise<EnvSnapshot[]>;
36
+ /** The logger this environment reports through. */
37
+ get logger(): ConsoleLogger;
38
+ /**
39
+ * The namespace of the {@link ComponentContext} this environment observes, and `undefined`
40
+ * while it observes none. The `view` setter writes it, so it carries the name
41
+ * {@link ShadowEnv.get} finds this environment under, unless another environment has since
42
+ * taken that namespace over; a `destroy()` leaves it on `undefined`.
43
+ */
23
44
  readonly ns$: import("@spearwolf/signalize").Signal<NamespaceType | undefined>;
24
45
  accessor viewReady: boolean;
25
46
  accessor proxyReady: boolean;
@@ -36,13 +57,69 @@ export declare class ShadowEnv {
36
57
  * @throws {ShadowEnvDestroyedError} if the environment is destroyed before that happens
37
58
  */
38
59
  readonly ready: () => Promise<ShadowEnv>;
60
+ /**
61
+ * Send the change trail without asking the Shadow Environment to confirm it --
62
+ * {@link ShadowEnv.syncWait} is the call that asks.
63
+ *
64
+ * What becomes of a refusal is then the proxy's decision, and the two shipped ones differ.
65
+ * `LocalShadowObjectEnv` runs the Kernel synchronously, inside the call the environment makes to
66
+ * the proxy -- one microtask after `sync()` returned, not inside the call to `sync()` itself --
67
+ * and rejects with what it threw, so a refusal reaches {@link ShadowEnv.SyncFailed} here as well,
68
+ * carrying its number.
69
+ * `RemoteWorkerEnv` sends no serial without a confirmation and gets no answer back, so a
70
+ * refusal stays in the worker: it is written to the console there, `SyncFailed` stays silent, and
71
+ * the whole trail is booked as applied.
72
+ *
73
+ * {@link ShadowEnv.syncWait} is the way both proxies answer on.
74
+ */
39
75
  sync(): void;
40
76
  /**
41
77
  * Like {@link ShadowEnv.sync}, but resolves with the change trail once the cycle completed.
42
78
  *
43
- * @throws {ShadowEnvDestroyedError} if the environment is destroyed before that happens
79
+ * A cycle whose change trail the Shadow Environment could not apply rejects instead, with the
80
+ * reason the proxy gave. Where the Kernel itself refused the trail that reason is a
81
+ * {@link ChangeTrailRefusedError}: it names how many entries the Kernel applied, this side folds
82
+ * exactly those into its bookkeeping, and everything behind that line stays pending and goes out
83
+ * again with the next cycle. A trail whose cause of refusal stays put is refused every time, which
84
+ * is what {@link ShadowEnv.SyncFailed} is the place to act on.
85
+ *
86
+ * A reason that says nothing about how far the Kernel got -- a confirmation window that ran out,
87
+ * a proxy whose environment is gone -- counts the whole trail as applied, because a Shadow
88
+ * Environment that fell silent may well hold all of it. Then the trail is gone, and only a
89
+ * re-creation from the Component Memory brings it back. That re-creation belongs to a fresh
90
+ * proxy: an environment that still holds the entities refuses a creation for a uuid it already
91
+ * has. Handing {@link ShadowEnv.envProxy} a new proxy is therefore the way back -- the Shadow
92
+ * Environment calls {@link ComponentContext.reCreateChanges} itself once the new proxy is ready.
93
+ * Making that call is the consumer's decision, the same way recovering from a
94
+ * {@link ShadowEnv.ProxyFailed} is.
95
+ *
96
+ * Which cycle a caller gets is decided when the change trail is built. Everyone who arrives
97
+ * before that point waits on the same promise -- they all ride the same trail. From the build
98
+ * on the trail is fixed, and a call after it belongs to the next cycle, the one that carries
99
+ * the changes made since. That holds inside a listener of {@link ShadowEnv.AfterSync} or
100
+ * {@link ShadowEnv.SyncFailed} as well: the cycle it was told about is over, so the call opens
101
+ * the one behind it.
102
+ *
103
+ * @throws {ShadowEnvDestroyedError} if the environment is destroyed before the cycle completes
44
104
  */
45
105
  syncWait(): Promise<ChangeTrailType>;
106
+ /**
107
+ * Describe this environment: the View's component tree and, where the proxy is ready and
108
+ * implements `inspect`, the Kernel's Entity Tree behind it.
109
+ *
110
+ * Never rejects for a reason inside the environment -- a proxy that cannot answer, a Kernel that
111
+ * threw, a View snapshot that threw -- and reports those under `error`, with the half that failed
112
+ * absent. Where both halves fail, `error` carries the View's reason. A proxy that is not ready yet
113
+ * is not an error either: `state.proxyReady` says so, and `kernel` is simply absent. It rejects
114
+ * only for a reason of the caller's: an aborted signal, or an environment that is destroyed
115
+ * before or while the proxy answers. The signal is raced here as well, so an abort settles the
116
+ * call whether or not the proxy honours the signal it was handed.
117
+ *
118
+ * A caller that wants the View and the Kernel to agree after its own change awaits
119
+ * {@link ShadowEnv.syncWait} first; the View snapshot reads the committed Component Memory,
120
+ * not the pending changes.
121
+ */
122
+ inspect(request?: InspectRequest, signal?: AbortSignal): Promise<EnvSnapshot>;
46
123
  /**
47
124
  * Tear the environment down: the proxy is destroyed, the namespace is released, all signals
48
125
  * and listeners are removed, and every caller still waiting on {@link ShadowEnv.ready} or
@@ -1 +1 @@
1
- {"version":3,"file":"ShadowEnv.d.ts","sourceRoot":"","sources":["../../../src/view/ShadowEnv.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,eAAe,EAAE,aAAa,EAAC,MAAM,aAAa,CAAC;AAChE,OAAO,EAAC,aAAa,EAAC,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAC,gBAAgB,EAAC,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,4BAA4B,CAAC;AAEtE,OAAO,CAAC,MAAM,CAAC;IAEb,IAAI,YAAY,EAAE,GAAG,CAAC,aAAa,EAAE,SAAS,CAAC,GAAG,SAAS,CAAC;CAC7D;AAED;;;GAGG;AACH,qBAAa,uBAAwB,SAAQ,KAAK;gBACpC,OAAO,SAA8C;CAIlE;AAED,qBAAa,SAAS;;IACpB,MAAM,CAAC,SAAS,SAAe;IAC/B,MAAM,CAAC,WAAW,SAAiB;IACnC,MAAM,CAAC,cAAc,SAAoB;IACzC,MAAM,CAAC,WAAW,SAAiB;IAEnC,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,aAAa,GAAG,SAAS,GAAG,SAAS;IAYpD,QAAQ,CAAC,MAAM,gBAAkC;IAEjD,QAAQ,CAAC,GAAG,mEAA6C;IAE/C,QAAQ,CAAC,SAAS,UAAS;IAC3B,QAAQ,CAAC,UAAU,UAAS;IAItC,IAAI,WAAW,YAEd;;IA2BD,IAAI,IAAI,IAAI,gBAAgB,GAAG,SAAS,CAEvC;IAED,IAAI,IAAI,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