@pulse-compute/wasm-compiler 0.0.0 → 1.0.0-beta.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 (104) hide show
  1. package/README.md +53 -1
  2. package/bin/provider-proof-composition.js +34 -0
  3. package/bin/pulsewasm-extract.js +20 -0
  4. package/package.json +60 -5
  5. package/src/artifacts-dir.js +13 -0
  6. package/src/ast-json.js +52 -0
  7. package/src/build-manifest.js +354 -0
  8. package/src/canonical-api-compiler.js +269 -0
  9. package/src/canonical-native-compiler.js +411 -0
  10. package/src/canonical-native-plan.js +1478 -0
  11. package/src/canonical-project-compiler.js +1224 -0
  12. package/src/canonical-router-compiler.js +25 -0
  13. package/src/cli-intents.js +1235 -0
  14. package/src/cli.js +1927 -0
  15. package/src/codegen/assemblyscript-compile.js +3 -0
  16. package/src/codegen/assemblyscript-core.js +3 -0
  17. package/src/codegen/assemblyscript-shape.js +3 -0
  18. package/src/codegen/assemblyscript-wasm-smoke.js +3 -0
  19. package/src/codegen/backend-capabilities.js +3 -0
  20. package/src/codegen/channel-broadcaster.js +3 -0
  21. package/src/codegen/compiled-handlers.js +3 -0
  22. package/src/codegen/compiled-wasm-runtime.js +3 -0
  23. package/src/codegen/config-references.js +248 -0
  24. package/src/codegen/dispatch-ts.js +145 -0
  25. package/src/codegen/effect-composition.js +331 -0
  26. package/src/codegen/effect-runtime.js +418 -0
  27. package/src/codegen/execution-harness-ts.js +467 -0
  28. package/src/codegen/handler-bindings-ts.js +298 -0
  29. package/src/codegen/handler-library-contracts.js +3 -0
  30. package/src/codegen/host-capabilities.js +3 -0
  31. package/src/codegen/host-runtime-kernel.js +3 -0
  32. package/src/codegen/integrated-compiled-app.js +3 -0
  33. package/src/codegen/json-body.js +3 -0
  34. package/src/codegen/library-sidecars.js +3 -0
  35. package/src/codegen/local-harness-ts.js +453 -0
  36. package/src/codegen/pulse-wrapper.js +217 -0
  37. package/src/codegen/request-result-headers.js +3 -0
  38. package/src/codegen/schema-json-compile.js +3 -0
  39. package/src/codegen/schema-json-sidecar-v2.js +3 -0
  40. package/src/codegen/schema-json-sidecar.js +3 -0
  41. package/src/codegen/streaming-passthrough.js +3 -0
  42. package/src/codegen/wasm-host-abi.js +3 -0
  43. package/src/codegen/wasm-host-bridge.js +3 -0
  44. package/src/compiled-wasm-host-runtime-kv.js +3 -0
  45. package/src/config-resolver.js +813 -0
  46. package/src/crypto-requirement-planner.js +89 -0
  47. package/src/definitions/config-schema.js +14 -0
  48. package/src/definitions/handler-roles.js +14 -0
  49. package/src/definitions/path-grammar.js +14 -0
  50. package/src/definitions/router-api.js +14 -0
  51. package/src/diagnostics/codes.js +14 -0
  52. package/src/diagnostics/reporter.js +14 -0
  53. package/src/diagnostics.js +14 -0
  54. package/src/dispatch-table.js +400 -0
  55. package/src/events/event-emit.js +265 -0
  56. package/src/events/event-topology.js +127 -0
  57. package/src/execution-plan.js +463 -0
  58. package/src/extractor.js +2816 -0
  59. package/src/handler-eval.js +1154 -0
  60. package/src/handler-table.js +326 -0
  61. package/src/index.js +19 -0
  62. package/src/javascript-application-plan.js +181 -0
  63. package/src/kv-provider.js +3 -0
  64. package/src/path-table.js +60 -0
  65. package/src/path.js +14 -0
  66. package/src/patterns/config-define.js +30 -0
  67. package/src/patterns/dependency-call.js +18 -0
  68. package/src/patterns/env-lookup.js +13 -0
  69. package/src/patterns/handler-reference.js +29 -0
  70. package/src/patterns/path-literal.js +35 -0
  71. package/src/patterns/result.js +15 -0
  72. package/src/patterns/router-chain-call.js +50 -0
  73. package/src/patterns/router-construction.js +19 -0
  74. package/src/project/package-reachability.js +782 -0
  75. package/src/project/reachable-graph-builder.js +992 -0
  76. package/src/project/reachable-graph-contract.js +54 -0
  77. package/src/project/reachable-graph-implementation.js +36 -0
  78. package/src/project/router-module-linker.js +710 -0
  79. package/src/project-config-compiler.js +222 -0
  80. package/src/project-target-support.js +500 -0
  81. package/src/provider-toolchain.js +299 -0
  82. package/src/spine/async-surface-normalizer.js +328 -0
  83. package/src/spine/canonical-handler-ir.js +336 -0
  84. package/src/spine/canonical-native-module.js +87 -0
  85. package/src/spine/canonical-native-plan.js +89 -0
  86. package/src/spine/canonical-project.js +76 -0
  87. package/src/spine/canonical-router.js +155 -0
  88. package/src/spine/canonical-source.js +165 -0
  89. package/src/spine/diagnostic-authority.js +290 -0
  90. package/src/spine/equivalence.js +262 -0
  91. package/src/spine/guest-unit-stage.js +87 -0
  92. package/src/spine/handler-ir-emitter.js +455 -0
  93. package/src/spine/handler-ir-managed.js +1598 -0
  94. package/src/spine/handler-ir.js +797 -0
  95. package/src/spine/handler-surface-authority.js +588 -0
  96. package/src/spine/package-operation-seam.js +1015 -0
  97. package/src/spine/pipeline.js +202 -0
  98. package/src/spine/plain-handler-frontend.js +545 -0
  99. package/src/spine/provider-requirement-authority.js +208 -0
  100. package/src/spine/router-control-contract.js +17 -0
  101. package/src/spine/router-handler-frontend.js +514 -0
  102. package/src/spine/router-handler-ir.js +372 -0
  103. package/src/spine/router-topology-frontend.js +638 -0
  104. package/src/stable-id.js +14 -0
@@ -0,0 +1,29 @@
1
+ 'use strict';
2
+
3
+ const { match, unknown } = require('./result.js');
4
+
5
+ function isInlineFunction(ts, node) {
6
+ return Boolean(node) && (ts.isArrowFunction(node) || ts.isFunctionExpression(node));
7
+ }
8
+
9
+ function classifyHandlerReference(ts, node) {
10
+ if (ts.isIdentifier(node)) return match({ kind: 'identifier', name: node.text });
11
+ if (isInlineFunction(ts, node)) {
12
+ return match({
13
+ kind: 'inline',
14
+ inlineKind: ts.isArrowFunction(node) ? 'inline-arrow' : 'inline-function-expression'
15
+ });
16
+ }
17
+ return unknown();
18
+ }
19
+
20
+ function classifyChannelReference(ts, node, isStringLiteralLike) {
21
+ if (isStringLiteralLike(ts, node)) return match({ kind: 'static', value: node.text });
22
+ return classifyHandlerReference(ts, node);
23
+ }
24
+
25
+ module.exports = {
26
+ classifyChannelReference,
27
+ classifyHandlerReference,
28
+ isInlineFunction
29
+ };
@@ -0,0 +1,35 @@
1
+ 'use strict';
2
+
3
+ function isStringLiteralLike(ts, node) {
4
+ return Boolean(node) && (ts.isStringLiteral(node) || node.kind === ts.SyntaxKind.NoSubstitutionTemplateLiteral);
5
+ }
6
+
7
+ function literalText(node) {
8
+ return node.text;
9
+ }
10
+
11
+ function nodeText(sourceFile, node) {
12
+ return node.getText(sourceFile).trim();
13
+ }
14
+
15
+ function unwrapExpression(ts, node) {
16
+ let current = node;
17
+ while (
18
+ current &&
19
+ (ts.isParenthesizedExpression(current) ||
20
+ ts.isAsExpression(current) ||
21
+ ts.isSatisfiesExpression?.(current) ||
22
+ ts.isNonNullExpression(current) ||
23
+ ts.isTypeAssertionExpression(current))
24
+ ) {
25
+ current = current.expression;
26
+ }
27
+ return current;
28
+ }
29
+
30
+ module.exports = {
31
+ isStringLiteralLike,
32
+ literalText,
33
+ nodeText,
34
+ unwrapExpression
35
+ };
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+
3
+ function match(value) {
4
+ return { status: 'match', value };
5
+ }
6
+
7
+ function reject(diagnostic) {
8
+ return { status: 'reject', diagnostic };
9
+ }
10
+
11
+ function unknown() {
12
+ return { status: 'unknown' };
13
+ }
14
+
15
+ module.exports = { match, reject, unknown };
@@ -0,0 +1,50 @@
1
+ 'use strict';
2
+
3
+ const { DIAGNOSTIC_CODES } = require('../diagnostics/codes.js');
4
+
5
+ function unwindRouterCallChain(ts, sourceFile, expr, diagnostics, diagnostic) {
6
+ const steps = [];
7
+ let cursor = expr;
8
+
9
+ while (ts.isCallExpression(cursor)) {
10
+ const callee = cursor.expression;
11
+ if (ts.isPropertyAccessExpression(callee)) {
12
+ steps.unshift({ method: callee.name.text, args: Array.from(cursor.arguments), node: cursor, nameNode: callee.name });
13
+ cursor = callee.expression;
14
+ continue;
15
+ }
16
+ if (ts.isElementAccessExpression(callee)) {
17
+ if (diagnostics && diagnostic) {
18
+ diagnostics.push(
19
+ diagnostic(
20
+ sourceFile,
21
+ callee,
22
+ DIAGNOSTIC_CODES.COMPUTED_METHOD,
23
+ 'Computed router method calls are not supported in PulseWasm v1.',
24
+ 'Use direct property calls such as app.get("/path", handler).',
25
+ { phase: 'extract' }
26
+ )
27
+ );
28
+ }
29
+ return null;
30
+ }
31
+ return null;
32
+ }
33
+
34
+ if (!ts.isIdentifier(cursor)) return null;
35
+ return { root: cursor.text, rootNode: cursor, steps };
36
+ }
37
+
38
+ function isOutermostCallInChain(ts, node) {
39
+ return !(
40
+ node.parent &&
41
+ ts.isPropertyAccessExpression(node.parent) &&
42
+ node.parent.parent &&
43
+ ts.isCallExpression(node.parent.parent)
44
+ );
45
+ }
46
+
47
+ module.exports = {
48
+ isOutermostCallInChain,
49
+ unwindRouterCallChain
50
+ };
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ function isRouterNewExpression(ts, init, unwrapExpression) {
4
+ const expr = unwrapExpression(ts, init);
5
+ return Boolean(expr && ts.isNewExpression(expr) && ts.isIdentifier(expr.expression) && ['Router', 'Pulse'].includes(expr.expression.text));
6
+ }
7
+
8
+ function isDirectRouterDeclarationInitializer(ts, node) {
9
+ let current = node;
10
+ while (current.parent && (ts.isParenthesizedExpression(current.parent) || ts.isAsExpression(current.parent) || ts.isNonNullExpression(current.parent))) {
11
+ current = current.parent;
12
+ }
13
+ return Boolean(current.parent && ts.isVariableDeclaration(current.parent) && current.parent.initializer === current && ts.isIdentifier(current.parent.name));
14
+ }
15
+
16
+ module.exports = {
17
+ isDirectRouterDeclarationInitializer,
18
+ isRouterNewExpression
19
+ };