dsh-ptc-plus 0.3.2 → 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.
- package/README.en.md +63 -80
- package/README.md +63 -80
- package/assets/ptc-plus-bindings-en.png +0 -0
- package/assets/ptc-plus-bindings-zh.png +0 -0
- package/assets/ptc-plus-repair-en.png +0 -0
- package/assets/ptc-plus-repair-zh.png +0 -0
- package/assets/ptc-plus-repl-workspace-en.png +0 -0
- package/assets/ptc-plus-repl-workspace-zh.png +0 -0
- package/assets/ptc-plus-settings-en.png +0 -0
- package/assets/ptc-plus-settings-zh.png +0 -0
- package/client.js +30827 -742
- package/compiler-amaro.cjs +5 -0
- package/compiler-amaro.cjs.map +6 -0
- package/compiler-asset-124f80c1bba92ff5fe79cfec6e8ad518f476de4a42514cae3919538887f510e8.txt +1 -0
- package/compiler-assets.json +3 -0
- package/compiler-core.cjs +556 -0
- package/compiler-core.cjs.map +6 -0
- package/compiler-platform.cjs +2 -0
- package/compiler-platform.cjs.map +6 -0
- package/compiler-typescript.cjs +388 -0
- package/compiler-typescript.cjs.map +6 -0
- package/docs/README.md +7 -0
- package/docs/adr/0004-declare-program-bindings-at-the-host.md +1 -1
- package/docs/adr/0006-rewrite-module-syntax-with-an-ast.md +5 -3
- package/docs/adr/0007-separate-worker-transport-from-session-semantics.md +1 -1
- package/docs/adr/0009-bound-expensive-acceptance-default.md +2 -0
- package/docs/adr/0010-session-log-derived-recovery-tips.md +59 -5
- package/docs/adr/0011-isolate-the-local-recovery-tip-provider.md +1 -1
- package/docs/adr/0012-preserve-mixed-destructuring-initialization.md +3 -1
- package/docs/adr/0013-isolate-repl-redeclaration-convenience.md +3 -1
- package/docs/adr/0014-persist-cell-rewrite-policy.md +6 -2
- package/docs/adr/0015-preserve-source-positions-through-rewrites.md +1 -1
- package/docs/adr/0016-archive-resolved-review-findings.md +1 -1
- package/docs/adr/0017-track-the-latest-dsh-public-surface.md +49 -0
- package/docs/adr/0018-use-versioned-fixture-for-ab-benchmark.md +3 -3
- package/docs/adr/0019-plugin-settings-and-kill-switch.md +5 -3
- package/docs/adr/0020-optional-cordis-tools-in-ptc-mode.md +2 -2
- package/docs/adr/0021-separate-host-bootstrap-from-session-runtime.md +12 -0
- package/docs/adr/0023-global-user-bindings.md +104 -0
- package/docs/adr/0024-repl-console-observation.md +33 -0
- package/docs/adr/0025-use-versioned-logical-binding-identities.md +119 -0
- package/docs/adr/0026-persist-the-delivery-verdict-against-the-verified-candidate.md +21 -0
- package/docs/adr/0027-run-the-session-kernel-in-a-killable-helper-process.md +37 -0
- package/docs/adr/0028-attach-to-the-host-ptc-execution-seam.md +103 -0
- package/docs/adr/0029-keep-plugin-unavailability-out-of-the-host-agent-lifecycle.md +27 -0
- package/docs/adr/0030-serve-both-typert-codec-generations-from-one-codec.md +27 -0
- package/docs/architecture.md +77 -21
- package/docs/binding-review-placement-design.md +200 -0
- package/docs/capability-projection.md +1 -1
- package/docs/client-ui.md +95 -19
- package/docs/durability-design.md +28 -10
- package/docs/evaluation.md +78 -6
- package/docs/installation.md +41 -6
- package/docs/publishing.md +5 -3
- package/docs/runtime-reference.md +76 -25
- package/docs/semantic-validation.md +29 -0
- package/docs/stateful-binding-updates-proposal.md +759 -0
- package/docs/user-bindings.en.md +66 -0
- package/docs/user-bindings.md +66 -0
- package/docs/value-wire.md +3 -3
- package/docs/verification-optimization-work.md +41 -0
- package/docs/verification.md +71 -0
- package/index.js +369 -92
- package/internal/ast-traversal.js +5 -2
- package/internal/async-local-storage-intrinsics.js +38 -0
- package/internal/binding-declaration-contract.js +8 -0
- package/internal/binding-descriptors.js +1 -0
- package/internal/binding-pattern-traversal.js +25 -0
- package/internal/binding-pattern.js +26 -29
- package/internal/binding-source-analysis.js +708 -0
- package/internal/binding-update-policy.js +72 -0
- package/internal/bounded-worker-round.js +56 -0
- package/internal/callable-definition-environment.js +42 -0
- package/internal/callable-source-catalog.js +129 -0
- package/internal/callable-source-encoding.js +47 -0
- package/internal/callable-source-facts.js +459 -0
- package/internal/callable-source-format.js +2 -0
- package/internal/callable-source-lowering.js +123 -0
- package/internal/cell-analysis-contract.js +25 -0
- package/internal/cell-analysis.js +253 -290
- package/internal/cell-completion.js +15 -0
- package/internal/cell-error.js +7 -0
- package/internal/cell-parser.js +66 -0
- package/internal/cell-rewriter.js +3 -677
- package/internal/commonjs-export-evidence.js +63 -0
- package/internal/commonjs-source-evidence.js +72 -0
- package/internal/compiler-amaro.cjs +2 -0
- package/internal/compiler-compression.js +12 -0
- package/internal/compiler-data.js +58 -0
- package/internal/compiler-descriptors.js +54 -0
- package/internal/compiler-dynamic-cache.js +48 -0
- package/internal/compiler-entry.js +35 -0
- package/internal/compiler-generated-names.js +17 -0
- package/internal/compiler-intrinsics.js +50 -0
- package/internal/compiler-module-links.js +37 -0
- package/internal/compiler-operations.js +61 -0
- package/internal/compiler-platform-factory.js +84 -0
- package/internal/compiler-platform.js +136 -0
- package/internal/compiler-record-roles.js +53 -0
- package/internal/compiler-region-output.js +259 -0
- package/internal/compiler-resource-lowering.js +103 -0
- package/internal/compiler-scope-facts.js +115 -0
- package/internal/compiler-service.js +109 -0
- package/internal/compiler-source-cache.js +32 -0
- package/internal/compiler-source-pieces.js +93 -0
- package/internal/compiler-source-regions.js +132 -0
- package/internal/compiler-storage-source.js +54 -0
- package/internal/compiler-text.js +15 -0
- package/internal/compiler-typescript.cjs +2 -0
- package/internal/config-spec.js +83 -27
- package/internal/cordis-tools-owner.js +130 -21
- package/internal/diagnostic.js +27 -1
- package/internal/direct-surface-owner.js +76 -23
- package/internal/dynamic-binding-evidence.js +16 -0
- package/internal/dynamic-environment-compiler.js +779 -0
- package/internal/dynamic-environment-integration.js +91 -0
- package/internal/dynamic-environment-runtime.js +383 -0
- package/internal/dynamic-native-calls.js +153 -0
- package/internal/dynamic-native-runtime.js +262 -0
- package/internal/dynamic-scope-analysis.js +90 -0
- package/internal/edit-transport-owner.js +27 -2
- package/internal/execution-seam-compat.js +193 -0
- package/internal/failure-reporting.js +136 -28
- package/internal/host-rpc.js +66 -0
- package/internal/isolated-worker.js +555 -0
- package/internal/kernel-child.js +139 -0
- package/internal/kernel-worker.js +1179 -233
- package/internal/language-semantics.js +14 -0
- package/internal/legacy-binding-catalog.js +48 -0
- package/internal/legacy-cell-analysis.js +600 -0
- package/internal/legacy-cell-parser.js +50 -0
- package/internal/legacy-cell-rewriter.js +631 -0
- package/internal/legacy-repl-convenience.js +291 -0
- package/internal/managed-module-operations.js +170 -0
- package/internal/module-compilation.js +322 -0
- package/internal/module-runtime-platform.js +19 -0
- package/internal/module-transform-contract.js +42 -0
- package/internal/native-await-declarations.js +68 -0
- package/internal/native-root-compilation.js +54 -0
- package/internal/native-root-dynamic.js +67 -0
- package/internal/record-utils.js +24 -15
- package/internal/recovery-tips.js +27 -15
- package/internal/rejected-cell-editor.js +13 -8
- package/internal/repl-convenience.js +2 -289
- package/internal/repl-memory-projection.js +81 -12
- package/internal/repl-observation-interest.js +70 -0
- package/internal/repl-rewrite-contract.js +6 -0
- package/internal/repl-scope-normalizer.js +2091 -0
- package/internal/repl-value-observer.js +117 -0
- package/internal/rpc-contract.js +52 -0
- package/internal/runtime-bridge-owner.js +172 -28
- package/internal/runtime-config.js +48 -52
- package/internal/runtime-contexts.js +82 -10
- package/internal/runtime-intrinsics.js +101 -0
- package/internal/runtime-messages.js +111 -0
- package/internal/session-cell-executor.js +402 -87
- package/internal/session-journal-recovery.js +684 -0
- package/internal/session-journal-schema.js +123 -0
- package/internal/session-journal.js +199 -654
- package/internal/session-log-view.js +42 -9
- package/internal/session-runtime.js +257 -95
- package/internal/session-state.js +247 -71
- package/internal/source-position-map.js +230 -71
- package/internal/stateful-module-compiler.js +154 -0
- package/internal/stateful-module-runtime.js +303 -0
- package/internal/stateful-root-compiler.js +600 -0
- package/internal/stateful-root-runtime.js +340 -0
- package/internal/typert-codec-compat.js +28 -0
- package/internal/typescript-transform.js +31 -0
- package/internal/user-binding-authoring.js +70 -0
- package/internal/user-binding-console-worker.js +244 -0
- package/internal/user-binding-console.js +148 -0
- package/internal/user-binding-draft-projection.js +335 -0
- package/internal/user-binding-model-context.js +31 -0
- package/internal/user-binding-runner.js +56 -0
- package/internal/user-bindings-owner.js +1065 -0
- package/internal/user-bindings-store.js +293 -0
- package/internal/user-bindings.js +361 -0
- package/internal/value-wire-schema.js +28 -0
- package/internal/value-wire.js +130 -91
- package/internal/worker-client.js +57 -67
- package/internal/worker-cwd-virtualization.js +80 -53
- package/internal/worker-environment.js +65 -0
- package/internal/worker-output-relay.js +29 -0
- package/internal/worker-repl-realm.js +134 -0
- package/internal/worker-shutdown.js +14 -0
- package/package.json +76 -7
- package/src/client-activity.js +95 -53
- package/src/client-authoring-view.js +580 -0
- package/src/client-binding-review.js +230 -0
- package/src/client-bindings-data.js +29 -0
- package/src/client-catalog.js +127 -0
- package/src/client-code-editor.js +84 -0
- package/src/client-console.js +112 -0
- package/src/client-copy.js +370 -0
- package/src/client-feature-gates.js +62 -0
- package/src/client-host-compat.js +150 -0
- package/src/client-indicator-view.js +267 -0
- package/src/client-repl-view.js +292 -0
- package/src/client-rpc.js +20 -0
- package/src/client-settings-view.js +221 -0
- package/src/client-styles.js +106 -0
- package/src/client-tool-view.js +108 -0
- package/src/client-transport.js +159 -0
- package/src/client-workbench.js +521 -0
- package/src/client.js +233 -615
|
@@ -8,10 +8,13 @@ export function walkAst(node, enter, leave = undefined, context = undefined, par
|
|
|
8
8
|
const entered = enter(node, parent, parentKey, context)
|
|
9
9
|
if (entered === SKIP_AST_CHILDREN) return
|
|
10
10
|
const childContext = entered === undefined ? context : entered
|
|
11
|
-
|
|
11
|
+
const keys = Object.keys(node)
|
|
12
|
+
for (let index = 0; index < keys.length; index++) {
|
|
13
|
+
const key = keys[index]
|
|
12
14
|
if (AST_METADATA_KEYS.has(key)) continue
|
|
15
|
+
const value = node[key]
|
|
13
16
|
if (Array.isArray(value)) {
|
|
14
|
-
for (
|
|
17
|
+
for (let child = 0; child < value.length; child++) walkAst(value[child], enter, leave, childContext, node, key)
|
|
15
18
|
} else {
|
|
16
19
|
walkAst(value, enter, leave, childContext, node, key)
|
|
17
20
|
}
|
|
@@ -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
|
+
}
|
|
@@ -86,6 +86,7 @@ export function normalizeBindingDescriptors(bindings) {
|
|
|
86
86
|
workerDescriptors: Object.freeze(namespaces.map(namespace => Object.freeze({
|
|
87
87
|
global: namespace.global,
|
|
88
88
|
members: namespace.members,
|
|
89
|
+
...(reservedNames.has(namespace.global) ? {} : { shadowable: true }),
|
|
89
90
|
...(namespace.emptyObjectMembers === undefined
|
|
90
91
|
? {}
|
|
91
92
|
: { emptyObjectMembers: namespace.emptyObjectMembers }),
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** Read binding names from Acorn or Babel patterns without compiler dependencies. */
|
|
2
|
+
export function walkBindingPattern(pattern, visit) {
|
|
3
|
+
if (pattern === null || typeof pattern !== 'object') return
|
|
4
|
+
if (pattern.type === 'Identifier') {
|
|
5
|
+
visit(pattern)
|
|
6
|
+
return
|
|
7
|
+
}
|
|
8
|
+
if (pattern.type === 'RestElement') return walkBindingPattern(pattern.argument, visit)
|
|
9
|
+
if (pattern.type === 'AssignmentPattern') return walkBindingPattern(pattern.left, visit)
|
|
10
|
+
if (pattern.type === 'ArrayPattern') {
|
|
11
|
+
for (const element of pattern.elements) walkBindingPattern(element, visit)
|
|
12
|
+
return
|
|
13
|
+
}
|
|
14
|
+
if (pattern.type === 'ObjectPattern') {
|
|
15
|
+
for (const property of pattern.properties) {
|
|
16
|
+
walkBindingPattern(property.type === 'RestElement' ? property.argument : property.value, visit)
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function bindingNodes(pattern) {
|
|
22
|
+
const nodes = []
|
|
23
|
+
walkBindingPattern(pattern, node => nodes.push(node))
|
|
24
|
+
return nodes
|
|
25
|
+
}
|
|
@@ -1,51 +1,48 @@
|
|
|
1
1
|
/** Shared binding-pattern traversal used by cell analysis and REPL policy code. */
|
|
2
|
+
import { types as t } from '@babel/core'
|
|
2
3
|
|
|
3
|
-
export
|
|
4
|
-
if (pattern === null || typeof pattern !== 'object') return
|
|
5
|
-
if (pattern.type === 'Identifier') {
|
|
6
|
-
visit(pattern)
|
|
7
|
-
return
|
|
8
|
-
}
|
|
9
|
-
if (pattern.type === 'RestElement') return walkBindingPattern(pattern.argument, visit)
|
|
10
|
-
if (pattern.type === 'AssignmentPattern') return walkBindingPattern(pattern.left, visit)
|
|
11
|
-
if (pattern.type === 'ArrayPattern') {
|
|
12
|
-
for (const element of pattern.elements) walkBindingPattern(element, visit)
|
|
13
|
-
return
|
|
14
|
-
}
|
|
15
|
-
if (pattern.type === 'ObjectPattern') {
|
|
16
|
-
for (const property of pattern.properties) {
|
|
17
|
-
walkBindingPattern(property.type === 'RestElement' ? property.argument : property.value, visit)
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
4
|
+
export { walkBindingPattern, bindingNodes } from './binding-pattern-traversal.js'
|
|
21
5
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
6
|
+
/** Recognize an actual assignment target through erased expression syntax. */
|
|
7
|
+
export function isWriteIdentifier(path) {
|
|
8
|
+
let selected = path
|
|
9
|
+
while (selected.parentPath?.isObjectProperty() && selected.key === 'value'
|
|
10
|
+
|| selected.parentPath?.isObjectPattern() || selected.parentPath?.isArrayPattern()
|
|
11
|
+
|| selected.parentPath?.isRestElement() && selected.key === 'argument'
|
|
12
|
+
|| selected.parentPath?.isAssignmentPattern() && selected.key === 'left'
|
|
13
|
+
|| selected.parent?.type.startsWith('TS') && selected.key === 'expression'
|
|
14
|
+
|| selected.parentPath?.isParenthesizedExpression() && selected.key === 'expression') selected = selected.parentPath
|
|
15
|
+
const parent = selected.parentPath
|
|
16
|
+
return parent?.isAssignmentExpression() && selected.key === 'left'
|
|
17
|
+
|| parent?.isUpdateExpression() && selected.key === 'argument'
|
|
18
|
+
|| (parent?.isForOfStatement() || parent?.isForInStatement()) && selected.key === 'left'
|
|
26
19
|
}
|
|
27
20
|
|
|
28
21
|
/** Allocate private identifiers outside both source and caller-owned name sets. */
|
|
29
|
-
export function createGeneratedNameAllocator(root, unavailableNames = []) {
|
|
22
|
+
export function createGeneratedNameAllocator(root, unavailableNames = [], { compact = false } = {}) {
|
|
30
23
|
const used = new Set(unavailableNames)
|
|
31
|
-
const seen = new Set()
|
|
32
24
|
const pending = [root]
|
|
33
25
|
while (pending.length > 0) {
|
|
34
26
|
const value = pending.pop()
|
|
35
|
-
if (value === null || typeof value !== 'object'
|
|
36
|
-
|
|
27
|
+
if (value === null || typeof value !== 'object') continue
|
|
28
|
+
if (Array.isArray(value)) {
|
|
29
|
+
for (const item of value) pending.push(item)
|
|
30
|
+
continue
|
|
31
|
+
}
|
|
37
32
|
if (value.type === 'Identifier') used.add(value.name)
|
|
38
|
-
for (const
|
|
39
|
-
|
|
33
|
+
for (const key of t.VISITOR_KEYS[value.type] ?? Object.keys(value)) {
|
|
34
|
+
const child = value[key]
|
|
35
|
+
if (Array.isArray(child)) for (const item of child) pending.push(item)
|
|
40
36
|
else if (child !== null && typeof child === 'object') pending.push(child)
|
|
41
37
|
}
|
|
42
38
|
}
|
|
43
39
|
const sequences = new Map()
|
|
40
|
+
let nextCompact = 0
|
|
44
41
|
return (purpose) => {
|
|
45
42
|
let sequence = sequences.get(purpose) ?? 0
|
|
46
43
|
let name
|
|
47
44
|
do {
|
|
48
|
-
name = `__dsh_ptc_${purpose}_${sequence++}__`
|
|
45
|
+
name = compact ? `__ptc$${(nextCompact++).toString(36)}` : `__dsh_ptc_${purpose}_${sequence++}__`
|
|
49
46
|
} while (used.has(name))
|
|
50
47
|
sequences.set(purpose, sequence)
|
|
51
48
|
used.add(name)
|