@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,25 +1,51 @@
1
1
  import { on } from "@spearwolf/eventize";
2
- import { batch, createEffect, createSignal, destroySignal, Effect } from "@spearwolf/signalize";
3
- import { readBooleanAttribute } from "../utils/attr-utils.js";
2
+ import { batch, createEffect, createSignal, destroySignal, Effect, hibernate } from "@spearwolf/signalize";
3
+ import { readBooleanAttribute, readListAttribute, readNumberAttribute } from "../utils/attr-utils.js";
4
4
  import { ConsoleLogger } from "../utils/ConsoleLogger.js";
5
5
  import { FrameLoop } from "../utils/FrameLoop.js";
6
6
  import { ComponentContext } from "../view/ComponentContext.js";
7
7
  import { LocalShadowObjectEnv } from "../view/LocalShadowObjectEnv.js";
8
8
  import { RemoteWorkerEnv } from "../view/RemoteWorkerEnv.js";
9
9
  import { ShadowEnv, ShadowEnvDestroyedError } from "../view/ShadowEnv.js";
10
- import { ATTR_AUTO_SYNC, ATTR_LOCAL, ATTR_NO_AUTOSTART, ATTR_NO_STRUCTURED_CLONE, ATTR_SRC } from "./constants.js";
10
+ import {
11
+ ATTR_AUTO_SYNC,
12
+ ATTR_CHANGE_TRAIL_TIMEOUT,
13
+ ATTR_CONFIGURE_TIMEOUT,
14
+ ATTR_DESTROY_TIMEOUT,
15
+ ATTR_EXPOSE_TO_MODEL_CONTEXT,
16
+ ATTR_INSPECT_TIMEOUT,
17
+ ATTR_LOAD_TIMEOUT,
18
+ ATTR_LOCAL,
19
+ ATTR_NO_AUTOSTART,
20
+ ATTR_NO_STRUCTURED_CLONE,
21
+ ATTR_REDACT_PROPS,
22
+ ATTR_SRC
23
+ } from "./constants.js";
24
+ import { ensureDisplayContentsRule } from "./displayContentsRule.js";
11
25
  import { ShaeElement } from "./ShaeElement.js";
26
+ const WorkerTimeoutAttributes = [
27
+ ["loadTimeout", ATTR_LOAD_TIMEOUT],
28
+ ["configureTimeout", ATTR_CONFIGURE_TIMEOUT],
29
+ ["changeTrailTimeout", ATTR_CHANGE_TRAIL_TIMEOUT],
30
+ ["inspectTimeout", ATTR_INSPECT_TIMEOUT],
31
+ ["destroyTimeout", ATTR_DESTROY_TIMEOUT]
32
+ ];
33
+ function normaliseAutoSync(value) {
34
+ if (typeof value !== "string") {
35
+ return value ? ShaeWorkerElement.DefaultAutoSync : "no";
36
+ }
37
+ return value.trim().toLowerCase();
38
+ }
12
39
  class ShaeWorkerElement extends ShaeElement {
13
40
  constructor() {
14
- super();
41
+ super(...arguments);
15
42
  this.isShaeWorkerElement = true;
16
43
  this.shadowEnv = new ShadowEnv();
17
- this.logger = new ConsoleLogger("ShaeWorkerElement");
44
+ this.#logger = new ConsoleLogger("ShaeWorkerElement");
18
45
  this.autostart = true;
19
46
  this.isConnected$ = createSignal(false);
20
47
  this.autoSync$ = createSignal(ShaeWorkerElement.DefaultAutoSync);
21
48
  this.src$ = createSignal("");
22
- this.#shouldDestroy = false;
23
49
  this.#started = false;
24
50
  /**
25
51
  * Both {@link ShaeWorkerElement.start} and {@link ShaeWorkerElement.importScript} await
@@ -32,7 +58,80 @@ class ShaeWorkerElement extends ShaeElement {
32
58
  if (error instanceof ShadowEnvDestroyedError) return;
33
59
  this.logger.error("shadowEnv failed", error);
34
60
  };
35
- this.ns$.onChange((ns) => {
61
+ }
62
+ static {
63
+ this.observedAttributes = [
64
+ ...ShaeElement.observedAttributes,
65
+ ATTR_LOCAL,
66
+ ATTR_SRC,
67
+ ATTR_NO_STRUCTURED_CLONE,
68
+ ATTR_AUTO_SYNC,
69
+ ATTR_EXPOSE_TO_MODEL_CONTEXT
70
+ ];
71
+ }
72
+ static {
73
+ this.DefaultAutoSync = "frame";
74
+ }
75
+ #logger;
76
+ /** The logger this element reports through. */
77
+ get logger() {
78
+ return this.#logger;
79
+ }
80
+ #started;
81
+ #autoSync;
82
+ #importScript;
83
+ #modelContextExposure;
84
+ /** The `redact-props` attribute as a list of property names, read as it stands right now. */
85
+ get redactProps() {
86
+ return readListAttribute(this, ATTR_REDACT_PROPS);
87
+ }
88
+ /**
89
+ * This element's share of the page's model-context registration, while it has one: a promise
90
+ * of the `ExposeHandle`, resolving once the tools are on the platform (`available: false` where
91
+ * there is none) and rejecting with what `registerTool()` rejected with. `undefined` without
92
+ * the `expose-to-model-context` attribute, before the first connect, and after a teardown.
93
+ */
94
+ get modelContextExposure() {
95
+ return this.#modelContextExposure?.handle;
96
+ }
97
+ /**
98
+ * Points the environment at the namespace this element names.
99
+ *
100
+ * It hangs on `ns$`, which belongs to the base class and outlives this element's teardown, so
101
+ * the handle is kept and released by hand — a listener left on a living signal is a listener the
102
+ * global signal queue goes on holding, and with it this element.
103
+ */
104
+ #envViewBinding;
105
+ /**
106
+ * Take the subscriptions up. Runs exactly once for this element, on the first connect.
107
+ *
108
+ * The return that `restore()` stands for on `<shae-ent>` and `<shae-prop>` does not exist here:
109
+ * `connectedCallback` turns a torn-down `<shae-worker>` away, so nothing ever calls this a second
110
+ * time.
111
+ *
112
+ * One path runs ahead of it, and it is the only one: `start()` is public, and an element started
113
+ * by hand while it is out of the document builds its environment before anything below is
114
+ * listening. Two things are lost there and stay lost, because both are moments rather than
115
+ * values, and there is no honest way to replay a moment that has passed:
116
+ *
117
+ * - the `contextcreated` — and, should the environment lose its connection first, the
118
+ * `contextlost` — DOM event for that environment. `ShadowEnv.ContextCreated` fires once, with
119
+ * nobody on the element listening for it; re-dispatching it from here would announce as new an
120
+ * environment that has been up for a while.
121
+ * - the namespace the environment points at, where `ns` changed between that `start()` and the
122
+ * first connect. `start()` resolves the view once with `??=`, the binding below only reacts to
123
+ * *changes*, and the change already happened. `shadowEnv.view` then names the context of the
124
+ * namespace the element carried when it was started. A write of `ns` after the first connect
125
+ * moves it, as it always does.
126
+ *
127
+ * A `<shae-worker>` that connects before it starts — the ordinary way, and the only way the
128
+ * declarative form has — meets neither. The import of `src` is the one case of this shape that
129
+ * *is* caught up, at the end of this method, because a pending import is a value and not a
130
+ * moment.
131
+ */
132
+ restore() {
133
+ super.restore();
134
+ this.#envViewBinding = this.ns$.onChange((ns) => {
36
135
  this.shadowEnv.view = ComponentContext.get(ns);
37
136
  });
38
137
  on(this.shadowEnv, ShadowEnv.ContextCreated, () => {
@@ -60,7 +159,24 @@ class ShaeWorkerElement extends ShaeElement {
60
159
  })
61
160
  );
62
161
  });
63
- this.autoSync$.onChange((sVal) => {
162
+ on(this.shadowEnv, ShadowEnv.SyncFailed, (reason, changeTrail) => {
163
+ this.dispatchEvent(
164
+ new CustomEvent(ShadowEnv.SyncFailed.toLowerCase(), {
165
+ bubbles: false,
166
+ detail: { shadowEnv: this.shadowEnv, reason, changeTrail }
167
+ })
168
+ );
169
+ });
170
+ this.autoSync$.onChange((sVal) => this.#reflectAutoSync(sVal));
171
+ this.#reflectAutoSync(this.autoSync$.value);
172
+ this.#createAutoSyncEffect();
173
+ this.#createImportScriptEffect();
174
+ if (this.shadowEnv.isReady) {
175
+ this.#importScript?.run();
176
+ }
177
+ }
178
+ #reflectAutoSync(sVal) {
179
+ this.reflectAttribute(ATTR_AUTO_SYNC, () => {
64
180
  const hasAttr = this.hasAttribute(ATTR_AUTO_SYNC);
65
181
  const attrVal = hasAttr ? this.getAttribute(ATTR_AUTO_SYNC) : void 0;
66
182
  if (sVal === ShaeWorkerElement.DefaultAutoSync) {
@@ -71,27 +187,7 @@ class ShaeWorkerElement extends ShaeElement {
71
187
  this.setAttribute(ATTR_AUTO_SYNC, sVal);
72
188
  }
73
189
  });
74
- this.#createAutoSyncEffect();
75
- this.#createImportScriptEffect();
76
- this.style.display = "contents";
77
- }
78
- static {
79
- this.observedAttributes = [
80
- ...ShaeElement.observedAttributes,
81
- ATTR_LOCAL,
82
- ATTR_SRC,
83
- ATTR_NO_STRUCTURED_CLONE,
84
- ATTR_AUTO_SYNC
85
- ];
86
- }
87
- static {
88
- this.DefaultAutoSync = "frame";
89
190
  }
90
- #shouldDestroy;
91
- #started;
92
- #frameLoop;
93
- #autoSync;
94
- #importScript;
95
191
  #createImportScriptEffect() {
96
192
  this.#importScript = createEffect(
97
193
  () => {
@@ -111,14 +207,10 @@ class ShaeWorkerElement extends ShaeElement {
111
207
  return this.autoSync$.value;
112
208
  }
113
209
  set autoSync(val) {
114
- if (typeof val !== "string") {
115
- val = val ? ShaeWorkerElement.DefaultAutoSync : "no";
116
- }
117
- this.autoSync$.set(`${val}`.trim().toLowerCase());
210
+ this.autoSync$.set(normaliseAutoSync(val));
118
211
  }
119
212
  get frameLoop() {
120
- this.#frameLoop ??= new FrameLoop();
121
- return this.#frameLoop;
213
+ return FrameLoop.get();
122
214
  }
123
215
  /**
124
216
  * The frameLoop (if activated) calls this method on every frame
@@ -131,9 +223,7 @@ class ShaeWorkerElement extends ShaeElement {
131
223
  throw new Error("src is blank");
132
224
  }
133
225
  const shadowEnv = await this.shadowEnv.ready();
134
- if (this.logger.isInfo) {
135
- this.logger.info("shadowEnv importScript:", src, { shadowEnv });
136
- }
226
+ this.logger.info("shadowEnv importScript:", src, { shadowEnv });
137
227
  const envProxy = shadowEnv.envProxy;
138
228
  if (envProxy == null) {
139
229
  throw new ShadowEnvDestroyedError();
@@ -142,33 +232,40 @@ class ShaeWorkerElement extends ShaeElement {
142
232
  return this;
143
233
  }
144
234
  connectedCallback() {
145
- batch(() => {
146
- const autoSync = this.getAttribute(ATTR_AUTO_SYNC);
147
- if (autoSync != null) {
148
- this.autoSync$.set(autoSync);
235
+ hibernate(() => {
236
+ if (this.isDestroyed) {
237
+ ensureDisplayContentsRule(this.getRootNode(), this.localName);
238
+ return;
239
+ }
240
+ super.connectedCallback();
241
+ batch(() => {
242
+ const autoSync = this.getAttribute(ATTR_AUTO_SYNC);
243
+ if (autoSync != null) {
244
+ this.autoSync = autoSync;
245
+ }
246
+ this.isConnected$.set(true);
247
+ });
248
+ if (this.shouldAutostart) {
249
+ this.start().catch(this.#onUnobservedRejection);
149
250
  }
150
- this.isConnected$.set(true);
251
+ this.#syncModelContextExposure();
151
252
  });
152
- if (this.shouldAutostart) {
153
- this.start().catch(this.#onUnobservedRejection);
154
- }
155
253
  }
156
254
  disconnectedCallback() {
157
255
  this.isConnected$.set(false);
158
- this.#deferDestroy();
256
+ super.disconnectedCallback();
159
257
  }
160
258
  attributeChangedCallback(name) {
259
+ if (this.isDestroyed) return;
161
260
  super.attributeChangedCallback(name);
162
261
  if (name === ATTR_LOCAL) {
163
- if (this.shadowEnv.envProxy != null) {
164
- throw new Error('Changing the "local" attribute after the shadowEnv has been created is not supported.');
165
- }
262
+ this.#refuseLocalChange();
166
263
  }
167
264
  if (name === ATTR_NO_STRUCTURED_CLONE) {
168
265
  this.#disableStructuredClone();
169
266
  }
170
267
  if (name === ATTR_AUTO_SYNC) {
171
- this.autoSync = this.hasAttribute(ATTR_AUTO_SYNC) ? this.getAttribute(ATTR_AUTO_SYNC) : true;
268
+ this.autoSync = this.getAttribute(ATTR_AUTO_SYNC) ?? true;
172
269
  }
173
270
  if (name === ATTR_SRC) {
174
271
  const src = (this.getAttribute(ATTR_SRC) || "").trim();
@@ -177,13 +274,30 @@ class ShaeWorkerElement extends ShaeElement {
177
274
  this.#importScript?.run();
178
275
  }
179
276
  }
277
+ if (name === ATTR_EXPOSE_TO_MODEL_CONTEXT) {
278
+ this.#syncModelContextExposure();
279
+ }
280
+ }
281
+ /**
282
+ * The timeout attributes, read at the one moment they are needed: when the worker environment
283
+ * is built. An attribute that is not there is left out, so the environment keeps its default,
284
+ * and a value the environment does not accept is reported there. They are not observed —
285
+ * setting one afterwards changes nothing about an environment that already exists, and a
286
+ * `local` element builds no worker environment at all, so they do nothing there.
287
+ */
288
+ #readWorkerTimeouts() {
289
+ const options = {};
290
+ for (const [key, attr] of WorkerTimeoutAttributes) {
291
+ const value = readNumberAttribute(this, attr);
292
+ if (value !== void 0) options[key] = value;
293
+ }
294
+ return options;
180
295
  }
181
296
  start() {
182
297
  if (!this.#started) {
183
- this.#shouldDestroy = false;
184
298
  this.shadowEnv.view ??= ComponentContext.get(this.ns);
185
299
  if (this.shadowEnv.envProxy == null) {
186
- const envProxy = readBooleanAttribute(this, ATTR_LOCAL) ? new LocalShadowObjectEnv() : new RemoteWorkerEnv();
300
+ const envProxy = readBooleanAttribute(this, ATTR_LOCAL) ? new LocalShadowObjectEnv() : new RemoteWorkerEnv(this.#readWorkerTimeouts());
187
301
  this.shadowEnv.envProxy = envProxy;
188
302
  this.#disableStructuredClone();
189
303
  }
@@ -191,41 +305,49 @@ class ShaeWorkerElement extends ShaeElement {
191
305
  }
192
306
  return this.shadowEnv.ready();
193
307
  }
194
- destroy() {
308
+ /**
309
+ * Tear this element down — for good.
310
+ *
311
+ * The effects and signals below belong to the element alone, so the element is what decides
312
+ * whether they have already been released; the guard for that sits in
313
+ * `ShaeLifecycleElement.destroy()`, which has already set the flag by the time this runs. Here
314
+ * that matters more than anywhere else: `shadowEnv.destroy()` dispatches a `contextlost`
315
+ * `CustomEvent` on this element on its way out, and a listener on it that reaches back into
316
+ * `destroy()` finds the flag down and turns around instead of tearing the same environment down
317
+ * a second time.
318
+ *
319
+ * Unlike `<shae-ent>` and `<shae-prop>`, this teardown is final: it destroys the signals and
320
+ * takes the environment down with them, and neither comes back. `connectedCallback` turns a
321
+ * returning element away rather than handing it a half of what it had, which is what makes
322
+ * {@link ShaeWorkerElement.restore} a method that runs once and never again.
323
+ */
324
+ teardown() {
325
+ this.#leaveModelContextExposure();
326
+ this.#envViewBinding?.();
327
+ this.#envViewBinding = void 0;
195
328
  this.#autoSync?.destroy();
196
329
  this.#importScript?.destroy();
197
330
  destroySignal(this.isConnected$, this.autoSync$, this.src$);
198
331
  this.shadowEnv.envProxy = void 0;
199
332
  this.shadowEnv.destroy();
200
- }
201
- #deferDestroy() {
202
- if (!this.#shouldDestroy) {
203
- this.#shouldDestroy = true;
204
- queueMicrotask(() => {
205
- if (this.#shouldDestroy) {
206
- this.destroy();
207
- }
208
- });
209
- }
333
+ super.teardown();
210
334
  }
211
335
  #createAutoSyncEffect() {
212
336
  this.#autoSync = createEffect(() => {
213
337
  if (this.isConnected$.get()) {
214
- const autoSync = (this.autoSync$.get() || ShaeWorkerElement.DefaultAutoSync).trim().toLowerCase();
338
+ const autoSync = normaliseAutoSync(this.autoSync$.get() || ShaeWorkerElement.DefaultAutoSync);
215
339
  let delay;
216
340
  if (["true", "yes", "on", "frame", "auto-sync"].includes(autoSync)) {
217
- if (this.logger.isDebug) {
218
- this.logger.debug("auto-sync", autoSync, this);
219
- }
341
+ this.logger.debug("auto-sync", autoSync, this);
220
342
  this.frameLoop.start(this);
221
343
  return () => {
222
344
  this.frameLoop.stop(this);
223
345
  };
224
- } else if (autoSync.toLowerCase().endsWith("fps")) {
346
+ } else if (autoSync.endsWith("fps")) {
225
347
  const fps = parseInt(autoSync, 10);
226
348
  if (fps > 0) {
227
349
  delay = Math.floor(1e3 / fps);
228
- } else if (this.logger.isWarn) {
350
+ } else {
229
351
  this.logger.warn(`invalid auto-sync value: ${autoSync}`);
230
352
  }
231
353
  } else {
@@ -238,16 +360,14 @@ class ShaeWorkerElement extends ShaeElement {
238
360
  }
239
361
  }
240
362
  if (delay !== void 0 && delay > 0) {
241
- if (this.logger.isDebug) {
242
- this.logger.debug("auto-sync interval (ms)", delay, this);
243
- }
363
+ this.logger.debug("auto-sync interval (ms)", delay, this);
244
364
  const id = setInterval(() => {
245
365
  this.syncShadowObjects();
246
366
  }, delay);
247
367
  return () => {
248
368
  clearInterval(id);
249
369
  };
250
- } else if (this.logger.isDebug) {
370
+ } else {
251
371
  this.logger.debug("auto-sync off", this);
252
372
  }
253
373
  }
@@ -259,6 +379,84 @@ class ShaeWorkerElement extends ShaeElement {
259
379
  env.disableStructuredClone = this.hasAttribute(ATTR_NO_STRUCTURED_CLONE);
260
380
  }
261
381
  }
382
+ /**
383
+ * `local` picks the environment kind once, at `start()`. The proxy, its kernel and its
384
+ * entities all belong to the side they were built on, and there is no way to move them onto
385
+ * the other one afterwards — a later write to this attribute is refused, not carried out.
386
+ *
387
+ * A throw from this reaction would not reach the caller of `setAttribute` either way: per spec,
388
+ * a Custom Element reaction reports its own exceptions to the global `error` event instead of
389
+ * propagating them synchronously, so a `try`/`catch` around the write would catch nothing. The
390
+ * refusal writes the attribute back through `reflectAttribute`, the one path this element uses
391
+ * to write its own attributes from inside, and reports the refusal separately through the
392
+ * `ConsoleLogger`. `logger.error` and not `logger.warn`: `logger.error` always prints, where
393
+ * `logger.warn` is gated behind `isWarn`, which is off outside `localhost`, and a refusal that
394
+ * goes silent there is exactly what this call needs to avoid.
395
+ *
396
+ * The write back re-enters `attributeChangedCallback` once, where the attribute now matches
397
+ * the effective state and the check below returns before logging again. On an element built
398
+ * and started by hand while it was never in the document, that write is parked until the first
399
+ * connect (see `reflectAttribute`), while the log line above runs immediately.
400
+ */
401
+ #refuseLocalChange() {
402
+ const envProxy = this.shadowEnv.envProxy;
403
+ if (envProxy == null) return;
404
+ const isLocalEnv = Boolean(envProxy.isLocalEnv);
405
+ if (readBooleanAttribute(this, ATTR_LOCAL) === isLocalEnv) return;
406
+ this.logger.error(
407
+ `the "local" attribute cannot change once the shadowEnv is built; it is reset to ${isLocalEnv ? 'the bare "local" form' : "its absence"} \u2014 build a new <shae-worker> element to switch environments`
408
+ );
409
+ this.reflectAttribute(ATTR_LOCAL, () => {
410
+ if (isLocalEnv) {
411
+ this.setAttribute(ATTR_LOCAL, "");
412
+ } else {
413
+ this.removeAttribute(ATTR_LOCAL);
414
+ }
415
+ });
416
+ }
417
+ /**
418
+ * Joins or leaves the page's model-context registration, whichever the attribute and the
419
+ * element's state ask for. The attribute is a truthy attribute like `local`; the join waits
420
+ * for a connect, because an element that is never connected has no environment to expose, and
421
+ * it ends with the teardown. `redact-props` is not watched: the share reads it at every call.
422
+ */
423
+ #syncModelContextExposure() {
424
+ const wanted = !this.isDestroyed && this.isConnected && readBooleanAttribute(this, ATTR_EXPOSE_TO_MODEL_CONTEXT);
425
+ if (wanted) {
426
+ this.#joinModelContextExposure();
427
+ } else {
428
+ this.#leaveModelContextExposure();
429
+ }
430
+ }
431
+ /**
432
+ * The share is an ordinary call of `exposeShadowEnvsToModelContext()` with two live rules:
433
+ * this element's namespace, and the names its `redact-props` attribute carries at the moment
434
+ * a tool asks. The function comes in through a dynamic import, and that is the whole reason
435
+ * this element can carry the attribute at all -- a static import would pull the model-context
436
+ * layer into every consumer of `<shae-worker>`, and the layer is meant to stay out of
437
+ * `index.ts` and the worker bundle. The single-file bundle inlines the import; the lib layout
438
+ * keeps the modules apart. A leave before the import is back aborts the signal the call is
439
+ * made with, and the function registers nothing for an aborted signal.
440
+ */
441
+ #joinModelContextExposure() {
442
+ if (this.#modelContextExposure !== void 0) return;
443
+ const controller = new AbortController();
444
+ const handle = import("../model-context/exposeShadowEnvsToModelContext.js").then(
445
+ ({ exposeShadowEnvsToModelContext }) => exposeShadowEnvsToModelContext({
446
+ signal: controller.signal,
447
+ namespaces: (ns) => ns === this.ns,
448
+ redactProps: (name) => this.redactProps.includes(name)
449
+ })
450
+ );
451
+ this.#modelContextExposure = { controller, handle };
452
+ handle.catch((error) => this.logger.error("expose-to-model-context: registering the tools failed", error));
453
+ }
454
+ #leaveModelContextExposure() {
455
+ const exposure = this.#modelContextExposure;
456
+ if (exposure === void 0) return;
457
+ this.#modelContextExposure = void 0;
458
+ exposure.controller.abort();
459
+ }
262
460
  }
263
461
  export {
264
462
  ShaeWorkerElement
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/elements/ShaeWorkerElement.ts"],
4
- "sourcesContent": ["import {on} from '@spearwolf/eventize';\nimport {batch, createEffect, createSignal, destroySignal, Effect} from '@spearwolf/signalize';\nimport {readBooleanAttribute} from '../utils/attr-utils.js';\nimport {ConsoleLogger} from '../utils/ConsoleLogger.js';\nimport {FrameLoop} from '../utils/FrameLoop.js';\nimport {ComponentContext} from '../view/ComponentContext.js';\nimport {LocalShadowObjectEnv} from '../view/LocalShadowObjectEnv.js';\nimport {RemoteWorkerEnv} from '../view/RemoteWorkerEnv.js';\nimport {ShadowEnv, ShadowEnvDestroyedError} from '../view/ShadowEnv.js';\nimport {ATTR_AUTO_SYNC, ATTR_LOCAL, ATTR_NO_AUTOSTART, ATTR_NO_STRUCTURED_CLONE, ATTR_SRC} from './constants.js';\nimport {ShaeElement} from './ShaeElement.js';\n\nexport class ShaeWorkerElement extends ShaeElement {\n static override observedAttributes = [\n ...ShaeElement.observedAttributes,\n ATTR_LOCAL,\n ATTR_SRC,\n ATTR_NO_STRUCTURED_CLONE,\n ATTR_AUTO_SYNC,\n ];\n\n static DefaultAutoSync = 'frame';\n\n readonly isShaeWorkerElement = true;\n\n readonly shadowEnv = new ShadowEnv();\n\n readonly logger = new ConsoleLogger('ShaeWorkerElement');\n\n autostart = true;\n\n isConnected$ = createSignal(false);\n autoSync$ = createSignal(ShaeWorkerElement.DefaultAutoSync);\n src$ = createSignal('');\n\n #shouldDestroy = false;\n #started = false;\n\n #frameLoop?: FrameLoop;\n #autoSync?: Effect;\n #importScript?: Effect;\n\n constructor() {\n super();\n\n this.ns$.onChange((ns) => {\n this.shadowEnv.view = ComponentContext.get(ns);\n });\n\n on(this.shadowEnv, ShadowEnv.ContextCreated, () => {\n this.#importScript?.run();\n this.dispatchEvent(\n new CustomEvent(ShadowEnv.ContextCreated.toLowerCase(), {\n bubbles: false,\n detail: {shadowEnv: this.shadowEnv},\n }),\n );\n });\n\n on(this.shadowEnv, ShadowEnv.ContextLost, () => {\n this.dispatchEvent(\n new CustomEvent(ShadowEnv.ContextLost.toLowerCase(), {\n bubbles: false,\n detail: {shadowEnv: this.shadowEnv},\n }),\n );\n });\n\n on(this.shadowEnv, ShadowEnv.ProxyFailed, (reason: unknown) => {\n this.dispatchEvent(\n new CustomEvent(ShadowEnv.ProxyFailed.toLowerCase(), {\n bubbles: false,\n detail: {shadowEnv: this.shadowEnv, reason},\n }),\n );\n });\n\n this.autoSync$.onChange((sVal) => {\n const hasAttr = this.hasAttribute(ATTR_AUTO_SYNC);\n const attrVal = hasAttr ? this.getAttribute(ATTR_AUTO_SYNC) : undefined;\n\n if (sVal === ShaeWorkerElement.DefaultAutoSync) {\n if (hasAttr && attrVal !== sVal) {\n this.setAttribute(ATTR_AUTO_SYNC, sVal);\n }\n } else if (attrVal !== sVal) {\n this.setAttribute(ATTR_AUTO_SYNC, sVal);\n }\n });\n\n this.#createAutoSyncEffect();\n this.#createImportScriptEffect();\n\n this.style.display = 'contents';\n }\n\n #createImportScriptEffect() {\n this.#importScript = createEffect(\n () => {\n const src = this.src$.get();\n if (src) {\n this.importScript(src).catch(this.#onUnobservedRejection);\n }\n },\n {autorun: false},\n );\n }\n\n /**\n * Both {@link ShaeWorkerElement.start} and {@link ShaeWorkerElement.importScript} await\n * {@link ShadowEnv.ready}, which rejects once the environment is destroyed \u2014 the normal\n * outcome for an element that connects and disconnects within the same task. Nothing in the\n * element waits on those promises, so the rejection has to end here instead of surfacing as\n * an unhandled rejection in the browser or as a hard failure in a test runner.\n */\n #onUnobservedRejection = (error: unknown) => {\n if (error instanceof ShadowEnvDestroyedError) return;\n this.logger.error('shadowEnv failed', error);\n };\n\n get shouldAutostart(): boolean {\n return this.autostart && !readBooleanAttribute(this, ATTR_NO_AUTOSTART);\n }\n\n get autoSync() {\n return this.autoSync$.value;\n }\n\n set autoSync(val: any) {\n if (typeof val !== 'string') {\n val = val ? ShaeWorkerElement.DefaultAutoSync : 'no';\n }\n this.autoSync$.set(`${val}`.trim().toLowerCase());\n }\n\n get frameLoop(): FrameLoop {\n this.#frameLoop ??= new FrameLoop();\n return this.#frameLoop;\n }\n\n /**\n * The frameLoop (if activated) calls this method on every frame\n */\n [FrameLoop.OnFrame]() {\n this.syncShadowObjects();\n }\n\n async importScript(src: URL | string): Promise<ShaeWorkerElement> {\n if (!src) {\n throw new Error('src is blank');\n }\n const shadowEnv = await this.shadowEnv.ready();\n if (this.logger.isInfo) {\n this.logger.info('shadowEnv importScript:', src, {shadowEnv});\n }\n // ready() only vouches for the proxy at the moment it resolves; a teardown can slip in\n // between that microtask and this line\n const envProxy = shadowEnv.envProxy;\n if (envProxy == null) {\n throw new ShadowEnvDestroyedError();\n }\n\n await envProxy.importScript(src);\n return this;\n }\n\n connectedCallback() {\n batch(() => {\n const autoSync = this.getAttribute(ATTR_AUTO_SYNC);\n if (autoSync != null) {\n this.autoSync$.set(autoSync);\n }\n this.isConnected$.set(true);\n });\n if (this.shouldAutostart) {\n this.start().catch(this.#onUnobservedRejection);\n }\n }\n\n disconnectedCallback() {\n this.isConnected$.set(false);\n this.#deferDestroy();\n }\n\n override attributeChangedCallback(name: string) {\n super.attributeChangedCallback(name);\n\n if (name === ATTR_LOCAL) {\n if (this.shadowEnv.envProxy != null) {\n throw new Error('Changing the \"local\" attribute after the shadowEnv has been created is not supported.');\n }\n }\n\n if (name === ATTR_NO_STRUCTURED_CLONE) {\n this.#disableStructuredClone();\n }\n\n if (name === ATTR_AUTO_SYNC) {\n this.autoSync = this.hasAttribute(ATTR_AUTO_SYNC) ? this.getAttribute(ATTR_AUTO_SYNC) : true;\n }\n\n if (name === ATTR_SRC) {\n const src = (this.getAttribute(ATTR_SRC) || '').trim();\n this.src$.set(src);\n if (this.shadowEnv.isReady) {\n this.#importScript?.run();\n }\n }\n }\n\n start(): Promise<ShadowEnv> {\n if (!this.#started) {\n this.#shouldDestroy = false;\n\n this.shadowEnv.view ??= ComponentContext.get(this.ns);\n\n if (this.shadowEnv.envProxy == null) {\n const envProxy = readBooleanAttribute(this, ATTR_LOCAL) ? new LocalShadowObjectEnv() : new RemoteWorkerEnv();\n this.shadowEnv.envProxy = envProxy;\n this.#disableStructuredClone();\n }\n\n this.#started = true;\n }\n\n return this.shadowEnv.ready();\n }\n\n destroy() {\n this.#autoSync?.destroy();\n this.#importScript?.destroy();\n destroySignal(this.isConnected$, this.autoSync$, this.src$);\n this.shadowEnv.envProxy = undefined;\n this.shadowEnv.destroy();\n }\n\n #deferDestroy() {\n // NOTE The destruction is halted until the next microtask\u2014but a reconnect (adding the element back to the DOM before the next microtask)\n // cannot stop this process, and that's okay. Once destroyed, it's destroyed forever.\n if (!this.#shouldDestroy) {\n this.#shouldDestroy = true;\n queueMicrotask(() => {\n if (this.#shouldDestroy) {\n this.destroy();\n }\n });\n }\n }\n\n #createAutoSyncEffect() {\n this.#autoSync = createEffect(() => {\n if (this.isConnected$.get()) {\n const autoSync = (this.autoSync$.get() || ShaeWorkerElement.DefaultAutoSync).trim().toLowerCase();\n let delay;\n\n if (['true', 'yes', 'on', 'frame', 'auto-sync'].includes(autoSync)) {\n if (this.logger.isDebug) {\n this.logger.debug('auto-sync', autoSync, this);\n }\n this.frameLoop.start(this);\n return () => {\n this.frameLoop.stop(this);\n };\n } else if (autoSync.toLowerCase().endsWith('fps')) {\n const fps = parseInt(autoSync, 10);\n if (fps > 0) {\n delay = Math.floor(1000 / fps);\n } else if (this.logger.isWarn) {\n this.logger.warn(`invalid auto-sync value: ${autoSync}`);\n }\n } else {\n delay = parseInt(autoSync, 10);\n if (isNaN(delay)) {\n delay = undefined;\n if (!['false', 'no', 'off'].includes(autoSync)) {\n this.logger.error(`invalid auto-sync value: ${autoSync}`);\n }\n }\n }\n\n if (delay !== undefined && delay > 0) {\n if (this.logger.isDebug) {\n this.logger.debug('auto-sync interval (ms)', delay, this);\n }\n const id = setInterval(() => {\n this.syncShadowObjects();\n }, delay);\n return () => {\n clearInterval(id);\n };\n } else if (this.logger.isDebug) {\n this.logger.debug('auto-sync off', this);\n }\n }\n }, [this.autoSync$, this.isConnected$]);\n }\n\n #disableStructuredClone() {\n const env = this.shadowEnv.envProxy as LocalShadowObjectEnv;\n if (env?.isLocalEnv) {\n env.disableStructuredClone = this.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,SAAS;AAC9B,eAAK,OAAO,MAAM,iBAAiB,IAAI;AAAA,QACzC;AAAA,MACF;AAAA,IACF,GAAG,CAAC,KAAK,WAAW,KAAK,YAAY,CAAC;AAAA,EACxC;AAAA,EAEA,0BAA0B;AACxB,UAAM,MAAM,KAAK,UAAU;AAC3B,QAAI,KAAK,YAAY;AACnB,UAAI,yBAAyB,KAAK,aAAa,wBAAwB;AAAA,IACzE;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["import {on} from '@spearwolf/eventize';\nimport {batch, createEffect, createSignal, destroySignal, Effect, hibernate} from '@spearwolf/signalize';\nimport type {ExposeHandle} from '../model-context/exposeShadowEnvsToModelContext.js';\nimport {readBooleanAttribute, readListAttribute, readNumberAttribute} from '../utils/attr-utils.js';\nimport {ConsoleLogger} from '../utils/ConsoleLogger.js';\nimport {FrameLoop} from '../utils/FrameLoop.js';\nimport {ComponentContext} from '../view/ComponentContext.js';\nimport {LocalShadowObjectEnv} from '../view/LocalShadowObjectEnv.js';\nimport {RemoteWorkerEnv, type RemoteWorkerEnvOptions} from '../view/RemoteWorkerEnv.js';\nimport {ShadowEnv, ShadowEnvDestroyedError} from '../view/ShadowEnv.js';\nimport {\n ATTR_AUTO_SYNC,\n ATTR_CHANGE_TRAIL_TIMEOUT,\n ATTR_CONFIGURE_TIMEOUT,\n ATTR_DESTROY_TIMEOUT,\n ATTR_EXPOSE_TO_MODEL_CONTEXT,\n ATTR_INSPECT_TIMEOUT,\n ATTR_LOAD_TIMEOUT,\n ATTR_LOCAL,\n ATTR_NO_AUTOSTART,\n ATTR_NO_STRUCTURED_CLONE,\n ATTR_REDACT_PROPS,\n ATTR_SRC,\n} from './constants.js';\nimport {ensureDisplayContentsRule} from './displayContentsRule.js';\nimport {ShaeElement} from './ShaeElement.js';\n\nconst WorkerTimeoutAttributes: [keyof RemoteWorkerEnvOptions, string][] = [\n ['loadTimeout', ATTR_LOAD_TIMEOUT],\n ['configureTimeout', ATTR_CONFIGURE_TIMEOUT],\n ['changeTrailTimeout', ATTR_CHANGE_TRAIL_TIMEOUT],\n ['inspectTimeout', ATTR_INSPECT_TIMEOUT],\n ['destroyTimeout', ATTR_DESTROY_TIMEOUT],\n];\n\n/**\n * The one place the `auto-sync` spelling rule lives: a string is trimmed and lower-cased,\n * and anything else is read as a flag \u2014 a truthy value asks for the frame default, a falsy\n * one for no syncing at all. Every write into `autoSync$` this element makes goes through\n * here, so the canonical spelling does not depend on which write ran first.\n */\nfunction normaliseAutoSync(value: unknown): string {\n if (typeof value !== 'string') {\n return value ? ShaeWorkerElement.DefaultAutoSync : 'no';\n }\n return value.trim().toLowerCase();\n}\n\n/** One element's share of the page's model-context registration: the signal that ends it, the handle it resolves to. */\ninterface ModelContextExposure {\n controller: AbortController;\n handle: Promise<ExposeHandle>;\n}\n\nexport class ShaeWorkerElement extends ShaeElement {\n static override observedAttributes = [\n ...ShaeElement.observedAttributes,\n ATTR_LOCAL,\n ATTR_SRC,\n ATTR_NO_STRUCTURED_CLONE,\n ATTR_AUTO_SYNC,\n ATTR_EXPOSE_TO_MODEL_CONTEXT,\n ];\n\n static DefaultAutoSync = 'frame';\n\n readonly isShaeWorkerElement = true;\n\n readonly shadowEnv = new ShadowEnv();\n\n readonly #logger = new ConsoleLogger('ShaeWorkerElement');\n\n /** The logger this element reports through. */\n get logger(): ConsoleLogger {\n return this.#logger;\n }\n\n autostart = true;\n\n isConnected$ = createSignal(false);\n autoSync$ = createSignal(ShaeWorkerElement.DefaultAutoSync);\n src$ = createSignal('');\n\n #started = false;\n\n #autoSync?: Effect;\n #importScript?: Effect;\n\n #modelContextExposure?: ModelContextExposure | undefined;\n\n /** The `redact-props` attribute as a list of property names, read as it stands right now. */\n get redactProps(): string[] {\n return readListAttribute(this, ATTR_REDACT_PROPS);\n }\n\n /**\n * This element's share of the page's model-context registration, while it has one: a promise\n * of the `ExposeHandle`, resolving once the tools are on the platform (`available: false` where\n * there is none) and rejecting with what `registerTool()` rejected with. `undefined` without\n * the `expose-to-model-context` attribute, before the first connect, and after a teardown.\n */\n get modelContextExposure(): Promise<ExposeHandle> | undefined {\n return this.#modelContextExposure?.handle;\n }\n\n /**\n * Points the environment at the namespace this element names.\n *\n * It hangs on `ns$`, which belongs to the base class and outlives this element's teardown, so\n * the handle is kept and released by hand \u2014 a listener left on a living signal is a listener the\n * global signal queue goes on holding, and with it this element.\n */\n #envViewBinding?: (() => void) | undefined;\n\n /**\n * Take the subscriptions up. Runs exactly once for this element, on the first connect.\n *\n * The return that `restore()` stands for on `<shae-ent>` and `<shae-prop>` does not exist here:\n * `connectedCallback` turns a torn-down `<shae-worker>` away, so nothing ever calls this a second\n * time.\n *\n * One path runs ahead of it, and it is the only one: `start()` is public, and an element started\n * by hand while it is out of the document builds its environment before anything below is\n * listening. Two things are lost there and stay lost, because both are moments rather than\n * values, and there is no honest way to replay a moment that has passed:\n *\n * - the `contextcreated` \u2014 and, should the environment lose its connection first, the\n * `contextlost` \u2014 DOM event for that environment. `ShadowEnv.ContextCreated` fires once, with\n * nobody on the element listening for it; re-dispatching it from here would announce as new an\n * environment that has been up for a while.\n * - the namespace the environment points at, where `ns` changed between that `start()` and the\n * first connect. `start()` resolves the view once with `??=`, the binding below only reacts to\n * *changes*, and the change already happened. `shadowEnv.view` then names the context of the\n * namespace the element carried when it was started. A write of `ns` after the first connect\n * moves it, as it always does.\n *\n * A `<shae-worker>` that connects before it starts \u2014 the ordinary way, and the only way the\n * declarative form has \u2014 meets neither. The import of `src` is the one case of this shape that\n * *is* caught up, at the end of this method, because a pending import is a value and not a\n * moment.\n */\n protected override restore(): void {\n super.restore();\n\n this.#envViewBinding = this.ns$.onChange((ns) => {\n this.shadowEnv.view = ComponentContext.get(ns);\n });\n\n on(this.shadowEnv, ShadowEnv.ContextCreated, () => {\n this.#importScript?.run();\n this.dispatchEvent(\n new CustomEvent(ShadowEnv.ContextCreated.toLowerCase(), {\n bubbles: false,\n detail: {shadowEnv: this.shadowEnv},\n }),\n );\n });\n\n on(this.shadowEnv, ShadowEnv.ContextLost, () => {\n this.dispatchEvent(\n new CustomEvent(ShadowEnv.ContextLost.toLowerCase(), {\n bubbles: false,\n detail: {shadowEnv: this.shadowEnv},\n }),\n );\n });\n\n on(this.shadowEnv, ShadowEnv.ProxyFailed, (reason: unknown) => {\n this.dispatchEvent(\n new CustomEvent(ShadowEnv.ProxyFailed.toLowerCase(), {\n bubbles: false,\n detail: {shadowEnv: this.shadowEnv, reason},\n }),\n );\n });\n\n on(this.shadowEnv, ShadowEnv.SyncFailed, (reason: unknown, changeTrail: unknown) => {\n this.dispatchEvent(\n new CustomEvent(ShadowEnv.SyncFailed.toLowerCase(), {\n bubbles: false,\n detail: {shadowEnv: this.shadowEnv, reason, changeTrail},\n }),\n );\n });\n\n this.autoSync$.onChange((sVal) => this.#reflectAutoSync(sVal));\n\n // the catch-up half of `restore()`: the signal carries the canonical spelling, and this is\n // what puts it on the attribute \u2014 `auto-sync=\"YES\"` is what an author writes, `auto-sync=\"yes\"`\n // is what the element syncs on, and a reader of the DOM sees the second\n this.#reflectAutoSync(this.autoSync$.value);\n\n // no catch-up for the namespace binding, and that is deliberate: the environment gets its view\n // from `start()`, which resolves the namespace at the one moment it needs it. Resolving it here\n // would build a `ComponentContext` for every `<shae-worker>` that has merely been connected,\n // and a context that exists is a context entities join\n this.#createAutoSyncEffect();\n this.#createImportScriptEffect();\n\n // a `src` that arrived while the environment was already up \u2014 only reachable through a\n // `start()` made by hand on an element outside the document \u2014 has nothing that would import it:\n // the effect is built without an autorun, and both callers that run it were registered a few\n // lines above. The same test `attributeChangedCallback` makes for `src`\n if (this.shadowEnv.isReady) {\n this.#importScript?.run();\n }\n }\n\n #reflectAutoSync(sVal: string): void {\n this.reflectAttribute(ATTR_AUTO_SYNC, () => {\n const hasAttr = this.hasAttribute(ATTR_AUTO_SYNC);\n const attrVal = hasAttr ? this.getAttribute(ATTR_AUTO_SYNC) : undefined;\n\n if (sVal === ShaeWorkerElement.DefaultAutoSync) {\n if (hasAttr && attrVal !== sVal) {\n this.setAttribute(ATTR_AUTO_SYNC, sVal);\n }\n } else if (attrVal !== sVal) {\n this.setAttribute(ATTR_AUTO_SYNC, sVal);\n }\n });\n }\n\n #createImportScriptEffect() {\n this.#importScript = createEffect(\n () => {\n const src = this.src$.get();\n if (src) {\n this.importScript(src).catch(this.#onUnobservedRejection);\n }\n },\n {autorun: false},\n );\n }\n\n /**\n * Both {@link ShaeWorkerElement.start} and {@link ShaeWorkerElement.importScript} await\n * {@link ShadowEnv.ready}, which rejects once the environment is destroyed \u2014 the normal\n * outcome for an element that connects and disconnects within the same task. Nothing in the\n * element waits on those promises, so the rejection has to end here instead of surfacing as\n * an unhandled rejection in the browser or as a hard failure in a test runner.\n */\n #onUnobservedRejection = (error: unknown) => {\n if (error instanceof ShadowEnvDestroyedError) return;\n this.logger.error('shadowEnv failed', error);\n };\n\n get shouldAutostart(): boolean {\n return this.autostart && !readBooleanAttribute(this, ATTR_NO_AUTOSTART);\n }\n\n get autoSync() {\n return this.autoSync$.value;\n }\n\n set autoSync(val: string | boolean | number) {\n this.autoSync$.set(normaliseAutoSync(val));\n }\n\n get frameLoop(): FrameLoop {\n return FrameLoop.get();\n }\n\n /**\n * The frameLoop (if activated) calls this method on every frame\n */\n [FrameLoop.OnFrame]() {\n this.syncShadowObjects();\n }\n\n async importScript(src: URL | string): Promise<ShaeWorkerElement> {\n if (!src) {\n throw new Error('src is blank');\n }\n const shadowEnv = await this.shadowEnv.ready();\n this.logger.info('shadowEnv importScript:', src, {shadowEnv});\n // ready() only vouches for the proxy at the moment it resolves; a teardown can slip in\n // between that microtask and this line\n const envProxy = shadowEnv.envProxy;\n if (envProxy == null) {\n throw new ShadowEnvDestroyedError();\n }\n\n await envProxy.importScript(src);\n return this;\n }\n\n override connectedCallback() {\n // the whole body outside any reactive context of the caller \u2014 same reason as in\n // `ShaeLifecycleElement.connectedCallback`, and the frames nest without trouble\n hibernate(() => {\n // this element does not come back, and the refusal has to stand in front of `super`: the base\n // takes an element's subscriptions up there, and for a torn-down one there is nothing to take\n // up \u2014 the teardown took the environment with it, and an environment cannot be rebuilt around\n // a proxy that is gone. A `<shae-worker>` that is needed again is a new one.\n //\n // How the element renders is a separate question from whether it still listens, so the rule\n // is installed before the refusal returns\n if (this.isDestroyed) {\n ensureDisplayContentsRule(this.getRootNode(), this.localName);\n return;\n }\n\n super.connectedCallback();\n\n batch(() => {\n const autoSync = this.getAttribute(ATTR_AUTO_SYNC);\n if (autoSync != null) {\n this.autoSync = autoSync;\n }\n this.isConnected$.set(true);\n });\n if (this.shouldAutostart) {\n this.start().catch(this.#onUnobservedRejection);\n }\n this.#syncModelContextExposure();\n });\n }\n\n override disconnectedCallback() {\n this.isConnected$.set(false);\n super.disconnectedCallback();\n }\n\n override attributeChangedCallback(name: string) {\n // the signals of this class are destroyed, so an attribute write would land in a value that\n // notifies nobody \u2014 and there is no return that would ever read it back\n if (this.isDestroyed) return;\n\n super.attributeChangedCallback(name);\n\n if (name === ATTR_LOCAL) {\n this.#refuseLocalChange();\n }\n\n if (name === ATTR_NO_STRUCTURED_CLONE) {\n this.#disableStructuredClone();\n }\n\n if (name === ATTR_AUTO_SYNC) {\n this.autoSync = this.getAttribute(ATTR_AUTO_SYNC) ?? true;\n }\n\n if (name === ATTR_SRC) {\n const src = (this.getAttribute(ATTR_SRC) || '').trim();\n this.src$.set(src);\n if (this.shadowEnv.isReady) {\n this.#importScript?.run();\n }\n }\n\n if (name === ATTR_EXPOSE_TO_MODEL_CONTEXT) {\n this.#syncModelContextExposure();\n }\n }\n\n /**\n * The timeout attributes, read at the one moment they are needed: when the worker environment\n * is built. An attribute that is not there is left out, so the environment keeps its default,\n * and a value the environment does not accept is reported there. They are not observed \u2014\n * setting one afterwards changes nothing about an environment that already exists, and a\n * `local` element builds no worker environment at all, so they do nothing there.\n */\n #readWorkerTimeouts(): RemoteWorkerEnvOptions {\n const options: RemoteWorkerEnvOptions = {};\n\n for (const [key, attr] of WorkerTimeoutAttributes) {\n const value = readNumberAttribute(this, attr);\n if (value !== undefined) options[key] = value;\n }\n\n return options;\n }\n\n start(): Promise<ShadowEnv> {\n if (!this.#started) {\n this.shadowEnv.view ??= ComponentContext.get(this.ns);\n\n if (this.shadowEnv.envProxy == null) {\n const envProxy = readBooleanAttribute(this, ATTR_LOCAL)\n ? new LocalShadowObjectEnv()\n : new RemoteWorkerEnv(this.#readWorkerTimeouts());\n this.shadowEnv.envProxy = envProxy;\n this.#disableStructuredClone();\n }\n\n this.#started = true;\n }\n\n return this.shadowEnv.ready();\n }\n\n /**\n * Tear this element down \u2014 for good.\n *\n * The effects and signals below belong to the element alone, so the element is what decides\n * whether they have already been released; the guard for that sits in\n * `ShaeLifecycleElement.destroy()`, which has already set the flag by the time this runs. Here\n * that matters more than anywhere else: `shadowEnv.destroy()` dispatches a `contextlost`\n * `CustomEvent` on this element on its way out, and a listener on it that reaches back into\n * `destroy()` finds the flag down and turns around instead of tearing the same environment down\n * a second time.\n *\n * Unlike `<shae-ent>` and `<shae-prop>`, this teardown is final: it destroys the signals and\n * takes the environment down with them, and neither comes back. `connectedCallback` turns a\n * returning element away rather than handing it a half of what it had, which is what makes\n * {@link ShaeWorkerElement.restore} a method that runs once and never again.\n */\n protected override teardown() {\n this.#leaveModelContextExposure();\n\n this.#envViewBinding?.();\n this.#envViewBinding = undefined;\n\n this.#autoSync?.destroy();\n this.#importScript?.destroy();\n destroySignal(this.isConnected$, this.autoSync$, this.src$);\n this.shadowEnv.envProxy = undefined;\n this.shadowEnv.destroy();\n\n super.teardown();\n }\n\n #createAutoSyncEffect() {\n this.#autoSync = createEffect(() => {\n if (this.isConnected$.get()) {\n const autoSync = normaliseAutoSync(this.autoSync$.get() || ShaeWorkerElement.DefaultAutoSync);\n let delay;\n\n if (['true', 'yes', 'on', 'frame', 'auto-sync'].includes(autoSync)) {\n this.logger.debug('auto-sync', autoSync, this);\n this.frameLoop.start(this);\n return () => {\n this.frameLoop.stop(this);\n };\n } else if (autoSync.endsWith('fps')) {\n const fps = parseInt(autoSync, 10);\n if (fps > 0) {\n delay = Math.floor(1000 / fps);\n } else {\n this.logger.warn(`invalid auto-sync value: ${autoSync}`);\n }\n } else {\n delay = parseInt(autoSync, 10);\n if (isNaN(delay)) {\n delay = undefined;\n if (!['false', 'no', 'off'].includes(autoSync)) {\n this.logger.error(`invalid auto-sync value: ${autoSync}`);\n }\n }\n }\n\n if (delay !== undefined && delay > 0) {\n this.logger.debug('auto-sync interval (ms)', delay, this);\n const id = setInterval(() => {\n this.syncShadowObjects();\n }, delay);\n return () => {\n clearInterval(id);\n };\n } else {\n this.logger.debug('auto-sync off', this);\n }\n }\n }, [this.autoSync$, this.isConnected$]);\n }\n\n #disableStructuredClone() {\n const env = this.shadowEnv.envProxy as LocalShadowObjectEnv;\n if (env?.isLocalEnv) {\n env.disableStructuredClone = this.hasAttribute(ATTR_NO_STRUCTURED_CLONE);\n }\n }\n\n /**\n * `local` picks the environment kind once, at `start()`. The proxy, its kernel and its\n * entities all belong to the side they were built on, and there is no way to move them onto\n * the other one afterwards \u2014 a later write to this attribute is refused, not carried out.\n *\n * A throw from this reaction would not reach the caller of `setAttribute` either way: per spec,\n * a Custom Element reaction reports its own exceptions to the global `error` event instead of\n * propagating them synchronously, so a `try`/`catch` around the write would catch nothing. The\n * refusal writes the attribute back through `reflectAttribute`, the one path this element uses\n * to write its own attributes from inside, and reports the refusal separately through the\n * `ConsoleLogger`. `logger.error` and not `logger.warn`: `logger.error` always prints, where\n * `logger.warn` is gated behind `isWarn`, which is off outside `localhost`, and a refusal that\n * goes silent there is exactly what this call needs to avoid.\n *\n * The write back re-enters `attributeChangedCallback` once, where the attribute now matches\n * the effective state and the check below returns before logging again. On an element built\n * and started by hand while it was never in the document, that write is parked until the first\n * connect (see `reflectAttribute`), while the log line above runs immediately.\n */\n #refuseLocalChange(): void {\n const envProxy = this.shadowEnv.envProxy;\n if (envProxy == null) return;\n\n const isLocalEnv = Boolean((envProxy as LocalShadowObjectEnv).isLocalEnv);\n if (readBooleanAttribute(this, ATTR_LOCAL) === isLocalEnv) return;\n\n this.logger.error(\n `the \"local\" attribute cannot change once the shadowEnv is built; it is reset to ${\n isLocalEnv ? 'the bare \"local\" form' : 'its absence'\n } \u2014 build a new <shae-worker> element to switch environments`,\n );\n\n this.reflectAttribute(ATTR_LOCAL, () => {\n if (isLocalEnv) {\n this.setAttribute(ATTR_LOCAL, '');\n } else {\n this.removeAttribute(ATTR_LOCAL);\n }\n });\n }\n /**\n * Joins or leaves the page's model-context registration, whichever the attribute and the\n * element's state ask for. The attribute is a truthy attribute like `local`; the join waits\n * for a connect, because an element that is never connected has no environment to expose, and\n * it ends with the teardown. `redact-props` is not watched: the share reads it at every call.\n */\n #syncModelContextExposure(): void {\n const wanted = !this.isDestroyed && this.isConnected && readBooleanAttribute(this, ATTR_EXPOSE_TO_MODEL_CONTEXT);\n if (wanted) {\n this.#joinModelContextExposure();\n } else {\n this.#leaveModelContextExposure();\n }\n }\n\n /**\n * The share is an ordinary call of `exposeShadowEnvsToModelContext()` with two live rules:\n * this element's namespace, and the names its `redact-props` attribute carries at the moment\n * a tool asks. The function comes in through a dynamic import, and that is the whole reason\n * this element can carry the attribute at all -- a static import would pull the model-context\n * layer into every consumer of `<shae-worker>`, and the layer is meant to stay out of\n * `index.ts` and the worker bundle. The single-file bundle inlines the import; the lib layout\n * keeps the modules apart. A leave before the import is back aborts the signal the call is\n * made with, and the function registers nothing for an aborted signal.\n */\n #joinModelContextExposure(): void {\n if (this.#modelContextExposure !== undefined) return;\n\n const controller = new AbortController();\n const handle = import('../model-context/exposeShadowEnvsToModelContext.js').then(({exposeShadowEnvsToModelContext}) =>\n exposeShadowEnvsToModelContext({\n signal: controller.signal,\n namespaces: (ns) => ns === this.ns,\n redactProps: (name) => this.redactProps.includes(name),\n }),\n );\n this.#modelContextExposure = {controller, handle};\n\n // the rejection reaches whoever awaits `modelContextExposure` as well; this makes sure it is heard when nobody does\n handle.catch((error) => this.logger.error('expose-to-model-context: registering the tools failed', error));\n }\n\n #leaveModelContextExposure(): void {\n const exposure = this.#modelContextExposure;\n if (exposure === undefined) return;\n this.#modelContextExposure = undefined;\n exposure.controller.abort();\n }\n}\n"],
5
+ "mappings": "AAAA,SAAQ,UAAS;AACjB,SAAQ,OAAO,cAAc,cAAc,eAAe,QAAQ,iBAAgB;AAElF,SAAQ,sBAAsB,mBAAmB,2BAA0B;AAC3E,SAAQ,qBAAoB;AAC5B,SAAQ,iBAAgB;AACxB,SAAQ,wBAAuB;AAC/B,SAAQ,4BAA2B;AACnC,SAAQ,uBAAmD;AAC3D,SAAQ,WAAW,+BAA8B;AACjD;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,OACK;AACP,SAAQ,iCAAgC;AACxC,SAAQ,mBAAkB;AAE1B,MAAM,0BAAoE;AAAA,EACxE,CAAC,eAAe,iBAAiB;AAAA,EACjC,CAAC,oBAAoB,sBAAsB;AAAA,EAC3C,CAAC,sBAAsB,yBAAyB;AAAA,EAChD,CAAC,kBAAkB,oBAAoB;AAAA,EACvC,CAAC,kBAAkB,oBAAoB;AACzC;AAQA,SAAS,kBAAkB,OAAwB;AACjD,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO,QAAQ,kBAAkB,kBAAkB;AAAA,EACrD;AACA,SAAO,MAAM,KAAK,EAAE,YAAY;AAClC;AAQO,MAAM,0BAA0B,YAAY;AAAA,EAA5C;AAAA;AAYL,SAAS,sBAAsB;AAE/B,SAAS,YAAY,IAAI,UAAU;AAEnC,SAAS,UAAU,IAAI,cAAc,mBAAmB;AAOxD,qBAAY;AAEZ,wBAAe,aAAa,KAAK;AACjC,qBAAY,aAAa,kBAAkB,eAAe;AAC1D,gBAAO,aAAa,EAAE;AAEtB,oBAAW;AA+JX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kCAAyB,CAAC,UAAm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4BAA4B;AAC/G,QAAI,QAAQ;AACV,WAAK,0BAA0B;AAAA,IACjC,OAAO;AACL,WAAK,2BAA2B;AAAA,IAClC;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYA,4BAAkC;AAChC,QAAI,KAAK,0BAA0B,OAAW;AAE9C,UAAM,aAAa,IAAI,gBAAgB;AACvC,UAAM,SAAS,OAAO,oDAAoD,EAAE;AAAA,MAAK,CAAC,EAAC,+BAA8B,MAC/G,+BAA+B;AAAA,QAC7B,QAAQ,WAAW;AAAA,QACnB,YAAY,CAAC,OAAO,OAAO,KAAK;AAAA,QAChC,aAAa,CAAC,SAAS,KAAK,YAAY,SAAS,IAAI;AAAA,MACvD,CAAC;AAAA,IACH;AACA,SAAK,wBAAwB,EAAC,YAAY,OAAM;AAGhD,WAAO,MAAM,CAAC,UAAU,KAAK,OAAO,MAAM,yDAAyD,KAAK,CAAC;AAAA,EAC3G;AAAA,EAEA,6BAAmC;AACjC,UAAM,WAAW,KAAK;AACtB,QAAI,aAAa,OAAW;AAC5B,SAAK,wBAAwB;AAC7B,aAAS,WAAW,MAAM;AAAA,EAC5B;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,16 +1,25 @@
1
1
  export declare const RequestEntParentEventName = "shaeRequestEntParent";
2
2
  export declare const ReRequestEntParentEventName = "shaeReRequestEntParent";
3
+ export declare const ReRequestEntHostEventName = "shaeReRequestEntHost";
3
4
  export declare const SHAE_WORKER = "shae-worker";
4
5
  export declare const SHAE_ENT = "shae-ent";
5
6
  export declare const SHAE_PROP = "shae-prop";
6
7
  export declare const ATTR_TOKEN = "token";
7
8
  export declare const ATTR_FORWARD_CUSTOM_EVENTS = "forward-custom-events";
9
+ export declare const ATTR_AUTO_DESTRUCT = "auto-destruct";
8
10
  export declare const ATTR_NS = "ns";
9
11
  export declare const ATTR_LOCAL = "local";
10
12
  export declare const ATTR_NO_AUTOSTART = "no-autostart";
11
13
  export declare const ATTR_NO_STRUCTURED_CLONE = "no-structured-clone";
12
14
  export declare const ATTR_AUTO_SYNC = "auto-sync";
13
15
  export declare const ATTR_SRC = "src";
16
+ export declare const ATTR_LOAD_TIMEOUT = "load-timeout";
17
+ export declare const ATTR_CONFIGURE_TIMEOUT = "configure-timeout";
18
+ export declare const ATTR_CHANGE_TRAIL_TIMEOUT = "change-trail-timeout";
19
+ export declare const ATTR_INSPECT_TIMEOUT = "inspect-timeout";
20
+ export declare const ATTR_DESTROY_TIMEOUT = "destroy-timeout";
21
+ export declare const ATTR_EXPOSE_TO_MODEL_CONTEXT = "expose-to-model-context";
22
+ export declare const ATTR_REDACT_PROPS = "redact-props";
14
23
  export declare const ATTR_NAME = "name";
15
24
  export declare const ATTR_VALUE = "value";
16
25
  export declare const ATTR_TYPE = "type";
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/elements/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,yBAAyB,yBAAyB,CAAC;AAChE,eAAO,MAAM,2BAA2B,2BAA2B,CAAC;AAEpE,eAAO,MAAM,WAAW,gBAAgB,CAAC;AACzC,eAAO,MAAM,QAAQ,aAAa,CAAC;AACnC,eAAO,MAAM,SAAS,cAAc,CAAC;AAGrC,eAAO,MAAM,UAAU,UAAU,CAAC;AAClC,eAAO,MAAM,0BAA0B,0BAA0B,CAAC;AAGlE,eAAO,MAAM,OAAO,OAAO,CAAC;AAG5B,eAAO,MAAM,UAAU,UAAU,CAAC;AAClC,eAAO,MAAM,iBAAiB,iBAAiB,CAAC;AAChD,eAAO,MAAM,wBAAwB,wBAAwB,CAAC;AAC9D,eAAO,MAAM,cAAc,cAAc,CAAC;AAC1C,eAAO,MAAM,QAAQ,QAAQ,CAAC;AAG9B,eAAO,MAAM,SAAS,SAAS,CAAC;AAChC,eAAO,MAAM,UAAU,UAAU,CAAC;AAClC,eAAO,MAAM,SAAS,SAAS,CAAC;AAChC,eAAO,MAAM,Y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