deepline 0.3.480 → 0.3.481

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 (152) hide show
  1. package/dist/bundling-sources/sdk/src/client-core.ts +35 -1
  2. package/dist/bundling-sources/sdk/src/http-core.ts +2 -0
  3. package/dist/bundling-sources/sdk/src/plays/run-request.ts +54 -31
  4. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  5. package/dist/bundling-sources/shared_libs/monitors/legacy-radar-forward-routes.ts +569 -0
  6. package/dist/bundling-sources/shared_libs/monitors/legacy-radar-retirement.ts +451 -0
  7. package/dist/bundling-sources/shared_libs/monitors/package.json +5 -1
  8. package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +18 -0
  9. package/dist/bundling-sources/shared_libs/play-runtime/runtime-array-input-receipts.ts +13 -6
  10. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backend.ts +2 -0
  11. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +125 -22
  12. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-shared.ts +16 -53
  13. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +34 -48
  14. package/dist/bundling-sources/shared_libs/security/receipt-admission-token.ts +44 -0
  15. package/dist/cli/auth-EQWYBNIE.js +43 -0
  16. package/dist/cli/{auth-KMKFQX7X.mjs → auth-FYY65LYD.mjs} +5 -5
  17. package/dist/cli/{billing-G3Y5FTQM.mjs → billing-3MELYUTI.mjs} +7 -7
  18. package/dist/cli/{billing-R5RCTEW6.js → billing-TROHWBSE.js} +80 -80
  19. package/dist/cli/{chunk-4V6KEXCM.js → chunk-27BYXQU4.js} +1 -1
  20. package/dist/cli/{chunk-OQOXR6JL.js → chunk-4CIVXXSU.js} +26 -26
  21. package/dist/cli/{chunk-RPJSVGSC.js → chunk-5ONCPLWC.js} +16 -16
  22. package/dist/cli/{chunk-K7E2DO5P.js → chunk-6VKDKATO.js} +53 -53
  23. package/dist/cli/{chunk-WQBJHB63.js → chunk-6WWBVWFQ.js} +7 -7
  24. package/dist/cli/{chunk-LLEBPM3N.mjs → chunk-6ZMUAASO.mjs} +4 -4
  25. package/dist/cli/{chunk-IQ6WL36K.mjs → chunk-75LUK4E5.mjs} +1 -1
  26. package/dist/cli/{chunk-AKCYZDBO.mjs → chunk-7VVC4RZX.mjs} +1 -1
  27. package/dist/cli/{chunk-JBQKBDDN.mjs → chunk-ASQJUUGB.mjs} +5 -5
  28. package/dist/cli/{chunk-DIDWIPMA.mjs → chunk-BJ5UFTWL.mjs} +28 -7
  29. package/dist/cli/{chunk-JH77OHD5.js → chunk-BJMEXKZY.js} +2 -2
  30. package/dist/cli/{chunk-53LLOGNV.mjs → chunk-C7UIUKW6.mjs} +2 -2
  31. package/dist/cli/{chunk-LHU6BMDV.js → chunk-CM3KC74A.js} +3 -3
  32. package/dist/cli/{chunk-XNXE7YWI.mjs → chunk-CS2P3EQS.mjs} +2 -2
  33. package/dist/cli/{chunk-APFFHSPL.js → chunk-CUSWZTS7.js} +8 -8
  34. package/dist/cli/{chunk-6AYQK7Z6.js → chunk-D3UHG54V.js} +199 -178
  35. package/dist/cli/{chunk-PM2CT7HZ.mjs → chunk-EJTU6X6C.mjs} +3 -3
  36. package/dist/cli/{chunk-FZX2DGQZ.js → chunk-EPEAQA6O.js} +37 -37
  37. package/dist/cli/{chunk-57MJL2HU.mjs → chunk-EPZSX7FZ.mjs} +4 -4
  38. package/dist/cli/{chunk-FZ42SO3Q.mjs → chunk-FXLMDAAY.mjs} +1 -1
  39. package/dist/cli/chunk-GBAT5NMI.mjs +789 -0
  40. package/dist/cli/{chunk-VPO2D7WV.js → chunk-GJOKFJ2Y.js} +10 -10
  41. package/dist/cli/{chunk-JDMR33HS.js → chunk-GVAENVIG.js} +28 -19
  42. package/dist/cli/{chunk-NELMCOWK.mjs → chunk-HNRELVCS.mjs} +27 -18
  43. package/dist/cli/{chunk-SUTQCM7U.mjs → chunk-HXG7TYRS.mjs} +2 -2
  44. package/dist/cli/{chunk-PDDUX5UY.js → chunk-J4D3PCQ2.js} +5 -5
  45. package/dist/cli/{chunk-PC42DFZC.mjs → chunk-JE27DTQM.mjs} +3 -3
  46. package/dist/cli/{chunk-MEJJD7PA.js → chunk-KDU6TSGE.js} +2 -2
  47. package/dist/cli/{chunk-NVTVS4AV.js → chunk-KPXP2DIY.js} +7 -9
  48. package/dist/cli/chunk-KQSTV4MW.js +789 -0
  49. package/dist/cli/{chunk-2AYWC63S.mjs → chunk-LISZBUA7.mjs} +2 -2
  50. package/dist/cli/{chunk-44TVNYYV.mjs → chunk-LTOY2GUJ.mjs} +10 -10
  51. package/dist/cli/{chunk-OGXG46LY.js → chunk-MKDWU3ZI.js} +93 -93
  52. package/dist/cli/{chunk-MTMOYZMK.mjs → chunk-N5267HEH.mjs} +1 -1
  53. package/dist/cli/{chunk-T7EWDIVM.mjs → chunk-PDJS6LFI.mjs} +2 -1
  54. package/dist/cli/{chunk-QEV3GFDS.js → chunk-R4EFW2I2.js} +3 -3
  55. package/dist/cli/{chunk-KQNQCZLB.mjs → chunk-RV2GB7KW.mjs} +2 -2
  56. package/dist/cli/{chunk-PYIWO4GS.mjs → chunk-S5BM6NPJ.mjs} +3 -5
  57. package/dist/cli/{chunk-7LMLHUCP.mjs → chunk-S5WXSC3P.mjs} +5 -5
  58. package/dist/cli/{chunk-63QH6FL3.mjs → chunk-SOGLBLMH.mjs} +4 -4
  59. package/dist/cli/{chunk-5IVGZCKY.js → chunk-SVPM2E2U.js} +5 -5
  60. package/dist/cli/{chunk-ZSWY5E3W.mjs → chunk-UUGSZZZH.mjs} +1 -1
  61. package/dist/cli/{chunk-TBJ23WKT.js → chunk-VBDR2DP6.js} +3 -3
  62. package/dist/cli/{chunk-TXFURKHD.mjs → chunk-VRAOWHXJ.mjs} +1 -1
  63. package/dist/cli/{chunk-ASARTL6E.mjs → chunk-VTKAIGW6.mjs} +3 -3
  64. package/dist/cli/{chunk-DQYJXVAF.js → chunk-WF5QE2IW.js} +17 -16
  65. package/dist/cli/{chunk-NBXG4S2X.js → chunk-WICQQ7GY.js} +53 -53
  66. package/dist/cli/{chunk-FFSOXQEM.js → chunk-WTWRZ5ZI.js} +8 -8
  67. package/dist/cli/{chunk-LBZLV6QF.js → chunk-X4XZFIK6.js} +14 -14
  68. package/dist/cli/{chunk-A3PZKD47.js → chunk-X6MEQBAT.js} +21 -21
  69. package/dist/cli/{csv-P3AEI4G4.mjs → csv-2EG7JW7V.mjs} +4 -4
  70. package/dist/cli/{csv-57D62T7L.js → csv-OUALOZBF.js} +13 -13
  71. package/dist/cli/{db-FWFYU34R.js → db-7BTOI6YB.js} +28 -28
  72. package/dist/cli/{db-PJQMPZJP.mjs → db-ECDQWI2Y.mjs} +7 -7
  73. package/dist/cli/describe-EXSH6OZD.js +48 -0
  74. package/dist/cli/{describe-F57VZZML.mjs → describe-KO6WKQIB.mjs} +18 -18
  75. package/dist/cli/describe-core.d.mts +2 -2
  76. package/dist/cli/describe-core.d.ts +2 -2
  77. package/dist/cli/{executions-ZAJGMAAT.mjs → executions-3VMFBZT4.mjs} +7 -7
  78. package/dist/cli/{executions-YBT7NTY5.js → executions-VZSG3F3E.js} +9 -9
  79. package/dist/cli/{feedback-YLYY2EG4.js → feedback-ASKBWRXR.js} +8 -8
  80. package/dist/cli/{feedback-L3ZQCSY6.mjs → feedback-SN7AVALN.mjs} +4 -4
  81. package/dist/cli/{git-M7735NWJ.mjs → git-W2DZXEAY.mjs} +5 -5
  82. package/dist/cli/git-X2XUKYYX.js +25 -0
  83. package/dist/cli/index.js +167 -144
  84. package/dist/cli/index.mjs +73 -50
  85. package/dist/cli/{legacy-noops-TX37UP3U.js → legacy-noops-6KOC6LV7.js} +8 -8
  86. package/dist/cli/{legacy-noops-PKNMQMGY.mjs → legacy-noops-R2SML7ED.mjs} +5 -5
  87. package/dist/cli/{monitors-U7AUIOFZ.mjs → monitors-4VGZGJBT.mjs} +8 -8
  88. package/dist/cli/{monitors-5YTGQSGD.js → monitors-OJXDYU4G.js} +92 -92
  89. package/dist/cli/{org-N6DSSLLD.js → org-AELMZFUT.js} +73 -73
  90. package/dist/cli/{org-SRKZRVVH.mjs → org-UGN5ZG2Y.mjs} +7 -7
  91. package/dist/cli/{pages-YPN54RCC.js → pages-L26N7MK3.js} +18 -18
  92. package/dist/cli/{pages-UOPJUFCF.mjs → pages-ZYPAAYSS.mjs} +7 -7
  93. package/dist/cli/{play-4IK4WXWU.mjs → play-ENYB7X4S.mjs} +125 -53
  94. package/dist/cli/{play-MEYZEYOV.js → play-VTZWB3N5.js} +620 -548
  95. package/dist/cli/{providers-UGHUYP4C.mjs → providers-BZQTVAQG.mjs} +7 -7
  96. package/dist/cli/{providers-VS5MK4ZH.js → providers-HWBY6MGQ.js} +10 -10
  97. package/dist/cli/{quickstart-GW2ERQ2A.js → quickstart-D54IJ3PX.js} +6 -6
  98. package/dist/cli/{quickstart-YBOQSLFV.mjs → quickstart-SSQJDWPB.mjs} +4 -4
  99. package/dist/cli/{run-IVGMLY3J.js → run-45NKE7UY.js} +37 -37
  100. package/dist/cli/{run-44JT5GJM.mjs → run-FR3TPYT3.mjs} +23 -23
  101. package/dist/cli/{search-43NY73VR.mjs → search-CZCWSR5L.mjs} +8 -8
  102. package/dist/cli/search-V2GJKQQQ.js +32 -0
  103. package/dist/cli/{secrets-DABUD3B7.js → secrets-KJ5ZEDWT.js} +16 -16
  104. package/dist/cli/{secrets-ONDQGW3B.mjs → secrets-KKK55B4Y.mjs} +7 -7
  105. package/dist/cli/{sessions-AIAKKLSR.mjs → sessions-2YKA54PH.mjs} +5 -5
  106. package/dist/cli/{sessions-4ILQMBKR.js → sessions-QCNPUTDZ.js} +6 -6
  107. package/dist/cli/{settings-HSGKYOJT.mjs → settings-4NI2AS5V.mjs} +12 -12
  108. package/dist/cli/{settings-BWNLL7TP.js → settings-KM3LCPWD.js} +79 -79
  109. package/dist/cli/{setup-LE4OVH4M.mjs → setup-BZF3M54I.mjs} +9 -9
  110. package/dist/cli/{setup-37QOD4UT.js → setup-V5MTS2AA.js} +47 -47
  111. package/dist/cli/skills-CRFYW767.js +33 -0
  112. package/dist/cli/{skills-A3ZVR2YX.mjs → skills-NXYNB3LP.mjs} +7 -7
  113. package/dist/cli/{tools-ITKPPUDT.mjs → tools-57MWFRIZ.mjs} +17 -17
  114. package/dist/cli/tools-Q662HPVJ.js +55 -0
  115. package/dist/cli/{update-XJOSCOK5.mjs → update-QM6H677U.mjs} +9 -9
  116. package/dist/cli/update-TYHKF7F5.js +33 -0
  117. package/dist/cli/{workflow-KYQYFSND.mjs → workflow-NHYDIUWY.mjs} +8 -8
  118. package/dist/cli/{workflow-LERZ3TYV.js → workflow-TGEC4ITO.js} +18 -18
  119. package/dist/{client-B9N1bcGc.d.mts → client-DJ3r8VQJ.d.mts} +1 -1
  120. package/dist/{client-Btw075Hq.d.ts → client-JPSNljtj.d.ts} +1 -1
  121. package/dist/{client-core-TulbIeRB.d.mts → client-core-3SJlNsKU.d.mts} +21 -2
  122. package/dist/{client-core-DvGWlwtX.d.ts → client-core-rCoQ5Xz3.d.ts} +21 -2
  123. package/dist/index.d.mts +3 -3
  124. package/dist/index.d.ts +3 -3
  125. package/dist/index.js +10 -10
  126. package/dist/index.mjs +7 -7
  127. package/dist/install-integrity.json +106 -104
  128. package/dist/plays/bundle-play-file.mjs +5426 -12
  129. package/dist/plays/play-description.d.mts +1 -1
  130. package/dist/plays/play-description.d.ts +1 -1
  131. package/dist/plays/run-request.d.mts +1 -1
  132. package/dist/plays/run-request.d.ts +1 -1
  133. package/dist/plays/run-request.js +4 -2
  134. package/dist/plays/run-request.mjs +3 -1
  135. package/dist/release.d.mts +1 -1
  136. package/dist/release.d.ts +1 -1
  137. package/dist/release.js +2 -2
  138. package/dist/release.mjs +1 -1
  139. package/dist/server.d.mts +2 -2
  140. package/dist/server.d.ts +2 -2
  141. package/dist/server.js +6 -6
  142. package/dist/server.mjs +4 -4
  143. package/package.json +1 -1
  144. package/dist/cli/auth-7FOB243B.js +0 -43
  145. package/dist/cli/chunk-7UFFWPQ2.js +0 -6188
  146. package/dist/cli/chunk-ZBSUXXZS.mjs +0 -6188
  147. package/dist/cli/describe-ZAYUBNUQ.js +0 -48
  148. package/dist/cli/git-A3433UTN.js +0 -25
  149. package/dist/cli/search-2XTYY7BF.js +0 -32
  150. package/dist/cli/skills-TULQXRQJ.js +0 -33
  151. package/dist/cli/tools-QYYBWDXU.js +0 -55
  152. package/dist/cli/update-XSMY7KWH.js +0 -33
@@ -0,0 +1,789 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// ../plays/script-entry.ts
2
+ var _path = require('path');
3
+
4
+ // ../plays/ts-ast.ts
5
+ var _acorn = require('acorn');
6
+ var _acorntypescript = require('acorn-typescript');
7
+ var TypeScriptParser = _acorn.Parser.extend(
8
+ _acorntypescript.tsPlugin.call(void 0, {
9
+ allowSatisfies: true,
10
+ jsx: {
11
+ allowNamespaces: true,
12
+ allowNamespacedObjects: true
13
+ }
14
+ })
15
+ );
16
+ function isAstNode(value) {
17
+ return value !== null && typeof value === "object" && "type" in value;
18
+ }
19
+ function astArray(value) {
20
+ return Array.isArray(value) ? value.filter(isAstNode) : [];
21
+ }
22
+ function parsePlaySourceForAnalysis(sourceCode) {
23
+ try {
24
+ return TypeScriptParser.parse(sourceCode, {
25
+ ecmaVersion: "latest",
26
+ sourceType: "module",
27
+ allowHashBang: true,
28
+ // Script plays may end early with a top-level `return`.
29
+ allowReturnOutsideFunction: true
30
+ });
31
+ } catch (e) {
32
+ return null;
33
+ }
34
+ }
35
+
36
+ // ../plays/script-entry.ts
37
+ var SCRIPT_SDK = "deepline";
38
+ var PLAY_FILE_PATTERN = /\.play\.[cm]?[jt]sx?$/i;
39
+ var DEFINE_CALLEES = /* @__PURE__ */ new Set(["definePlay", "defineWorkflow"]);
40
+ var FUNCTION_TYPES = /* @__PURE__ */ new Set([
41
+ "FunctionDeclaration",
42
+ "FunctionExpression",
43
+ "ArrowFunctionExpression"
44
+ ]);
45
+ var MODULE_SCOPE = /* @__PURE__ */ new Set([
46
+ "ImportDeclaration",
47
+ "TSTypeAliasDeclaration",
48
+ "TSInterfaceDeclaration"
49
+ ]);
50
+ var DECLARATION_TYPES = /* @__PURE__ */ new Set([
51
+ "FunctionDeclaration",
52
+ "TSDeclareFunction",
53
+ "ClassDeclaration",
54
+ "TSTypeAliasDeclaration",
55
+ "TSInterfaceDeclaration",
56
+ "TSEnumDeclaration"
57
+ ]);
58
+ var UNWRAPPED_TYPES = /* @__PURE__ */ new Set([
59
+ "TSAsExpression",
60
+ "TSSatisfiesExpression",
61
+ "TSTypeAssertion",
62
+ "ParenthesizedExpression",
63
+ "AwaitExpression"
64
+ ]);
65
+ var CONDITIONAL_TYPES = /* @__PURE__ */ new Set([
66
+ ...FUNCTION_TYPES,
67
+ "ClassDeclaration",
68
+ "ClassExpression",
69
+ "IfStatement",
70
+ "ConditionalExpression",
71
+ "LogicalExpression",
72
+ "SwitchStatement",
73
+ "ForStatement",
74
+ "ForInStatement",
75
+ "ForOfStatement",
76
+ "WhileStatement",
77
+ "DoWhileStatement",
78
+ "CatchClause"
79
+ ]);
80
+ var INLINE_PLAY_FILE = ".inline.play.ts";
81
+ var LEADING_IMPORT = /^\s*import\s+(?:[\w$*{}\s,]+?\s+from\s+)?['"][^'"]+['"]\s*;?/;
82
+ function inlinePlaySource(code) {
83
+ let header = "";
84
+ let body = code;
85
+ for (let match = LEADING_IMPORT.exec(body); match; ) {
86
+ header += match[0];
87
+ body = body.slice(match[0].length);
88
+ match = LEADING_IMPORT.exec(body);
89
+ }
90
+ const runtimeImport = /\bimport\s+\w+\s*(,\s*\{[^}]*\}\s*)?from\s+['"]deepline['"]/.test(header) ? "" : `import ${SCRIPT_SDK} from '${SCRIPT_SDK}'; `;
91
+ if (/\bexport\s+default\b/.test(code)) return runtimeImport + code;
92
+ return `${runtimeImport}${header}export default async function (input: any) {${body}
93
+ }
94
+ `;
95
+ }
96
+ function playNameFromPath(filePath) {
97
+ return _path.basename.call(void 0, filePath).replace(/^\.+/, "").replace(/(\.play)?\.[cm]?[jt]sx?$/, "");
98
+ }
99
+ function parseScriptPlay(source) {
100
+ const program = programOf(source);
101
+ const form = program ? playForm(program) : null;
102
+ if (!program || !form) return null;
103
+ const { entry } = form;
104
+ const header = headerOf(program);
105
+ const contextName = _nullishCoalesce(defaultImportName(header.find(isSdkImport)), () => ( SCRIPT_SDK));
106
+ const parts = scriptPlayParts(program, contextName, _nullishCoalesce(_optionalChain([entry, 'optionalAccess', _ => _.node]), () => ( null)));
107
+ const configExport = configExportOf(program);
108
+ const headerEnd = _nullishCoalesce(_optionalChain([header, 'access', _2 => _2.at, 'call', _3 => _3(-1), 'optionalAccess', _4 => _4.end]), () => ( 0));
109
+ const [entryCall = null] = entry ? entryCallsOf(program, entry) : [];
110
+ const callStatement = entryCall ? program.body.find(
111
+ (node) => node.start <= entryCall.start && node.end >= entryCall.end
112
+ ) : void 0;
113
+ const excluded = new Set(
114
+ [
115
+ _optionalChain([entry, 'optionalAccess', _5 => _5.exportStatement]),
116
+ _optionalChain([entry, 'optionalAccess', _6 => _6.declaration]),
117
+ callStatement,
118
+ configExport
119
+ ].filter(Boolean)
120
+ );
121
+ const moduleCode = program.body.slice(header.length).filter(
122
+ (node) => !excluded.has(node) && !MODULE_SCOPE.has(node.type) && !(node.type === "ExpressionStatement" && scriptCallName(unwrapped(node.expression), contextName) === "config") && // Beside a play function, module code that neither awaits nor uses
123
+ // the runtime only names values and helpers, as a definePlay file's
124
+ // module scope does.
125
+ (!entry || usesRuntime(node, contextName))
126
+ );
127
+ const body = _optionalChain([entry, 'optionalAccess', _7 => _7.node, 'access', _8 => _8.body]);
128
+ const code = [
129
+ ...moduleCode,
130
+ ..._optionalChain([body, 'optionalAccess', _9 => _9.type]) === "BlockStatement" ? body.body : []
131
+ ];
132
+ const [parameter] = _nullishCoalesce(_optionalChain([entry, 'optionalAccess', _10 => _10.node, 'access', _11 => _11.params]), () => ( []));
133
+ return {
134
+ entry,
135
+ entryCall,
136
+ code,
137
+ contextName,
138
+ headerEnd,
139
+ delegate: delegateOf(code, contextName),
140
+ config: _nullishCoalesce((configExport && configObjectOf(configExport)), () => ( parts.config)),
141
+ // The entry's parameter is its input; `(input) => ({ ... })` returns its
142
+ // expression.
143
+ inputType: _nullishCoalesce(parameterType(parameter), () => ( parts.inputType)),
144
+ outputs: body && body.type !== "BlockStatement" ? [body] : parts.outputs
145
+ };
146
+ }
147
+ function playRuntimeNames(source) {
148
+ const program = programOf(source);
149
+ const imported = program ? program.body.filter(isSdkImport).map(defaultImportName) : [];
150
+ return /* @__PURE__ */ new Set([
151
+ "ctx",
152
+ SCRIPT_SDK,
153
+ ...imported.filter((name) => name !== null)
154
+ ]);
155
+ }
156
+ function isRuntimeReceiver(name, runtimeNames) {
157
+ return runtimeNames.has(name) || name.endsWith("Ctx");
158
+ }
159
+ function delegateOf(code, contextName) {
160
+ const [statement, extra] = code.filter(
161
+ (node) => !isSignatureStatement(node, contextName) && !isDeclarationOnly(node)
162
+ );
163
+ if (extra || _optionalChain([statement, 'optionalAccess', _12 => _12.type]) !== "ReturnStatement") return null;
164
+ const returned = statement.argument;
165
+ const call = isAstNode(returned) && returned.type === "AwaitExpression" ? returned.argument : returned;
166
+ if (!isAstNode(call) || call.type !== "CallExpression") return null;
167
+ const [runtime] = call.arguments;
168
+ return isAstNode(call.callee) && call.callee.type === "Identifier" && _optionalChain([runtime, 'optionalAccess', _13 => _13.type]) === "Identifier" && (runtime.name === "ctx" || runtime.name === contextName) ? { handlerName: call.callee.name } : null;
169
+ }
170
+ function isSignatureStatement(node, contextName) {
171
+ if (node.type === "ExpressionStatement") {
172
+ return scriptCallName(unwrapped(node.expression), contextName) === "config";
173
+ }
174
+ if (node.type !== "VariableDeclaration") return false;
175
+ const declarations = node.declarations;
176
+ return declarations.length === 1 && scriptCallName(unwrapped(declarations[0].init), contextName) === "input";
177
+ }
178
+ function isDeclarationOnly(node) {
179
+ if (DECLARATION_TYPES.has(node.type)) return true;
180
+ return node.type === "VariableDeclaration" && node.kind === "const" && node.declarations.every(
181
+ (declarator) => isAstNode(declarator.init) && isLiteralValue(declarator.init)
182
+ );
183
+ }
184
+ function isLiteralValue(node) {
185
+ return node.type === "TemplateLiteral" ? node.expressions.length === 0 : node.type === "Literal" && (node.regex !== void 0 || ["string", "number", "bigint"].includes(typeof node.value));
186
+ }
187
+ function unwrapped(node) {
188
+ let current = isAstNode(node) ? node : null;
189
+ while (current && UNWRAPPED_TYPES.has(current.type)) {
190
+ const inner = _nullishCoalesce(current.expression, () => ( current.argument));
191
+ current = isAstNode(inner) ? inner : null;
192
+ }
193
+ return current;
194
+ }
195
+ function parameterType(parameter) {
196
+ const target = _optionalChain([parameter, 'optionalAccess', _14 => _14.type]) === "AssignmentPattern" ? parameter.left : parameter;
197
+ const annotation = isAstNode(target) ? target.typeAnnotation : null;
198
+ return isAstNode(annotation) && isAstNode(annotation.typeAnnotation) ? annotation.typeAnnotation : null;
199
+ }
200
+ function scriptPlayParts(program, contextName, playFunction) {
201
+ const parts = { config: null, inputType: null, outputs: [] };
202
+ const visit = (node, insideFunction) => {
203
+ if (node.type === "ReturnStatement" && !insideFunction && isAstNode(node.argument)) {
204
+ parts.outputs.push(node.argument);
205
+ }
206
+ const call = scriptCallName(node, contextName);
207
+ const [argument] = Array.isArray(node.arguments) ? node.arguments.filter(isAstNode) : [];
208
+ if (call === "config" && _optionalChain([argument, 'optionalAccess', _15 => _15.type]) === "ObjectExpression") {
209
+ parts.config ??= argument;
210
+ } else if (call === "input") {
211
+ parts.inputType ??= typeArgument(node);
212
+ } else if (call === "output" && argument) {
213
+ parts.outputs.push(argument);
214
+ }
215
+ const nested = node === playFunction ? false : insideFunction || FUNCTION_TYPES.has(node.type);
216
+ childNodes(node).forEach((child) => visit(child, nested));
217
+ };
218
+ visit(program, playFunction !== null);
219
+ return parts;
220
+ }
221
+ function usesRuntime(node, contextName) {
222
+ if (node.type === "AwaitExpression" || node.type === "Identifier" && node.name === contextName) {
223
+ return true;
224
+ }
225
+ if (FUNCTION_TYPES.has(node.type)) return false;
226
+ return childNodes(node).some((child) => usesRuntime(child, contextName));
227
+ }
228
+ function scriptCallName(node, contextName) {
229
+ if (_optionalChain([node, 'optionalAccess', _16 => _16.type]) !== "CallExpression" || !isAstNode(node.callee)) return null;
230
+ const callee = node.callee;
231
+ if (callee.type !== "MemberExpression" || callee.computed || !isAstNode(callee.object) || callee.object.type !== "Identifier" || callee.object.name !== contextName || !isAstNode(callee.property)) {
232
+ return null;
233
+ }
234
+ const name = callee.property.name;
235
+ return name === "config" || name === "input" || name === "output" ? name : null;
236
+ }
237
+ function typeArgument(call) {
238
+ const instantiation = _nullishCoalesce(call.typeArguments, () => ( call.typeParameters));
239
+ return isAstNode(instantiation) && Array.isArray(instantiation.params) ? _nullishCoalesce(instantiation.params.find(isAstNode), () => ( null)) : null;
240
+ }
241
+ function wrapScriptPlay(source, script, { typed }) {
242
+ const { entry, entryCall } = script;
243
+ const unknownType = typed ? ": unknown" : "";
244
+ const anyType = typed ? ": any" : "";
245
+ const runtimeImport = defaultImportName(
246
+ headerOf(programOf(source)).find(isSdkImport)
247
+ ) ? `import { runScriptPlay as __deeplineRunScriptPlay } from '${SCRIPT_SDK}';` : `import ${SCRIPT_SDK}, { runScriptPlay as __deeplineRunScriptPlay } from '${SCRIPT_SDK}';`;
248
+ const entryBindings = entry ? ` let __deeplineEntry${anyType}; let __deeplineEntryResult${anyType};` : "";
249
+ const prefix = `${runtimeImport} export default async function (__deeplineContext${unknownType}, __deeplineInput${anyType}) { return __deeplineRunScriptPlay(__deeplineContext, __deeplineInput, async () => {${entryBindings}`;
250
+ const edits = [
251
+ {
252
+ at: script.headerEnd,
253
+ text: script.headerEnd === 0 ? `${prefix} ` : ` ${prefix}`
254
+ }
255
+ ];
256
+ const configExport = configExportOf(programOf(source));
257
+ if (configExport) {
258
+ const declared = configExport.declaration;
259
+ edits.push({
260
+ at: configExport.start,
261
+ end: declared.start,
262
+ text: blank(
263
+ source.slice(configExport.start, declared.start)
264
+ )
265
+ });
266
+ }
267
+ let entryName = "__deeplineEntry";
268
+ if (entry) {
269
+ const statement = entry.exportStatement;
270
+ const declared = statement.declaration;
271
+ if (entry.exportedAs === "specifier") {
272
+ entryName = entry.name;
273
+ edits.push({
274
+ at: statement.start,
275
+ end: statement.end,
276
+ text: blank(
277
+ source.slice(statement.start, statement.end)
278
+ )
279
+ });
280
+ } else if (entry.exportedAs === "declaration" && entry.name) {
281
+ entryName = entry.name;
282
+ edits.push({
283
+ at: statement.start,
284
+ end: declared.start,
285
+ text: blank(
286
+ source.slice(statement.start, declared.start)
287
+ )
288
+ });
289
+ } else {
290
+ edits.push({
291
+ at: statement.start,
292
+ end: declared.start,
293
+ text: "__deeplineEntry = "
294
+ });
295
+ if (entry.exportedAs === "declaration") {
296
+ edits.push({ at: statement.end, text: ";" });
297
+ }
298
+ }
299
+ if (entryCall) {
300
+ edits.push(
301
+ { at: entryCall.start, text: "(__deeplineEntryResult = " },
302
+ { at: entryCall.end, text: ")" }
303
+ );
304
+ }
305
+ }
306
+ const dispatch = !entry ? "" : entryCall ? " return await __deeplineEntryResult;" : (
307
+ // A play function that takes no input is called without one.
308
+ ` return await ${entryName}(${entry.node.params.length ? "__deeplineInput" : ""});`
309
+ );
310
+ return edits.sort(
311
+ (left, right) => right.at - left.at || (_nullishCoalesce(right.end, () => ( right.at))) - (_nullishCoalesce(left.end, () => ( left.at)))
312
+ ).reduce(
313
+ (text, edit) => text.slice(0, edit.at) + edit.text + text.slice(_nullishCoalesce(edit.end, () => ( edit.at))),
314
+ source
315
+ ) + `
316
+ ;${dispatch} }); }
317
+ `;
318
+ }
319
+ function blank(text) {
320
+ return text.replace(/[^\n]/g, " ");
321
+ }
322
+ function validateScriptPlay(source, script) {
323
+ const { contextName, entry } = script;
324
+ const program = programOf(source);
325
+ const statements = program.body;
326
+ const defaultExport = statements.find(isDefaultExport);
327
+ if (defaultExport && !entry) {
328
+ fail(
329
+ source,
330
+ defaultExport,
331
+ "The default export must be the play function: export default async function (input) { ... return { ... }; }."
332
+ );
333
+ }
334
+ if (entry) {
335
+ const calls = entryCallsOf(program, entry);
336
+ if (calls.length > 1) {
337
+ fail(
338
+ source,
339
+ calls[1],
340
+ `The play function is called ${calls.length} times at the top of the file; the runtime runs it once per run. Call it once, or not at all.`
341
+ );
342
+ }
343
+ const moduleResult = (node, insideFunction) => {
344
+ const call = scriptCallName(node, contextName);
345
+ if (!insideFunction && (node.type === "ReturnStatement" || call === "output")) {
346
+ fail(
347
+ source,
348
+ node,
349
+ "The play function's return is the play's result; this top-level result would compete with it. Return the result from the play function."
350
+ );
351
+ }
352
+ const nested = insideFunction || FUNCTION_TYPES.has(node.type);
353
+ childNodes(node).forEach((child) => moduleResult(child, nested));
354
+ };
355
+ moduleResult(program, false);
356
+ }
357
+ const lateImport = statements.slice(headerOf(program).length).find((node) => node.type === "ImportDeclaration");
358
+ if (lateImport) {
359
+ fail(
360
+ source,
361
+ lateImport,
362
+ "Move this import above the play code; imports come first in a script play."
363
+ );
364
+ }
365
+ const topLevelConfig = new Set(
366
+ statements.map(
367
+ (node) => node.type === "ExpressionStatement" ? node.expression : null
368
+ ).filter((node) => isAstNode(node))
369
+ );
370
+ const configExport = configExportOf(program);
371
+ if (configExport) {
372
+ const config = configObjectOf(configExport);
373
+ if (!config) {
374
+ fail(
375
+ source,
376
+ configExport,
377
+ "export const config must be one object literal, e.g. export const config = { description: '...' };"
378
+ );
379
+ }
380
+ validateConfigName(source, config);
381
+ }
382
+ const configCalls = [];
383
+ const inputTypes = /* @__PURE__ */ new Set();
384
+ const visit = (node) => {
385
+ const call = scriptCallName(node, contextName);
386
+ const args = Array.isArray(node.arguments) ? node.arguments : [];
387
+ if (call === "config") {
388
+ configCalls.push(node);
389
+ if (!topLevelConfig.has(node)) {
390
+ fail(
391
+ source,
392
+ node,
393
+ `${contextName}.config(...) must be its own top-level statement.`
394
+ );
395
+ }
396
+ if (args.length !== 1 || !isAstNode(args[0]) || args[0].type !== "ObjectExpression") {
397
+ fail(
398
+ source,
399
+ node,
400
+ `${contextName}.config(...) takes one object literal, e.g. ${contextName}.config({ description: '...' }).`
401
+ );
402
+ }
403
+ validateConfigName(source, args[0]);
404
+ if (configCalls.length > 1) {
405
+ fail(source, node, `${contextName}.config(...) may appear only once.`);
406
+ }
407
+ if (configExport) {
408
+ fail(
409
+ source,
410
+ node,
411
+ `The play config is declared twice: export const config (line ${lineOf(source, configExport)}) and ${contextName}.config(...) (line ${lineOf(source, node)}). Keep only export const config.`
412
+ );
413
+ }
414
+ } else if (call === "input") {
415
+ if (args.length > 0) {
416
+ fail(
417
+ source,
418
+ node,
419
+ `${contextName}.input() takes no arguments; declare the shape as a type: ${contextName}.input<{ domain: string }>().`
420
+ );
421
+ }
422
+ const type = typeArgument(node);
423
+ if (type)
424
+ inputTypes.add(source.slice(type.start, type.end));
425
+ if (inputTypes.size > 1) {
426
+ fail(
427
+ source,
428
+ node,
429
+ `${contextName}.input<T>() is called with different types (${[...inputTypes].join(", ")}). Use one input type.`
430
+ );
431
+ }
432
+ }
433
+ childNodes(node).forEach(visit);
434
+ };
435
+ visit(program);
436
+ }
437
+ var SCRIPT_PLAY_MODULE_DECLARATION = `import type { DefinedPlay } from '${SCRIPT_SDK}';
438
+ declare const play: DefinedPlay<Record<string, unknown>, Record<string, unknown>>;
439
+ export default play;
440
+ `;
441
+ function validateConfigName(source, config) {
442
+ const name = (_nullishCoalesce(config.properties, () => ( []))).find(
443
+ (property) => property.type === "Property" && !property.computed && isAstNode(property.key) && (property.key.name === "name" || property.key.value === "name")
444
+ );
445
+ if (name && !(isAstNode(name.value) && name.value.type === "Literal" && typeof name.value.value === "string" && name.value.value.trim())) {
446
+ fail(source, name, "config name must be a non-empty string literal.");
447
+ }
448
+ }
449
+ function lineOf(source, node) {
450
+ return source.slice(0, node.start).split("\n").length;
451
+ }
452
+ function fail(source, node, message) {
453
+ throw new Error(`line ${lineOf(source, node)}: ${message}`);
454
+ }
455
+ function childNodes(node) {
456
+ return Object.entries(node).flatMap(
457
+ ([key, value]) => key === "loc" ? [] : Array.isArray(value) ? value.filter(isAstNode) : isAstNode(value) ? [value] : []
458
+ );
459
+ }
460
+ var programs = /* @__PURE__ */ new Map();
461
+ var MAX_PROGRAMS = 16;
462
+ function programOf(source) {
463
+ const program = programs.has(source) ? programs.get(source) : parse(source);
464
+ programs.delete(source);
465
+ programs.set(source, program);
466
+ if (programs.size > MAX_PROGRAMS) {
467
+ programs.delete(programs.keys().next().value);
468
+ }
469
+ return program;
470
+ }
471
+ function headerOf(program) {
472
+ const statements = program.body;
473
+ const firstCode = statements.findIndex(
474
+ (node) => !MODULE_SCOPE.has(node.type)
475
+ );
476
+ return firstCode === -1 ? statements : statements.slice(0, firstCode);
477
+ }
478
+ function isSdkImport(node) {
479
+ return node.type === "ImportDeclaration" && isAstNode(node.source) && node.source.value === SCRIPT_SDK;
480
+ }
481
+ function parse(source) {
482
+ try {
483
+ return TypeScriptParser.parse(source, {
484
+ ecmaVersion: "latest",
485
+ sourceType: "module",
486
+ allowHashBang: true,
487
+ // Script plays may end early with a top-level `return`.
488
+ allowReturnOutsideFunction: true
489
+ });
490
+ } catch (error) {
491
+ const looksLikeScript = /\bdeepline\s*\./.test(source) && !/\bexport\b|\bdefinePlay\b/.test(source);
492
+ if (!looksLikeScript) return null;
493
+ const line = _optionalChain([error, 'access', _17 => _17.loc, 'optionalAccess', _18 => _18.line]);
494
+ throw new Error(
495
+ `line ${_nullishCoalesce(line, () => ( "?"))}: ${error.message.replace(/ \(\d+:\d+\)$/, "")}`
496
+ );
497
+ }
498
+ }
499
+ function playForm(program) {
500
+ if (containsDefinePlayCall(program)) return null;
501
+ const configExport = configExportOf(program);
502
+ const exports = program.body.filter(
503
+ (node) => node !== configExport && /^Export|^TSExportAssignment$/.test(node.type)
504
+ );
505
+ if (exports.length === 0) return { entry: null };
506
+ const [statement] = exports;
507
+ if (exports.length !== 1 || !isDefaultExport(statement)) return null;
508
+ const entry = entryOf(program, statement);
509
+ if (entry && entry.node.params.length > 1) return null;
510
+ if (!importsRuntime(program) && (!entry || importsRuntimeName(program))) {
511
+ return null;
512
+ }
513
+ return { entry };
514
+ }
515
+ function configExportOf(program) {
516
+ return _nullishCoalesce(program.body.find(
517
+ (node) => node.type === "ExportNamedDeclaration" && !node.source && isAstNode(node.declaration) && node.declaration.type === "VariableDeclaration" && node.declaration.declarations.some(
518
+ (declarator) => declarator.id.name === "config"
519
+ )
520
+ ), () => ( null));
521
+ }
522
+ function configObjectOf(configExport) {
523
+ const declaration = configExport.declaration;
524
+ const declarators = declaration.declarations;
525
+ if (declaration.kind !== "const" || declarators.length !== 1) return null;
526
+ const init = unwrapped(declarators[0].init);
527
+ return _optionalChain([init, 'optionalAccess', _19 => _19.type]) === "ObjectExpression" ? init : null;
528
+ }
529
+ function isDefaultExport(node) {
530
+ if (node.type === "ExportDefaultDeclaration") return true;
531
+ const specifiers = _nullishCoalesce(node.specifiers, () => ( []));
532
+ return node.type === "ExportNamedDeclaration" && !node.declaration && !node.source && specifiers.length === 1 && exportedName(specifiers[0]) === "default";
533
+ }
534
+ function exportedName(specifier) {
535
+ const exported = specifier.exported;
536
+ return _nullishCoalesce(_optionalChain([exported, 'optionalAccess', _20 => _20.name]), () => ( _optionalChain([exported, 'optionalAccess', _21 => _21.value])));
537
+ }
538
+ function entryOf(program, statement) {
539
+ if (statement.type === "ExportDefaultDeclaration") {
540
+ const declared = unwrapped(statement.declaration);
541
+ if (declared && FUNCTION_TYPES.has(declared.type)) {
542
+ const id = declared.id;
543
+ return {
544
+ node: declared,
545
+ name: declared.type === "FunctionDeclaration" && id ? id.name : null,
546
+ exportedAs: declared.type === "FunctionDeclaration" ? "declaration" : "expression",
547
+ exportStatement: statement,
548
+ declaration: null
549
+ };
550
+ }
551
+ return _optionalChain([declared, 'optionalAccess', _22 => _22.type]) === "Identifier" ? boundEntry(program, statement, declared.name, "binding") : null;
552
+ }
553
+ const [specifier] = statement.specifiers;
554
+ const local = specifier.local;
555
+ return boundEntry(program, statement, local.name, "specifier");
556
+ }
557
+ function boundEntry(program, exportStatement, name, exportedAs) {
558
+ for (const node of program.body) {
559
+ if (node.type === "FunctionDeclaration" && _optionalChain([node, 'access', _23 => _23.id, 'optionalAccess', _24 => _24.name]) === name) {
560
+ return { node, name, exportedAs, exportStatement, declaration: node };
561
+ }
562
+ if (node.type !== "VariableDeclaration") continue;
563
+ for (const declarator of node.declarations) {
564
+ const init = unwrapped(declarator.init);
565
+ if (declarator.id.name === name && init && FUNCTION_TYPES.has(init.type)) {
566
+ return {
567
+ node: init,
568
+ name,
569
+ exportedAs,
570
+ exportStatement,
571
+ declaration: node
572
+ };
573
+ }
574
+ }
575
+ }
576
+ return null;
577
+ }
578
+ function entryCallsOf(program, entry) {
579
+ if (!entry.name) return [];
580
+ const calls = [];
581
+ const visit = (node) => {
582
+ if (CONDITIONAL_TYPES.has(node.type)) return;
583
+ if (node.type === "CallExpression" && isAstNode(node.callee) && node.callee.type === "Identifier" && node.callee.name === entry.name) {
584
+ calls.push(node);
585
+ }
586
+ childNodes(node).forEach(visit);
587
+ };
588
+ program.body.filter(
589
+ (node) => node !== entry.declaration && node !== entry.exportStatement
590
+ ).forEach(visit);
591
+ return calls;
592
+ }
593
+ function importsRuntime(program) {
594
+ return program.body.some(
595
+ (node) => isSdkImport(node) && defaultImportName(node) !== null
596
+ );
597
+ }
598
+ function importsRuntimeName(program) {
599
+ return program.body.some(
600
+ (node) => node.type === "ImportDeclaration" && node.specifiers.some(
601
+ (specifier) => specifier.local.name === SCRIPT_SDK
602
+ )
603
+ );
604
+ }
605
+ function containsDefinePlayCall(node) {
606
+ if (node.type === "CallExpression" && isAstNode(node.callee)) {
607
+ const callee = node.callee;
608
+ const name = callee.type === "Identifier" ? callee.name : callee.type === "MemberExpression" && isAstNode(callee.property) ? callee.property.name : null;
609
+ if (DEFINE_CALLEES.has(name)) return true;
610
+ }
611
+ return childNodes(node).some(containsDefinePlayCall);
612
+ }
613
+ function defaultImportName(importDeclaration) {
614
+ const specifier = _optionalChain([importDeclaration, 'optionalAccess', _25 => _25.specifiers, 'optionalAccess', _26 => _26.find, 'call', _27 => _27((node) => node.type === "ImportDefaultSpecifier")]);
615
+ return specifier && isAstNode(specifier.local) ? specifier.local.name : null;
616
+ }
617
+
618
+ // ../plays/play-exports.ts
619
+ var PLAY_DEFAULT_EXPORT = "default";
620
+ function getIdentifierName(node) {
621
+ return isAstNode(node) && node.type === "Identifier" ? typeof node.name === "string" ? node.name : null : null;
622
+ }
623
+ function unwrapStaticExpression(node) {
624
+ let current = node;
625
+ while (current && (current.type === "TSAsExpression" || current.type === "TSSatisfiesExpression" || current.type === "TSTypeAssertion" || current.type === "TSNonNullExpression" || current.type === "ParenthesizedExpression")) {
626
+ current = isAstNode(current.expression) ? current.expression : null;
627
+ }
628
+ return current;
629
+ }
630
+ function isDefinePlayCall(node) {
631
+ const expression = unwrapStaticExpression(node);
632
+ if (!expression || expression.type !== "CallExpression") return false;
633
+ const callee = isAstNode(expression.callee) ? expression.callee : null;
634
+ if (!callee) return false;
635
+ if (callee.type === "Identifier") {
636
+ return callee.name === "definePlay" || callee.name === "defineWorkflow";
637
+ }
638
+ if (callee.type === "MemberExpression" && !callee.computed && isAstNode(callee.property) && callee.property.type === "Identifier") {
639
+ return callee.property.name === "definePlay" || callee.property.name === "defineWorkflow";
640
+ }
641
+ return false;
642
+ }
643
+ function stringLiteralValue(node) {
644
+ const expression = unwrapStaticExpression(node);
645
+ return _optionalChain([expression, 'optionalAccess', _28 => _28.type]) === "Literal" && typeof expression.value === "string" ? expression.value : null;
646
+ }
647
+ function definePlayName(node) {
648
+ const expression = unwrapStaticExpression(node);
649
+ if (!expression || expression.type !== "CallExpression") return null;
650
+ const first = unwrapStaticExpression(
651
+ _nullishCoalesce(astArray(expression.arguments)[0], () => ( null))
652
+ );
653
+ if (_optionalChain([first, 'optionalAccess', _29 => _29.type]) !== "ObjectExpression") return stringLiteralValue(first);
654
+ return objectStringProperty(first, "id");
655
+ }
656
+ function objectStringProperty(object, propertyName) {
657
+ let value = null;
658
+ for (const property of astArray(_optionalChain([object, 'optionalAccess', _30 => _30.properties]))) {
659
+ if (property.type !== "Property" || property.computed) continue;
660
+ const key = isAstNode(property.key) ? property.key : null;
661
+ const keyName = _nullishCoalesce(getIdentifierName(key), () => ( (_optionalChain([key, 'optionalAccess', _31 => _31.type]) === "Literal" && typeof key.value === "string" ? key.value : null)));
662
+ if (keyName !== propertyName) continue;
663
+ value = stringLiteralValue(
664
+ isAstNode(property.value) ? property.value : null
665
+ );
666
+ }
667
+ return value;
668
+ }
669
+ function listPlayFileExports(sourceCode) {
670
+ const ast = parsePlaySourceForAnalysis(sourceCode);
671
+ if (!ast) return null;
672
+ const script = parseScriptPlay(sourceCode);
673
+ if (script) {
674
+ return [
675
+ {
676
+ name: PLAY_DEFAULT_EXPORT,
677
+ aliases: [],
678
+ playName: objectStringProperty(script.config, "name")
679
+ }
680
+ ];
681
+ }
682
+ const declarations = /* @__PURE__ */ new Map();
683
+ const namedExports = /* @__PURE__ */ new Map();
684
+ let defaultExpression = null;
685
+ const recordDeclarations = (declaration, exported) => {
686
+ for (const declarator of astArray(declaration.declarations)) {
687
+ const name = getIdentifierName(declarator.id);
688
+ if (!name) continue;
689
+ declarations.set(
690
+ name,
691
+ isAstNode(declarator.init) ? declarator.init : null
692
+ );
693
+ if (exported) namedExports.set(name, name);
694
+ }
695
+ };
696
+ for (const statement of astArray(ast.body)) {
697
+ if (statement.type === "VariableDeclaration") {
698
+ recordDeclarations(statement, false);
699
+ continue;
700
+ }
701
+ if (statement.type === "ExportDefaultDeclaration") {
702
+ defaultExpression = isAstNode(statement.declaration) ? statement.declaration : null;
703
+ continue;
704
+ }
705
+ if (statement.type === "TSExportAssignment") {
706
+ defaultExpression = isAstNode(statement.expression) ? statement.expression : null;
707
+ continue;
708
+ }
709
+ if (statement.type !== "ExportNamedDeclaration") continue;
710
+ if (isAstNode(statement.declaration) && statement.declaration.type === "VariableDeclaration") {
711
+ recordDeclarations(statement.declaration, true);
712
+ }
713
+ for (const specifier of astArray(statement.specifiers)) {
714
+ const localName = getIdentifierName(specifier.local);
715
+ const exportedName2 = getIdentifierName(specifier.exported);
716
+ if (localName && exportedName2) namedExports.set(exportedName2, localName);
717
+ }
718
+ }
719
+ const defaultLocalName = getIdentifierName(
720
+ unwrapStaticExpression(defaultExpression)
721
+ );
722
+ const defaultIsPlay = defaultLocalName ? isDefinePlayCall(_nullishCoalesce(declarations.get(defaultLocalName), () => ( null))) : isDefinePlayCall(defaultExpression);
723
+ const exports = [];
724
+ const aliasedLocals = /* @__PURE__ */ new Set();
725
+ if (defaultIsPlay) {
726
+ const aliases = defaultLocalName ? [...namedExports.entries()].filter(([, local]) => local === defaultLocalName).map(([exported]) => exported) : [];
727
+ if (defaultLocalName) aliasedLocals.add(defaultLocalName);
728
+ exports.push({
729
+ name: PLAY_DEFAULT_EXPORT,
730
+ aliases,
731
+ playName: definePlayName(
732
+ defaultLocalName ? _nullishCoalesce(declarations.get(defaultLocalName), () => ( null)) : defaultExpression
733
+ )
734
+ });
735
+ }
736
+ for (const [exportedName2, localName] of namedExports) {
737
+ if (exportedName2 === PLAY_DEFAULT_EXPORT) continue;
738
+ if (aliasedLocals.has(localName)) continue;
739
+ const declaration = _nullishCoalesce(declarations.get(localName), () => ( null));
740
+ if (!isDefinePlayCall(declaration)) continue;
741
+ exports.push({
742
+ name: exportedName2,
743
+ aliases: [],
744
+ playName: definePlayName(declaration)
745
+ });
746
+ }
747
+ return exports;
748
+ }
749
+ function canonicalPlayExportName(exportName, exports) {
750
+ const requested = _optionalChain([exportName, 'optionalAccess', _32 => _32.trim, 'call', _33 => _33()]) || PLAY_DEFAULT_EXPORT;
751
+ for (const entry of exports) {
752
+ if (entry.name === requested || entry.aliases.includes(requested)) {
753
+ return entry.name;
754
+ }
755
+ }
756
+ for (const entry of exports) {
757
+ if (entry.playName === requested) return entry.name;
758
+ }
759
+ return null;
760
+ }
761
+ function playExportNamesForMessage(exports) {
762
+ return exports.flatMap((entry) => [
763
+ ...entry.playName ? [entry.playName] : [],
764
+ entry.name,
765
+ ...entry.aliases
766
+ ]);
767
+ }
768
+
769
+
770
+
771
+
772
+
773
+
774
+
775
+
776
+
777
+
778
+
779
+
780
+
781
+
782
+
783
+
784
+
785
+
786
+
787
+
788
+
789
+ exports.TypeScriptParser = TypeScriptParser; exports.isAstNode = isAstNode; exports.astArray = astArray; exports.parsePlaySourceForAnalysis = parsePlaySourceForAnalysis; exports.PLAY_FILE_PATTERN = PLAY_FILE_PATTERN; exports.INLINE_PLAY_FILE = INLINE_PLAY_FILE; exports.inlinePlaySource = inlinePlaySource; exports.playNameFromPath = playNameFromPath; exports.parseScriptPlay = parseScriptPlay; exports.playRuntimeNames = playRuntimeNames; exports.isRuntimeReceiver = isRuntimeReceiver; exports.wrapScriptPlay = wrapScriptPlay; exports.validateScriptPlay = validateScriptPlay; exports.SCRIPT_PLAY_MODULE_DECLARATION = SCRIPT_PLAY_MODULE_DECLARATION; exports.PLAY_DEFAULT_EXPORT = PLAY_DEFAULT_EXPORT; exports.isDefinePlayCall = isDefinePlayCall; exports.listPlayFileExports = listPlayFileExports; exports.canonicalPlayExportName = canonicalPlayExportName; exports.playExportNamesForMessage = playExportNamesForMessage;