@scriptc/compiler 0.0.11 → 0.0.13

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 (97) hide show
  1. package/ambient/scriptc-node-fallback.d.ts +153 -24
  2. package/ambient/scriptc.d.ts +2 -2
  3. package/dist/backend/cc.d.ts +10 -2
  4. package/dist/backend/cc.js +12 -0
  5. package/dist/backend/cc.js.map +1 -1
  6. package/dist/backend/emission/emit-async.js +1 -1
  7. package/dist/backend/emission/emit-exprs.js +235 -64
  8. package/dist/backend/emission/emit-exprs.js.map +1 -1
  9. package/dist/backend/emission/emit-island.js +1 -1
  10. package/dist/backend/emission/emit-shapes.js +1 -1
  11. package/dist/backend/emission/emit-walkers.d.ts +14 -14
  12. package/dist/backend/emission/emit-walkers.js +44 -44
  13. package/dist/backend/emission/emit-walkers.js.map +1 -1
  14. package/dist/backend/emission/emitter.d.ts +3 -3
  15. package/dist/backend/emission/emitter.js +8 -8
  16. package/dist/backend/emission/may-throw.js +1 -1
  17. package/dist/backend/llvm/dyn.d.ts +10 -10
  18. package/dist/backend/llvm/dyn.js +26 -26
  19. package/dist/backend/llvm/dyn.js.map +1 -1
  20. package/dist/backend/llvm/emitter.js +140 -49
  21. package/dist/backend/llvm/emitter.js.map +1 -1
  22. package/dist/backend/llvm/shapes.js +1 -1
  23. package/dist/backend/llvm/walkers.js +2 -2
  24. package/dist/backend/llvm/walkers.js.map +1 -1
  25. package/dist/diagnostics/diagnostic.d.ts +1 -1
  26. package/dist/diagnostics/diagnostic.js +4 -3
  27. package/dist/diagnostics/diagnostic.js.map +1 -1
  28. package/dist/frontend/lowering/crypto-tables.d.ts +7 -0
  29. package/dist/frontend/lowering/crypto-tables.js +139 -0
  30. package/dist/frontend/lowering/crypto-tables.js.map +1 -0
  31. package/dist/frontend/lowering/lib-boundary.js +5 -5
  32. package/dist/frontend/lowering/lib-boundary.js.map +1 -1
  33. package/dist/frontend/lowering/lower-assert.js +12 -12
  34. package/dist/frontend/lowering/lower-assert.js.map +1 -1
  35. package/dist/frontend/lowering/lower-builtins.d.ts +45 -27
  36. package/dist/frontend/lowering/lower-builtins.js +203 -70
  37. package/dist/frontend/lowering/lower-builtins.js.map +1 -1
  38. package/dist/frontend/lowering/lower-calls.d.ts +4 -4
  39. package/dist/frontend/lowering/lower-calls.js +74 -66
  40. package/dist/frontend/lowering/lower-calls.js.map +1 -1
  41. package/dist/frontend/lowering/lower-classes.js +41 -7
  42. package/dist/frontend/lowering/lower-classes.js.map +1 -1
  43. package/dist/frontend/lowering/lower-containers.d.ts +5 -5
  44. package/dist/frontend/lowering/lower-containers.js +19 -19
  45. package/dist/frontend/lowering/lower-containers.js.map +1 -1
  46. package/dist/frontend/lowering/lower-emitter.js +2 -2
  47. package/dist/frontend/lowering/lower-emitter.js.map +1 -1
  48. package/dist/frontend/lowering/lower-exprs.d.ts +7 -7
  49. package/dist/frontend/lowering/lower-exprs.js +227 -119
  50. package/dist/frontend/lowering/lower-exprs.js.map +1 -1
  51. package/dist/frontend/lowering/lower-inspect.js +5 -5
  52. package/dist/frontend/lowering/lower-inspect.js.map +1 -1
  53. package/dist/frontend/lowering/lower-island.js +12 -3
  54. package/dist/frontend/lowering/lower-island.js.map +1 -1
  55. package/dist/frontend/lowering/lower-modules.js +17 -17
  56. package/dist/frontend/lowering/lower-modules.js.map +1 -1
  57. package/dist/frontend/lowering/lower-namespaces.d.ts +11 -1
  58. package/dist/frontend/lowering/lower-namespaces.js +41 -6
  59. package/dist/frontend/lowering/lower-namespaces.js.map +1 -1
  60. package/dist/frontend/lowering/lower-server.d.ts +21 -0
  61. package/dist/frontend/lowering/lower-server.js +278 -23
  62. package/dist/frontend/lowering/lower-server.js.map +1 -1
  63. package/dist/frontend/lowering/lower-stmts.d.ts +1 -1
  64. package/dist/frontend/lowering/lower-stmts.js +195 -34
  65. package/dist/frontend/lowering/lower-stmts.js.map +1 -1
  66. package/dist/frontend/lowering/lower-stream.js +67 -23
  67. package/dist/frontend/lowering/lower-stream.js.map +1 -1
  68. package/dist/frontend/lowering/lowerer.d.ts +31 -13
  69. package/dist/frontend/lowering/lowerer.js +99 -45
  70. package/dist/frontend/lowering/lowerer.js.map +1 -1
  71. package/dist/frontend/lowering/surfaces.d.ts +6 -0
  72. package/dist/frontend/lowering/surfaces.js +78 -2
  73. package/dist/frontend/lowering/surfaces.js.map +1 -1
  74. package/dist/frontend/program.js +1 -1
  75. package/dist/frontend/shared.js +7 -7
  76. package/dist/frontend/shared.js.map +1 -1
  77. package/dist/frontend/types.d.ts +2 -2
  78. package/dist/frontend/types.js +27 -15
  79. package/dist/frontend/types.js.map +1 -1
  80. package/dist/index.js +44 -8
  81. package/dist/index.js.map +1 -1
  82. package/dist/ir/nodes.d.ts +208 -106
  83. package/dist/ir/nodes.js +100 -22
  84. package/dist/ir/nodes.js.map +1 -1
  85. package/dist/ir/validate.js +96 -38
  86. package/dist/ir/validate.js.map +1 -1
  87. package/dist/library/int-infer.js +13 -0
  88. package/dist/library/int-infer.js.map +1 -1
  89. package/dist/library/profile.d.ts +8 -6
  90. package/dist/library/profile.js.map +1 -1
  91. package/dist/library/sidecar-validate.js +1 -1
  92. package/dist/library/sidecar-validate.js.map +1 -1
  93. package/dist/library/sidecar.d.ts +1 -1
  94. package/dist/library/sidecar.js +20 -7
  95. package/dist/library/sidecar.js.map +1 -1
  96. package/package.json +2 -2
  97. package/surface-manifest.json +289 -4
@@ -17,7 +17,7 @@ import { STREAM_API_MEMBERS, STREAM_PROP_MEMBERS, UNDERSCORE_METHODS, lowerStrea
17
17
  import { emitOverrideShapeReason, emitSpecSuperForward, emitterRooted, lowerEmitterSuperCall } from "./lower-emitter.js";
18
18
  import { declSymbolOf } from "./lower-modules.js";
19
19
  import { uniqueSymbolKeyOf } from "./lower-exprs.js";
20
- import { lowerHttpServerNew } from "./lower-server.js";
20
+ import { lowerHttpAgentNew, lowerHttpServerNew } from "./lower-server.js";
21
21
  import { ambientNsRootOf, ambientUndefReadType, ambientUndefVarRootOf, ambientUndefinedFnSymbolOf, fenceEarlyAliasUse, fenceEarlyNsMemberRef, nsMemberIdentOf, nsUndefRead } from "./lower-namespaces.js";
22
22
  import { mixinResultBindingClassOf } from "./lower-mixins.js";
23
23
  /** The KEY symbol behind a LATE-BOUND (`__@name@id`) property: resolved
@@ -474,6 +474,32 @@ export function collectClassShape(L, decl) {
474
474
  }
475
475
  }
476
476
  }
477
+ // A poisoned BASE this class EXTENDS must report EAGERLY for the same
478
+ // reason: the derived statement evaluates its heritage when module
479
+ // init reaches it (these are top-level declarations), and the base's
480
+ // fence is the COMPILER's, not Node's — Node defines the base fine and
481
+ // runs on — so a deferred trap there is a manufactured divergence, not
482
+ // the Node-parity deferral is licensed by (classFieldSuperAccessibleJs2:
483
+ // the binary refused at `class D extends C` where Node prints five
484
+ // lines). Leaf poisoned classes stay deferred — only the extends edge
485
+ // reports. Resolution runs under the collect pass's guard (this is
486
+ // collectProgram), so the lookup neither flushes nor fences.
487
+ {
488
+ const baseIdent = decl.heritageClauses
489
+ ?.find((h) => h.token === ts.SyntaxKind.ExtendsKeyword)
490
+ ?.types.map((t) => t.expression)
491
+ .filter(ts.isIdentifier)[0];
492
+ const baseSym = baseIdent ? L.resolveValueSymbol(baseIdent) : null;
493
+ const baseDiags = baseSym ? L.deferredDiags.get(baseSym) : undefined;
494
+ if (baseSym && baseDiags) {
495
+ L.deferredDiags.delete(baseSym);
496
+ if (!L.alreadyFlushed.has(baseSym)) {
497
+ L.flushedSymbols.add(baseSym);
498
+ for (const d of baseDiags)
499
+ L.pushDiag(d);
500
+ }
501
+ }
502
+ }
477
503
  }
478
504
  export function collectClassShapeInner(L, decl, jsNameOverride, inst,
479
505
  /** MIXIN instantiation mode (lower-mixins.ts): the class inside a
@@ -4351,6 +4377,14 @@ export function lowerNew(L, expr) {
4351
4377
  if (httpServer)
4352
4378
  return httpServer;
4353
4379
  }
4380
+ // `new http.Agent(opts?)` / `new https.Agent(opts?)` — the Agent
4381
+ // handle (lower-server): getName/destroy/counters through the dyn
4382
+ // handle ops, requests thread it via the agent option.
4383
+ {
4384
+ const agent = lowerHttpAgentNew(L, expr);
4385
+ if (agent)
4386
+ return agent;
4387
+ }
4354
4388
  if (ts.isIdentifier(expr.expression)) {
4355
4389
  // `import C = N.C; new C()` — the alias's own source-order guards
4356
4390
  // (a no-op for every non-import= binding).
@@ -4362,7 +4396,7 @@ export function lowerNew(L, expr) {
4362
4396
  // like Node's message property default.
4363
4397
  const errInfo = L.builtinErrorInfoOf(symbol);
4364
4398
  // `new DOMException(message?, nameOrOptions?)`: both arguments cross
4365
- // as DOM values (absent → the DOM undefined), and the runtime owns
4399
+ // as dyn values (absent → the dyn undefined), and the runtime owns
4366
4400
  // WebIDL's resolution — ToString of the message ("" for undefined),
4367
4401
  // name from a string / an options object's `name` member (with the
4368
4402
  // `cause` own-property record) / "Error" for absent, and the legacy
@@ -4623,7 +4657,7 @@ export function lowerNew(L, expr) {
4623
4657
  const targs = L.checker.getTypeArguments(tsType);
4624
4658
  // JAVASCRIPT `new Map()` whose arguments never resolved past
4625
4659
  // Map<any, any> (no annotation, no contextual type, no seed): the
4626
- // WeakMap stance below — the VALUE lowers as an opaque DOM object
4660
+ // WeakMap stance below — the VALUE lowers as an opaque dyn object
4627
4661
  // (identity and truthiness are real), and every reached METHOD use
4628
4662
  // meets its own per-site fence at runtime. The formatter's
4629
4663
  // config-cache shape: module init constructs the caches
@@ -4656,7 +4690,7 @@ export function lowerNew(L, expr) {
4656
4690
  // `new WeakMap()` / `new WeakSet()` in JAVASCRIPT sources: no weak
4657
4691
  // container exists in the value model, but harness code constructs
4658
4692
  // one unconditionally and touches it only on paths tests don't
4659
- // reach — the value lowers as an opaque DOM object (identity only;
4693
+ // reach — the value lowers as an opaque dyn object (identity only;
4660
4694
  // every reached METHOD use meets its own per-site fence → runtime
4661
4695
  // fence). TypeScript keeps the compile fence.
4662
4696
  if ((symbol?.name === "WeakMap" || symbol?.name === "WeakSet") &&
@@ -4756,14 +4790,14 @@ export function lowerNew(L, expr) {
4756
4790
  // `new Promise(setImmediate)` (the Node-suite early-exit shape):
4757
4791
  // the executor IS the stdlib setImmediate, so resolve rides the
4758
4792
  // immediate queue — a dedicated runtime constructor arms an
4759
- // immediate that fulfills with the undefined DOM value.
4793
+ // immediate that fulfills with the undefined dyn value.
4760
4794
  {
4761
4795
  const a0 = args[0];
4762
4796
  if (ts.isIdentifier(a0) && a0.text === "setImmediate") {
4763
4797
  const sym = L.checker.getSymbolAtLocation(a0);
4764
4798
  const decls = sym ? L.checker.declarationsOf(sym) : [];
4765
4799
  if (decls.length > 0 && decls.every((d) => L.isStdlibFile(d.getSourceFile()))) {
4766
- // The settled value is the undefined DOM value — the result
4800
+ // The settled value is the undefined dyn value — the result
4767
4801
  // is promise<dyn> whatever T the checker inferred for the
4768
4802
  // unusual executor (Promise<unknown> in the suite's shape).
4769
4803
  return {
@@ -4992,7 +5026,7 @@ export function lowerNew(L, expr) {
4992
5026
  // of the generic construction rejection.
4993
5027
  {
4994
5028
  const STDLIB_CTOR_HINTS = {
4995
- Agent: "constructing an http Agent (compiled clients dial one connection per request and close it with the response — pass agent: false for Node's one-shot semantics, or omit the option)",
5029
+ Agent: "constructing an http Agent through an indirect class binding (spell the construction on the module binding — new http.Agent(...)/new https.Agent(...) or the named Agent import — which lowers to the Agent handle)",
4996
5030
  };
4997
5031
  const ctorName = ts.isIdentifier(expr.expression)
4998
5032
  ? expr.expression