dsh-ptc-plus 0.4.1 → 0.4.2

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 (53) hide show
  1. package/README.en.md +6 -10
  2. package/README.md +6 -10
  3. package/client.js +262 -31
  4. package/compiler-core.cjs +132 -130
  5. package/compiler-core.cjs.map +3 -3
  6. package/docs/README.md +1 -0
  7. package/docs/adr/0023-global-user-bindings.md +6 -6
  8. package/docs/adr/0025-use-versioned-logical-binding-identities.md +3 -3
  9. package/docs/adr/0027-run-the-session-kernel-in-a-killable-helper-process.md +5 -5
  10. package/docs/architecture.md +9 -5
  11. package/docs/client-ui.md +1 -1
  12. package/docs/durability-design.md +6 -3
  13. package/docs/installation.md +4 -4
  14. package/docs/runtime-reference.md +5 -1
  15. package/docs/stateful-binding-updates-proposal.md +8 -4
  16. package/docs/user-bindings.en.md +5 -3
  17. package/docs/user-bindings.md +4 -2
  18. package/docs/verification-optimization-work.md +41 -0
  19. package/docs/verification.md +15 -1
  20. package/internal/async-local-storage-intrinsics.js +38 -0
  21. package/internal/binding-declaration-contract.js +8 -0
  22. package/internal/binding-source-analysis.js +381 -64
  23. package/internal/binding-update-policy.js +7 -1
  24. package/internal/cell-analysis.js +21 -8
  25. package/internal/compiler-intrinsics.js +9 -43
  26. package/internal/compiler-module-links.js +7 -4
  27. package/internal/dynamic-environment-integration.js +8 -4
  28. package/internal/dynamic-environment-runtime.js +24 -3
  29. package/internal/dynamic-native-calls.js +4 -1
  30. package/internal/dynamic-native-runtime.js +15 -1
  31. package/internal/failure-reporting.js +38 -30
  32. package/internal/isolated-worker.js +17 -10
  33. package/internal/kernel-worker.js +493 -331
  34. package/internal/module-compilation.js +5 -4
  35. package/internal/module-transform-contract.js +32 -2
  36. package/internal/record-utils.js +24 -15
  37. package/internal/repl-value-observer.js +6 -3
  38. package/internal/runtime-intrinsics.js +101 -0
  39. package/internal/session-cell-executor.js +2 -1
  40. package/internal/session-journal-schema.js +30 -13
  41. package/internal/session-journal.js +19 -4
  42. package/internal/session-runtime.js +1 -0
  43. package/internal/source-position-map.js +19 -0
  44. package/internal/stateful-root-compiler.js +3 -1
  45. package/internal/typescript-transform.js +4 -2
  46. package/internal/user-binding-console-worker.js +101 -41
  47. package/internal/user-bindings.js +10 -2
  48. package/internal/value-wire.js +101 -71
  49. package/internal/worker-cwd-virtualization.js +80 -53
  50. package/internal/worker-environment.js +20 -0
  51. package/internal/worker-repl-realm.js +134 -0
  52. package/package.json +2 -1
  53. package/src/client-activity.js +8 -1
@@ -0,0 +1,38 @@
1
+ import { AsyncLocalStorage } from 'node:async_hooks'
2
+
3
+ const bind = Function.prototype.call.bind(Function.prototype.bind)
4
+ const defineProperty = Object.defineProperty
5
+ const getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor
6
+ const apply = Reflect.apply
7
+ const nativeGetStore = AsyncLocalStorage.prototype.getStore
8
+ const nativeEnterWith = AsyncLocalStorage.prototype.enterWith
9
+ const nativeRun = AsyncLocalStorage.prototype.run
10
+ const nativeRunDescriptor = getOwnPropertyDescriptor(AsyncLocalStorage.prototype, 'run')
11
+
12
+ function protect(scope) {
13
+ defineProperty(scope, 'getStore', { value: bind(nativeGetStore, scope) })
14
+ defineProperty(scope, 'enterWith', { value: bind(nativeEnterWith, scope) })
15
+ defineProperty(scope, 'run', { value: bind(nativeRun, scope) })
16
+ return scope
17
+ }
18
+
19
+ export function createPrivateAsyncLocalStorage() {
20
+ return protect(new AsyncLocalStorage())
21
+ }
22
+
23
+ export function protectNextAsyncLocalStorageRun(invoke) {
24
+ let scope
25
+ defineProperty(AsyncLocalStorage.prototype, 'run', {
26
+ ...nativeRunDescriptor,
27
+ value: function (...args) {
28
+ scope ??= protect(this)
29
+ return apply(nativeRun, this, args)
30
+ },
31
+ })
32
+ try {
33
+ invoke()
34
+ } finally {
35
+ defineProperty(AsyncLocalStorage.prototype, 'run', nativeRunDescriptor)
36
+ }
37
+ return scope
38
+ }
@@ -0,0 +1,8 @@
1
+ const BINDING_TYPE_NAMESPACE_TOKEN = '__ptcBindingTypes'
2
+
3
+ export function bindingTypeNamespaceToken(source) {
4
+ let token = BINDING_TYPE_NAMESPACE_TOKEN
5
+ let suffix = 0
6
+ while (source.includes(token)) token = `${BINDING_TYPE_NAMESPACE_TOKEN}_${++suffix}`
7
+ return token
8
+ }