deepline 0.3.546 → 0.3.548
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/dist/bundling-sources/sdk/src/client-core.ts +13 -0
- package/dist/bundling-sources/sdk/src/index.ts +7 -1
- package/dist/bundling-sources/sdk/src/integrations.ts +17 -7
- package/dist/bundling-sources/sdk/src/play.ts +71 -0
- package/dist/bundling-sources/sdk/src/release.ts +1 -1
- package/dist/bundling-sources/sdk/src/runs/watch-polling.ts +13 -4
- package/dist/bundling-sources/sdk/src/types.ts +33 -0
- package/dist/bundling-sources/shared_libs/integration-contracts/calendar-delegation.ts +7 -0
- package/dist/bundling-sources/shared_libs/monitors/provider-monitor-batch-operation.ts +2 -0
- package/dist/bundling-sources/shared_libs/monitors/tracking-provider-guidance.ts +1 -0
- package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +19 -1
- package/dist/bundling-sources/shared_libs/play-data-plane/r2.ts +17 -2
- package/dist/bundling-sources/shared_libs/play-runtime/async-operation.ts +57 -5
- package/dist/bundling-sources/shared_libs/play-runtime/context.ts +295 -52
- package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +10 -1
- package/dist/bundling-sources/shared_libs/play-runtime/docflow-decision-tracker.ts +135 -0
- package/dist/bundling-sources/shared_libs/play-runtime/docflow-fail-open.ts +177 -0
- package/dist/bundling-sources/shared_libs/play-runtime/docflow-node-io.ts +99 -2
- package/dist/bundling-sources/shared_libs/play-runtime/durable-runs-rollout.ts +16 -10
- package/dist/bundling-sources/shared_libs/play-runtime/fenced-call-diagnostics.ts +211 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-capacity-policy.ts +52 -14
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +68 -2
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-progress.ts +18 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +68 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-capacity.ts +100 -3
- package/dist/bundling-sources/shared_libs/play-runtime/tool-cache-policy.ts +9 -1
- package/dist/bundling-sources/shared_libs/play-runtime/tool-result.ts +48 -0
- package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +6 -1
- package/dist/bundling-sources/shared_libs/plays/bundling/index.ts +716 -51
- package/dist/bundling-sources/shared_libs/plays/docflow-decision-arms.ts +146 -0
- package/dist/bundling-sources/shared_libs/plays/docflow-flow-order.ts +94 -0
- package/dist/bundling-sources/shared_libs/plays/docflow-unreached-reason.ts +10 -1
- package/dist/bundling-sources/shared_libs/plays/docflow.ts +787 -117
- package/dist/bundling-sources/shared_libs/plays/share/static-pipeline-summary.ts +8 -2
- package/dist/bundling-sources/shared_libs/plays/static-pipeline.ts +6 -0
- package/dist/bundling-sources/shared_libs/plays/trigger-config-contract.ts +13 -0
- package/dist/bundling-sources/shared_libs/product-notifications/billing-sales.ts +25 -0
- package/dist/bundling-sources/shared_libs/security/email-blacklist.ts +3 -0
- package/dist/bundling-sources/shared_libs/security/email-domain.ts +24 -0
- package/dist/bundling-sources/shared_libs/security/secret-redaction.ts +56 -0
- package/dist/cli/auth-7UJFY5BY.js +43 -0
- package/dist/cli/{auth-KFWG72AZ.mjs → auth-YOOVLLUL.mjs} +5 -5
- package/dist/cli/{billing-MMZ336HO.mjs → billing-2NCNX6L2.mjs} +10 -10
- package/dist/cli/{billing-OQVOAZ4S.js → billing-HETIOUD6.js} +96 -96
- package/dist/cli/{chunk-JVOUQFHT.js → chunk-2OG2KBYJ.js} +1 -1
- package/dist/cli/{chunk-JA633HRV.mjs → chunk-3QRU6RY7.mjs} +3 -3
- package/dist/cli/{chunk-TI6DTURF.js → chunk-4WAM6TLD.js} +7 -1
- package/dist/cli/{chunk-RO66FPTS.mjs → chunk-53QLWPZK.mjs} +1 -1
- package/dist/cli/{chunk-6LG7MLJ2.js → chunk-5OJOFUMO.js} +44 -44
- package/dist/cli/{chunk-F2VEFMU5.js → chunk-5XFJBIQT.js} +13 -13
- package/dist/cli/{chunk-UQJBV5PM.js → chunk-5XXPP3PR.js} +10 -10
- package/dist/cli/{chunk-6FBDTYR2.mjs → chunk-64BFUBXX.mjs} +2 -2
- package/dist/cli/{chunk-VAT2SXFF.js → chunk-6GIZNOXQ.js} +12 -12
- package/dist/cli/{chunk-7MY7KWJS.mjs → chunk-7AJ5V3BK.mjs} +1 -1
- package/dist/cli/{chunk-MEGHIX4M.js → chunk-7H6TQ6W2.js} +5 -5
- package/dist/cli/{chunk-PMDHY2YK.js → chunk-7JIOJLTS.js} +7 -7
- package/dist/cli/{chunk-EEJHB76U.js → chunk-7UJZWI5Z.js} +12 -12
- package/dist/cli/{chunk-X5KOHDJN.mjs → chunk-ATTURFOV.mjs} +1 -1
- package/dist/cli/{chunk-SH32HL7I.js → chunk-AUYBBFPT.js} +53 -53
- package/dist/cli/{chunk-JCWNF44W.js → chunk-BDBEEV6X.js} +22 -22
- package/dist/cli/{chunk-WKHPLBJK.js → chunk-BWJZ4NQJ.js} +15 -15
- package/dist/cli/{chunk-2JHYYB3F.js → chunk-CSPHSNBW.js} +3 -3
- package/dist/cli/{chunk-4AZLGNXV.js → chunk-CXZLHBNK.js} +4 -4
- package/dist/cli/{chunk-J65HJCJO.mjs → chunk-F4ON5COB.mjs} +2 -2
- package/dist/cli/{chunk-KUK7ARXA.mjs → chunk-FMQA7UZZ.mjs} +2 -2
- package/dist/cli/{chunk-UREAIHUU.mjs → chunk-FUUYWEF4.mjs} +3 -3
- package/dist/cli/{chunk-HXIR3VQL.mjs → chunk-FZHMNK6F.mjs} +7 -1
- package/dist/cli/{chunk-PU3ZAG6V.mjs → chunk-GCEGQ7TQ.mjs} +1 -1
- package/dist/cli/{chunk-BLYW6FFB.js → chunk-GJA2PRHJ.js} +2 -2
- package/dist/cli/{chunk-TBWYZOSV.js → chunk-GUIYFOG2.js} +3 -3
- package/dist/cli/{chunk-BTFUAGHC.js → chunk-HDLMX7SG.js} +16 -16
- package/dist/cli/{chunk-VTK3HGMN.mjs → chunk-HIMZ57QD.mjs} +5 -5
- package/dist/cli/{chunk-JYG4XZLT.js → chunk-HTZIJORU.js} +99 -99
- package/dist/cli/{chunk-VPERQ3U6.mjs → chunk-HU3DDLGD.mjs} +5 -5
- package/dist/cli/{chunk-H7Q5IDO3.js → chunk-I2JIWKCQ.js} +20 -20
- package/dist/cli/{chunk-MXQP7CXZ.js → chunk-IIWXBRDK.js} +3 -3
- package/dist/cli/{chunk-MI7X6V6V.mjs → chunk-IQBXX54G.mjs} +3 -3
- package/dist/cli/{chunk-SYTWWVIQ.js → chunk-JQWX377P.js} +5 -5
- package/dist/cli/{chunk-Z3UEBFIN.js → chunk-LAVPP6WD.js} +41 -41
- package/dist/cli/{chunk-JCH4UNNS.js → chunk-M2OZORIH.js} +2 -2
- package/dist/cli/{chunk-Z7SXGOIQ.mjs → chunk-MF7PCM6C.mjs} +1 -1
- package/dist/cli/{chunk-7ZW67ME6.mjs → chunk-MQSKSISW.mjs} +1 -1
- package/dist/cli/{chunk-JARZ47OP.mjs → chunk-MWQ4WWZF.mjs} +2 -2
- package/dist/cli/{chunk-EEG46QZY.mjs → chunk-NFMX7BRF.mjs} +2 -2
- package/dist/cli/{chunk-VXTTAYOT.mjs → chunk-OGDQFVCP.mjs} +3 -3
- package/dist/cli/{chunk-3DUNNZB6.mjs → chunk-OQCYSLML.mjs} +4 -4
- package/dist/cli/{chunk-5W4ENHWM.js → chunk-PVE3A2BO.js} +285 -264
- package/dist/cli/{chunk-F5YQXCP3.js → chunk-PVQCX6KQ.js} +50 -7
- package/dist/cli/{chunk-GYTSDSQD.mjs → chunk-QQBRXMZM.mjs} +11 -11
- package/dist/cli/{chunk-6Y5TU3R7.mjs → chunk-QZ74ZC55.mjs} +1 -1
- package/dist/cli/{chunk-5OEFXAKP.mjs → chunk-RMCCB3XY.mjs} +50 -7
- package/dist/cli/{chunk-5V7NZKGG.js → chunk-T3RDWG5J.js} +2 -2
- package/dist/cli/{chunk-OAKWSLKS.mjs → chunk-TKGFHRHE.mjs} +28 -7
- package/dist/cli/{chunk-HJR2DDJS.mjs → chunk-U35ZLVBA.mjs} +2 -2
- package/dist/cli/{chunk-ND7SFRQL.js → chunk-U7HJXE6Y.js} +2 -2
- package/dist/cli/{chunk-LX2TC3HO.mjs → chunk-UBQQR56I.mjs} +4 -4
- package/dist/cli/{chunk-5VNQMVCU.js → chunk-VK2GSTRN.js} +26 -26
- package/dist/cli/{chunk-K2XELBPF.mjs → chunk-VSACOMIA.mjs} +5 -5
- package/dist/cli/{chunk-IVWU7SJC.js → chunk-WI4MCR7M.js} +5 -5
- package/dist/cli/{chunk-LIJKRDDG.js → chunk-WIHQAZPV.js} +6 -6
- package/dist/cli/{chunk-LHE2TSV6.mjs → chunk-WVZF4DU7.mjs} +1 -1
- package/dist/cli/{chunk-2HSZCQMT.mjs → chunk-WYT3H6JD.mjs} +1 -1
- package/dist/cli/{chunk-GOOF7E2B.mjs → chunk-XKEBQVCP.mjs} +5 -5
- package/dist/cli/{chunk-P7A3H6G5.mjs → chunk-XU3D2KFR.mjs} +1 -1
- package/dist/cli/command-docs.js +2 -2
- package/dist/cli/command-docs.mjs +1 -1
- package/dist/cli/concurrent-runs-help-A2IQVZRJ.js +21 -0
- package/dist/cli/{concurrent-runs-help-C2O5YKQA.mjs → concurrent-runs-help-FDCCZ45D.mjs} +6 -6
- package/dist/cli/{csv-Z4DNGR54.mjs → csv-GJYLQ52D.mjs} +4 -4
- package/dist/cli/{csv-MJDNOIQJ.js → csv-OCEQWZO3.js} +13 -13
- package/dist/cli/{db-4RL2BNOF.mjs → db-5MA2UUHQ.mjs} +7 -7
- package/dist/cli/{db-S5QVPK5E.js → db-G5QGXFAX.js} +28 -28
- package/dist/cli/{describe-L4P5SZLQ.mjs → describe-4DOJ4DHA.mjs} +19 -19
- package/dist/cli/describe-SD7DRTBW.js +50 -0
- package/dist/cli/describe-core.d.mts +4 -4
- package/dist/cli/describe-core.d.ts +4 -4
- package/dist/cli/{executions-RR6O3XK5.mjs → executions-C7SMBHHB.mjs} +7 -7
- package/dist/cli/{executions-MFZ2Z36O.js → executions-IYEVUPJI.js} +9 -9
- package/dist/cli/{feedback-YDAG7VH2.js → feedback-GYAF46GA.js} +14 -14
- package/dist/cli/{feedback-EQBQ3ABB.mjs → feedback-XUU2UKM6.mjs} +6 -6
- package/dist/cli/git-7YYVMY6L.js +25 -0
- package/dist/cli/{git-YGLCCU35.mjs → git-WVCMK5AH.mjs} +5 -5
- package/dist/cli/index.js +146 -146
- package/dist/cli/index.mjs +45 -45
- package/dist/cli/{integrations-FWYXSBHK.mjs → integrations-FXADGAX2.mjs} +11 -9
- package/dist/cli/{integrations-IQXYMRMW.js → integrations-YYBJJFVX.js} +19 -17
- package/dist/cli/{legacy-noops-I4YRIX5F.mjs → legacy-noops-LJY7LDUE.mjs} +6 -6
- package/dist/cli/{legacy-noops-U7LI7UXC.js → legacy-noops-REZCYES2.js} +9 -9
- package/dist/cli/{mcp-GX2UKKWU.js → mcp-L5PURE5S.js} +24 -24
- package/dist/cli/{mcp-QJBMB6VS.mjs → mcp-XSB3ZJFR.mjs} +4 -4
- package/dist/cli/{monitors-WCJYINGX.js → monitors-I5EIHSGV.js} +119 -101
- package/dist/cli/{monitors-Z6EGKYJP.mjs → monitors-UBPF2OLO.mjs} +26 -8
- package/dist/cli/{org-NNHICBR2.mjs → org-PHHIN2ER.mjs} +7 -7
- package/dist/cli/{org-7SKG423N.js → org-SGSTGGUD.js} +89 -89
- package/dist/cli/{play-CXDFPJ7Z.mjs → play-LEJNJLWY.mjs} +295 -67
- package/dist/cli/{play-4P4DTG3Q.js → play-WQEKMANL.js} +897 -669
- package/dist/cli/{providers-VQLQ7DTR.mjs → providers-3W26ZDAV.mjs} +7 -7
- package/dist/cli/{providers-EE4TUE3O.js → providers-RSDXBXIS.js} +10 -10
- package/dist/cli/{quickstart-IYNJRB5G.mjs → quickstart-LGJD2M36.mjs} +4 -4
- package/dist/cli/{quickstart-RVXHK4WA.js → quickstart-U3QX4EMI.js} +6 -6
- package/dist/cli/{run-R3F34KU3.js → run-F2UPZUJS.js} +45 -45
- package/dist/cli/{run-VBQPPMEX.mjs → run-YWZ3W5HK.mjs} +25 -25
- package/dist/cli/search-K6ANAXLF.js +32 -0
- package/dist/cli/{search-B7R62HX5.mjs → search-O2OJH3PY.mjs} +8 -8
- package/dist/cli/{search-output-LNQQXIGZ.mjs → search-output-H5BF6SJ3.mjs} +4 -4
- package/dist/cli/{search-output-LWHWEPOT.js → search-output-W7OCBYBU.js} +6 -6
- package/dist/cli/{secrets-NM3VAJLO.mjs → secrets-65XCAA7U.mjs} +7 -7
- package/dist/cli/{secrets-QBOZ7WTD.js → secrets-BN4GYVRI.js} +16 -16
- package/dist/cli/sessions-M52QWLA6.js +22 -0
- package/dist/cli/{sessions-R5BSIJ4I.mjs → sessions-SVEVESCQ.mjs} +6 -6
- package/dist/cli/{settings-POYWKNRD.js → settings-7YMDAFCN.js} +86 -86
- package/dist/cli/{settings-S4PN7WLY.mjs → settings-HAU2NP2H.mjs} +13 -13
- package/dist/cli/{setup-PFLXVBTL.mjs → setup-5RXHZ6YI.mjs} +9 -9
- package/dist/cli/{setup-VHB4Z654.js → setup-G37QXQGM.js} +49 -49
- package/dist/cli/{skills-W2TELEU7.mjs → skills-Q7A3XFAU.mjs} +7 -7
- package/dist/cli/skills-ZK4D5BJW.js +36 -0
- package/dist/cli/tools-DBZTLYFM.js +57 -0
- package/dist/cli/{tools-M4FA6N3Y.mjs → tools-ZG4NYRGB.mjs} +18 -18
- package/dist/cli/{update-W7LIHEA7.mjs → update-2CMZTZCL.mjs} +9 -9
- package/dist/cli/update-LC5HGEEH.js +34 -0
- package/dist/cli/{views-KTVPV6UP.mjs → views-A6IIY4OQ.mjs} +7 -7
- package/dist/cli/{views-DJXAGD7V.js → views-XUMDMDIE.js} +22 -22
- package/dist/cli/{workflow-NVZDJKH2.js → workflow-4EEW6MCD.js} +18 -18
- package/dist/cli/{workflow-LGKCRODX.mjs → workflow-74MYISHU.mjs} +8 -8
- package/dist/{client-Tp1LSULB.d.mts → client-D1uWA2Vc.d.mts} +1 -1
- package/dist/{client-CCyWJqAI.d.ts → client-Hz7SsBXs.d.ts} +1 -1
- package/dist/{client-core-BpYiYEfu.d.ts → client-core-D3Ad7Flt.d.ts} +554 -504
- package/dist/{client-core-D8eCZz3O.d.mts → client-core-Db_e63Hb.d.mts} +554 -504
- package/dist/{compiler-manifest-EBWEUj0b.d.ts → compiler-manifest-BqwVrOri.d.mts} +38 -18
- package/dist/{compiler-manifest-EBWEUj0b.d.mts → compiler-manifest-BqwVrOri.d.ts} +38 -18
- package/dist/{errors-CParKUQR.d.mts → errors-BU8FB99X.d.mts} +1 -1
- package/dist/{errors-Qt0OTA7_.d.ts → errors-DfVN_FUG.d.ts} +1 -1
- package/dist/{index-CoqDkIw0.d.ts → index-BGnvtYGc.d.ts} +6 -1
- package/dist/{index-BMUVCNp7.d.mts → index-DjZgwpGw.d.mts} +6 -1
- package/dist/index.d.mts +28 -8
- package/dist/index.d.ts +28 -8
- package/dist/index.js +64 -39
- package/dist/index.mjs +32 -7
- package/dist/install-integrity.json +133 -128
- package/dist/plays/bundle-play-file.d.mts +3 -3
- package/dist/plays/bundle-play-file.d.ts +3 -3
- package/dist/plays/bundle-play-file.mjs +620 -124
- package/dist/plays/play-description.d.mts +3 -3
- package/dist/plays/play-description.d.ts +3 -3
- package/dist/plays/run-request.d.mts +2 -2
- package/dist/plays/run-request.d.ts +2 -2
- package/dist/release.d.mts +1 -1
- package/dist/release.d.ts +1 -1
- package/dist/release.js +2 -2
- package/dist/release.mjs +1 -1
- package/dist/server.d.mts +4 -4
- package/dist/server.d.ts +4 -4
- package/dist/server.js +6 -6
- package/dist/server.mjs +4 -4
- package/package.json +1 -1
- package/dist/cli/auth-W32GMYND.js +0 -43
- package/dist/cli/concurrent-runs-help-6QT7ZR4W.js +0 -21
- package/dist/cli/describe-VLU2LUDJ.js +0 -50
- package/dist/cli/git-E6W44F5M.js +0 -25
- package/dist/cli/search-UUVFXZRA.js +0 -32
- package/dist/cli/sessions-K3PD73Q2.js +0 -22
- package/dist/cli/skills-QNE2EYT3.js +0 -36
- package/dist/cli/tools-3RLI4HGF.js +0 -57
- package/dist/cli/update-UT6KIW2W.js +0 -34
|
@@ -202,6 +202,11 @@ export type BundledPlayFileSuccess = {
|
|
|
202
202
|
packagedFiles: PlayLocalFileReference[];
|
|
203
203
|
unresolvedFileReferences: PlayLocalFileDiscoveryError[];
|
|
204
204
|
importedPlayDependencies: ImportedPlayDependency[];
|
|
205
|
+
/**
|
|
206
|
+
* Diagram boxes (or files) left untracked by a fresh build, and why.
|
|
207
|
+
* Display-only: tracking never fails a bundle. Absent on a cache hit.
|
|
208
|
+
*/
|
|
209
|
+
docflowInstrumentationWarnings?: string[];
|
|
205
210
|
};
|
|
206
211
|
|
|
207
212
|
export type BundledPlayFileFailure = {
|
|
@@ -1564,6 +1569,11 @@ const DOCFLOW_INJECTED_CONTEXT_NAME = '__deeplineDocflowContext';
|
|
|
1564
1569
|
type DocflowContextResolution =
|
|
1565
1570
|
/** The run function's first parameter is a plain identifier. */
|
|
1566
1571
|
| { kind: 'named'; name: string }
|
|
1572
|
+
/**
|
|
1573
|
+
* No context is in scope (a helper function): read the run's context from
|
|
1574
|
+
* the SDK's async-local store via {@link DOCFLOW_STORE_CONTEXT_READER}.
|
|
1575
|
+
*/
|
|
1576
|
+
| { kind: 'store' }
|
|
1567
1577
|
/** The run function declares no parameters; one is injected at `at`. */
|
|
1568
1578
|
| { kind: 'inject'; name: string; at: number }
|
|
1569
1579
|
/** The run function exists but its context cannot be addressed. */
|
|
@@ -1753,7 +1763,14 @@ function docflowObservedExpression(input: {
|
|
|
1753
1763
|
? `{throw (${input.expression})}`
|
|
1754
1764
|
: `(${input.expression})`;
|
|
1755
1765
|
const callback = input.awaitsResult ? `async()=>${body}` : `()=>${body}`;
|
|
1756
|
-
|
|
1766
|
+
// Fail-open by construction, whatever runtime runs the artifact: `once`
|
|
1767
|
+
// executes the authored expression at most once and replays its outcome, the
|
|
1768
|
+
// observer's return value is ignored and anything it throws is swallowed,
|
|
1769
|
+
// and the expression's own value or throw is what the Play sees — the same
|
|
1770
|
+
// object, the same Promise instance. An observer that never calls `once`
|
|
1771
|
+
// still leaves the statement executed exactly once. No global identifier is
|
|
1772
|
+
// referenced: authored code may shadow `undefined`, `Promise`, or `Error`.
|
|
1773
|
+
const observation = `((runtimeContext,inputCaptures,execute)=>{let state=0,value,error;const once=()=>{if(state===0){state=1;try{value=execute();state=2}catch(thrown){error=thrown;state=3}}if(state===3)throw error;return value};try{if(runtimeContext!=null&&typeof runtimeContext.__deeplineObserveDocflowNode==="function")runtimeContext.__deeplineObserveDocflowNode(${JSON.stringify(input.nodeId)},inputCaptures,${JSON.stringify(input.outputs)},once)}catch(ignored){}return once()})(${input.contextName},${docflowInputCaptureSource(input.inputs)},${callback})`;
|
|
1757
1774
|
// Parenthesize the awaited form so it is self-delimiting at every source
|
|
1758
1775
|
// boundary, including compact `return{...}` syntax. This avoids relying on
|
|
1759
1776
|
// whitespace repair around a character-offset replacement.
|
|
@@ -1781,22 +1798,434 @@ function expressionContainsTopLevelAwait(expression: AstNode): boolean {
|
|
|
1781
1798
|
return false;
|
|
1782
1799
|
}
|
|
1783
1800
|
|
|
1801
|
+
export type PlayDocflowInstrumentationOptions = {
|
|
1802
|
+
/**
|
|
1803
|
+
* Instrument an imported module rather than a play entry: these are the
|
|
1804
|
+
* entry's annotations that sit in this module (parsed against the entry's
|
|
1805
|
+
* diagram and limited to boxes it draws). Every one reads the run context
|
|
1806
|
+
* from the SDK's async-local store, because a helper has none in scope.
|
|
1807
|
+
*/
|
|
1808
|
+
helperBindings?: readonly PlayDocflowBinding[];
|
|
1809
|
+
/** Every other module in the entry's import closure, keyed by path. */
|
|
1810
|
+
moduleSources?: ReadonlyMap<string, string>;
|
|
1811
|
+
/**
|
|
1812
|
+
* Publish each definePlay run function's context to the SDK store even when
|
|
1813
|
+
* this file reads none itself, because an imported helper module does.
|
|
1814
|
+
*/
|
|
1815
|
+
bindRunContext?: boolean;
|
|
1816
|
+
};
|
|
1817
|
+
|
|
1818
|
+
/** Prelude-local function returning the run context helper nodes observe. */
|
|
1819
|
+
const DOCFLOW_STORE_CONTEXT_READER = '__deeplineDocflowRunContext';
|
|
1820
|
+
/** Prelude-local function running a play body with its context published. */
|
|
1821
|
+
const DOCFLOW_STORE_CONTEXT_BINDER = '__deeplineDocflowBindRunContext';
|
|
1822
|
+
const DOCFLOW_SDK_NAMESPACE = '__deeplineDocflowSdk';
|
|
1823
|
+
|
|
1824
|
+
/**
|
|
1825
|
+
* One line prepended to a module that observes through the run-context store.
|
|
1826
|
+
* The SDK members are read by property and type-checked at call time, so an
|
|
1827
|
+
* SDK without them (an older installed package) degrades to a pass-through
|
|
1828
|
+
* instead of failing the bundle. Function declarations hoist, so a helper
|
|
1829
|
+
* called during a circular import's initialization still finds them.
|
|
1830
|
+
*/
|
|
1831
|
+
function docflowRunContextPrelude(
|
|
1832
|
+
ast: AstNode,
|
|
1833
|
+
sourceCode: string,
|
|
1834
|
+
): DocflowInstrumentationReplacement {
|
|
1835
|
+
const isModule = astArray(ast.body).some(
|
|
1836
|
+
(statement) =>
|
|
1837
|
+
statement.type === 'ImportDeclaration' ||
|
|
1838
|
+
statement.type === 'ExportNamedDeclaration' ||
|
|
1839
|
+
statement.type === 'ExportDefaultDeclaration' ||
|
|
1840
|
+
statement.type === 'ExportAllDeclaration',
|
|
1841
|
+
);
|
|
1842
|
+
const sdk = DOCFLOW_SDK_NAMESPACE;
|
|
1843
|
+
const binding = isModule
|
|
1844
|
+
? `import * as ${sdk} from 'deepline';`
|
|
1845
|
+
: `var ${sdk}=require('deepline');`;
|
|
1846
|
+
// Both are fail-open: a missing or throwing SDK member yields "no context"
|
|
1847
|
+
// (the observation passes through) and runs the body exactly once, unbound.
|
|
1848
|
+
const value =
|
|
1849
|
+
`${binding}` +
|
|
1850
|
+
`function ${DOCFLOW_STORE_CONTEXT_READER}(){try{return (typeof ${sdk}.__deeplineCurrentDocflowContext==="function"?${sdk}.__deeplineCurrentDocflowContext():null)??{}}catch(ignored){return {}}}` +
|
|
1851
|
+
`function ${DOCFLOW_STORE_CONTEXT_BINDER}(context,body){let entered=false;const run=()=>{entered=true;return body()};try{if(typeof ${sdk}.__deeplineRunWithDocflowContext==="function")return ${sdk}.__deeplineRunWithDocflowContext(context,run)}catch(failure){if(entered)throw failure}return entered?void 0:body()} `;
|
|
1852
|
+
const at = docflowPreludeOffset(ast, sourceCode);
|
|
1853
|
+
return { start: at, end: at, value };
|
|
1854
|
+
}
|
|
1855
|
+
|
|
1856
|
+
/**
|
|
1857
|
+
* Where the prelude goes: after a hashbang (which must stay the file's first
|
|
1858
|
+
* characters) and after the directive prologue (`'use strict'` stops being a
|
|
1859
|
+
* directive once a statement precedes it), on the same line either way.
|
|
1860
|
+
*/
|
|
1861
|
+
function docflowPreludeOffset(ast: AstNode, sourceCode: string): number {
|
|
1862
|
+
let at = sourceCode.startsWith('#!') ? sourceCode.indexOf('\n') + 1 : 0;
|
|
1863
|
+
for (const statement of astArray(ast.body)) {
|
|
1864
|
+
if (
|
|
1865
|
+
statement.type !== 'ExpressionStatement' ||
|
|
1866
|
+
typeof statement.directive !== 'string'
|
|
1867
|
+
) {
|
|
1868
|
+
break;
|
|
1869
|
+
}
|
|
1870
|
+
at = astNodeBounds(statement)?.end ?? at;
|
|
1871
|
+
}
|
|
1872
|
+
return at;
|
|
1873
|
+
}
|
|
1874
|
+
|
|
1875
|
+
/**
|
|
1876
|
+
* Wraps each inline definePlay run function's body so the run's context is
|
|
1877
|
+
* published to the SDK store for its whole async flow. Edits stay on the
|
|
1878
|
+
* body's first and last lines, so no authored line moves. A run function whose
|
|
1879
|
+
* context cannot be addressed is left alone: its helper nodes then observe
|
|
1880
|
+
* nothing, as before.
|
|
1881
|
+
*/
|
|
1882
|
+
/** Identifier names a binding pattern can introduce (over-approximated). */
|
|
1883
|
+
function docflowPatternNames(pattern: unknown, names: Set<string>): void {
|
|
1884
|
+
const pending: unknown[] = [pattern];
|
|
1885
|
+
while (pending.length > 0) {
|
|
1886
|
+
const value = pending.pop();
|
|
1887
|
+
if (Array.isArray(value)) {
|
|
1888
|
+
pending.push(...value);
|
|
1889
|
+
continue;
|
|
1890
|
+
}
|
|
1891
|
+
if (!isAstNode(value)) continue;
|
|
1892
|
+
if (value.type === 'Identifier' && typeof value.name === 'string') {
|
|
1893
|
+
names.add(value.name);
|
|
1894
|
+
}
|
|
1895
|
+
for (const [key, child] of Object.entries(value)) {
|
|
1896
|
+
if (key === 'typeAnnotation') continue;
|
|
1897
|
+
if (Array.isArray(child) || isAstNode(child)) pending.push(child);
|
|
1898
|
+
}
|
|
1899
|
+
}
|
|
1900
|
+
}
|
|
1901
|
+
|
|
1902
|
+
const DOCFLOW_FUNCTION_NODE_TYPES = new Set([
|
|
1903
|
+
'FunctionDeclaration',
|
|
1904
|
+
'FunctionExpression',
|
|
1905
|
+
'ArrowFunctionExpression',
|
|
1906
|
+
]);
|
|
1907
|
+
|
|
1908
|
+
/**
|
|
1909
|
+
* Whether the run function's body redeclares a parameter with `var` or a
|
|
1910
|
+
* top-level `function`. Such a declaration shares the parameter's binding;
|
|
1911
|
+
* moved into an inner arrow it would declare a fresh, unset variable instead.
|
|
1912
|
+
*/
|
|
1913
|
+
function docflowRunBodyRedeclaresParameter(run: AstNode): boolean {
|
|
1914
|
+
const parameters = new Set<string>();
|
|
1915
|
+
docflowPatternNames(run.params, parameters);
|
|
1916
|
+
if (parameters.size === 0 || !isAstNode(run.body)) return false;
|
|
1917
|
+
const declared = new Set<string>();
|
|
1918
|
+
for (const statement of astArray(run.body.body)) {
|
|
1919
|
+
if (statement.type === 'FunctionDeclaration' && isAstNode(statement.id)) {
|
|
1920
|
+
docflowPatternNames(statement.id, declared);
|
|
1921
|
+
}
|
|
1922
|
+
}
|
|
1923
|
+
const pending: unknown[] = [run.body];
|
|
1924
|
+
while (pending.length > 0) {
|
|
1925
|
+
const value = pending.pop();
|
|
1926
|
+
if (Array.isArray(value)) {
|
|
1927
|
+
pending.push(...value);
|
|
1928
|
+
continue;
|
|
1929
|
+
}
|
|
1930
|
+
if (!isAstNode(value)) continue;
|
|
1931
|
+
if (DOCFLOW_FUNCTION_NODE_TYPES.has(value.type)) continue;
|
|
1932
|
+
if (value.type === 'VariableDeclaration' && value.kind === 'var') {
|
|
1933
|
+
for (const declaration of astArray(value.declarations)) {
|
|
1934
|
+
docflowPatternNames(declaration.id, declared);
|
|
1935
|
+
}
|
|
1936
|
+
}
|
|
1937
|
+
for (const child of Object.values(value)) {
|
|
1938
|
+
if (Array.isArray(child) || isAstNode(child)) pending.push(child);
|
|
1939
|
+
}
|
|
1940
|
+
}
|
|
1941
|
+
return [...declared].some((name) => parameters.has(name));
|
|
1942
|
+
}
|
|
1943
|
+
|
|
1944
|
+
function docflowRunContextBindings(
|
|
1945
|
+
ast: AstNode,
|
|
1946
|
+
sourceCode: string,
|
|
1947
|
+
injectedContextAt: Set<number>,
|
|
1948
|
+
warnings: string[],
|
|
1949
|
+
): DocflowInstrumentationReplacement[] {
|
|
1950
|
+
const replacements: DocflowInstrumentationReplacement[] = [];
|
|
1951
|
+
const pending: unknown[] = [ast];
|
|
1952
|
+
while (pending.length > 0) {
|
|
1953
|
+
const value = pending.pop();
|
|
1954
|
+
if (!isAstNode(value)) continue;
|
|
1955
|
+
for (const child of Object.values(value)) {
|
|
1956
|
+
if (Array.isArray(child)) pending.push(...child);
|
|
1957
|
+
else if (isAstNode(child)) pending.push(child);
|
|
1958
|
+
}
|
|
1959
|
+
const context = docflowContextFromCall(value, sourceCode);
|
|
1960
|
+
// A definePlay call names its context or has one injected; the store
|
|
1961
|
+
// kind is a helper module's, never a run function's.
|
|
1962
|
+
if (!context || context.kind === 'unsupported' || context.kind === 'store')
|
|
1963
|
+
continue;
|
|
1964
|
+
const run = definePlayRunFunction(value);
|
|
1965
|
+
if (!run || run.generator === true || !isAstNode(run.body)) continue;
|
|
1966
|
+
if (docflowRunBodyRedeclaresParameter(run)) {
|
|
1967
|
+
warnings.push(
|
|
1968
|
+
"Diagram boxes in imported helper modules are not tracked for this play: its run function redeclares a parameter with `var` or `function`, whose meaning would change if its body were wrapped. The play runs unchanged.",
|
|
1969
|
+
);
|
|
1970
|
+
continue;
|
|
1971
|
+
}
|
|
1972
|
+
const body = astNodeBounds(run.body);
|
|
1973
|
+
if (!body) continue;
|
|
1974
|
+
if (context.kind === 'inject') injectedContextAt.add(context.at);
|
|
1975
|
+
const contextName =
|
|
1976
|
+
context.kind === 'inject' ? DOCFLOW_INJECTED_CONTEXT_NAME : context.name;
|
|
1977
|
+
// Keep the body's own kind: wrapping a synchronous run function's body in
|
|
1978
|
+
// an async arrow would turn its returned value into a Promise.
|
|
1979
|
+
const arrow = run.async === true ? 'async()=>' : '()=>';
|
|
1980
|
+
if (run.body.type === 'BlockStatement') {
|
|
1981
|
+
const directives = astArray(run.body.body).filter(
|
|
1982
|
+
(statement) =>
|
|
1983
|
+
statement.type === 'ExpressionStatement' &&
|
|
1984
|
+
typeof statement.directive === 'string',
|
|
1985
|
+
);
|
|
1986
|
+
if (directives.length > 0) continue;
|
|
1987
|
+
replacements.push(
|
|
1988
|
+
{
|
|
1989
|
+
start: body.start + 1,
|
|
1990
|
+
end: body.start + 1,
|
|
1991
|
+
value: `return ${DOCFLOW_STORE_CONTEXT_BINDER}(${contextName},${arrow}{`,
|
|
1992
|
+
},
|
|
1993
|
+
{ start: body.end - 1, end: body.end - 1, value: '});' },
|
|
1994
|
+
);
|
|
1995
|
+
} else {
|
|
1996
|
+
replacements.push(
|
|
1997
|
+
{
|
|
1998
|
+
start: body.start,
|
|
1999
|
+
end: body.start,
|
|
2000
|
+
value: `${DOCFLOW_STORE_CONTEXT_BINDER}(${contextName},${arrow}(`,
|
|
2001
|
+
},
|
|
2002
|
+
{ start: body.end, end: body.end, value: '))' },
|
|
2003
|
+
);
|
|
2004
|
+
}
|
|
2005
|
+
}
|
|
2006
|
+
return replacements;
|
|
2007
|
+
}
|
|
2008
|
+
|
|
1784
2009
|
/**
|
|
1785
2010
|
* Instruments authored nodes at AST expression boundaries. Declarations,
|
|
1786
2011
|
* expressions, decisions, and returns are wrapped so the runtime reports the
|
|
1787
2012
|
* actual result or failure. Rewrites remain single-line so source mappings and
|
|
1788
2013
|
* the executable program's block scope do not change.
|
|
1789
2014
|
*/
|
|
1790
|
-
export function instrumentPlayDocflowRuntimeHits(
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
2015
|
+
export function instrumentPlayDocflowRuntimeHits(
|
|
2016
|
+
sourceCode: string,
|
|
2017
|
+
options: PlayDocflowInstrumentationOptions = {},
|
|
2018
|
+
): string {
|
|
2019
|
+
return instrumentPlayDocflowRuntimeHitsWithReport(sourceCode, options).code;
|
|
2020
|
+
}
|
|
2021
|
+
|
|
2022
|
+
export type PlayDocflowInstrumentationReport = {
|
|
2023
|
+
/** The instrumented source, or the authored source unchanged. */
|
|
2024
|
+
code: string;
|
|
2025
|
+
/** Whether `code` differs from the authored source. */
|
|
2026
|
+
instrumented: boolean;
|
|
2027
|
+
/**
|
|
2028
|
+
* Bindings (or the whole file) left untracked, and why. Tracking is
|
|
2029
|
+
* display-only: none of these ever fails a bundle.
|
|
2030
|
+
*/
|
|
2031
|
+
warnings: string[];
|
|
2032
|
+
};
|
|
2033
|
+
|
|
2034
|
+
/**
|
|
2035
|
+
* Fail-open instrumentation. Diagram tracking is display-only, so it can never
|
|
2036
|
+
* fail a bundle or change what a Play does:
|
|
2037
|
+
*
|
|
2038
|
+
* - any exception while analysing or rewriting returns the authored source;
|
|
2039
|
+
* - the rewrite only runs on an AST parsed from the exact authored text (an
|
|
2040
|
+
* AST parsed from a type-stripped transform has different offsets);
|
|
2041
|
+
* - the rewritten source must parse again, or the authored source is used;
|
|
2042
|
+
* - a binding that cannot be observed safely is skipped with a warning.
|
|
2043
|
+
*/
|
|
2044
|
+
export function instrumentPlayDocflowRuntimeHitsWithReport(
|
|
2045
|
+
sourceCode: string,
|
|
2046
|
+
options: PlayDocflowInstrumentationOptions = {},
|
|
2047
|
+
): PlayDocflowInstrumentationReport {
|
|
2048
|
+
const warnings: string[] = [];
|
|
2049
|
+
const untouched = (reason?: string): PlayDocflowInstrumentationReport => {
|
|
2050
|
+
if (reason) warnings.push(reason);
|
|
2051
|
+
return { code: sourceCode, instrumented: false, warnings };
|
|
2052
|
+
};
|
|
2053
|
+
let code: string;
|
|
2054
|
+
try {
|
|
2055
|
+
code = instrumentPlayDocflowRuntimeHitsCore(sourceCode, options, warnings);
|
|
2056
|
+
} catch (error) {
|
|
2057
|
+
return untouched(
|
|
2058
|
+
`Diagram tracking was skipped for this file: instrumentation failed (${boundedInstrumentationReason(error)}). The play runs unchanged.`,
|
|
2059
|
+
);
|
|
2060
|
+
}
|
|
2061
|
+
if (code === sourceCode) return untouched();
|
|
2062
|
+
if (!parsePlaySourceAstExact(code)) {
|
|
2063
|
+
return untouched(
|
|
2064
|
+
'Diagram tracking was skipped for this file: the instrumented source did not parse. The play runs unchanged.',
|
|
2065
|
+
);
|
|
2066
|
+
}
|
|
2067
|
+
return { code, instrumented: true, warnings };
|
|
2068
|
+
}
|
|
2069
|
+
|
|
2070
|
+
function boundedInstrumentationReason(error: unknown): string {
|
|
2071
|
+
let message: string;
|
|
2072
|
+
try {
|
|
2073
|
+
message = error instanceof Error ? error.message : String(error);
|
|
2074
|
+
} catch {
|
|
2075
|
+
message = 'unknown error';
|
|
2076
|
+
}
|
|
2077
|
+
return message.length > 300 ? `${message.slice(0, 300)}…` : message;
|
|
2078
|
+
}
|
|
2079
|
+
|
|
2080
|
+
/**
|
|
2081
|
+
* Parses exactly the given text, without the type-stripping fallback of
|
|
2082
|
+
* `parsePlaySourceAst`, so node offsets index into `sourceCode` itself.
|
|
2083
|
+
*/
|
|
2084
|
+
function parsePlaySourceAstExact(sourceCode: string): AstNode | null {
|
|
2085
|
+
try {
|
|
2086
|
+
return TypeScriptParser.parse(sourceCode, {
|
|
2087
|
+
ecmaVersion: 'latest',
|
|
2088
|
+
sourceType: 'module',
|
|
2089
|
+
allowHashBang: true,
|
|
2090
|
+
// Script plays may end early with a top-level `return`.
|
|
2091
|
+
allowReturnOutsideFunction: true,
|
|
2092
|
+
}) as unknown as AstNode;
|
|
2093
|
+
} catch {
|
|
2094
|
+
return null;
|
|
2095
|
+
}
|
|
2096
|
+
}
|
|
2097
|
+
|
|
2098
|
+
/** Start offsets of statements that sit directly in a statement list. */
|
|
2099
|
+
function docflowStatementListStarts(ast: AstNode): Set<number> {
|
|
2100
|
+
const starts = new Set<number>();
|
|
2101
|
+
const pending: unknown[] = [ast];
|
|
2102
|
+
while (pending.length > 0) {
|
|
2103
|
+
const value = pending.pop();
|
|
2104
|
+
if (!isAstNode(value)) continue;
|
|
2105
|
+
const list =
|
|
2106
|
+
value.type === 'Program' ||
|
|
2107
|
+
value.type === 'BlockStatement' ||
|
|
2108
|
+
value.type === 'StaticBlock'
|
|
2109
|
+
? value.body
|
|
2110
|
+
: value.type === 'SwitchCase'
|
|
2111
|
+
? value.consequent
|
|
2112
|
+
: null;
|
|
2113
|
+
for (const statement of astArray(list)) {
|
|
2114
|
+
// A statement before a directive would demote it to a plain string.
|
|
2115
|
+
if (
|
|
2116
|
+
statement.type === 'ExpressionStatement' &&
|
|
2117
|
+
typeof statement.directive === 'string'
|
|
2118
|
+
) {
|
|
2119
|
+
continue;
|
|
2120
|
+
}
|
|
2121
|
+
if (/^(Import|Export)/.test(statement.type)) continue;
|
|
2122
|
+
const bounds = astNodeBounds(statement);
|
|
2123
|
+
if (bounds) starts.add(bounds.start);
|
|
2124
|
+
}
|
|
2125
|
+
for (const child of Object.values(value)) {
|
|
2126
|
+
if (Array.isArray(child)) pending.push(...child);
|
|
2127
|
+
else if (isAstNode(child)) pending.push(child);
|
|
2128
|
+
}
|
|
2129
|
+
}
|
|
2130
|
+
return starts;
|
|
2131
|
+
}
|
|
2132
|
+
|
|
2133
|
+
/**
|
|
2134
|
+
* Why wrapping `expression` in an observation callback would change what it
|
|
2135
|
+
* means, or null: `yield` cannot appear in an arrow, and an anonymous function
|
|
2136
|
+
* or class initializer takes its `.name` from the declaration it sits in.
|
|
2137
|
+
*/
|
|
2138
|
+
function docflowUnwrappableReason(
|
|
2139
|
+
statement: AstNode | null,
|
|
2140
|
+
expression: AstNode,
|
|
2141
|
+
): string | null {
|
|
2142
|
+
const pending: AstNode[] = [expression];
|
|
2143
|
+
while (pending.length > 0) {
|
|
2144
|
+
const node = pending.pop()!;
|
|
2145
|
+
if (node.type === 'YieldExpression') {
|
|
2146
|
+
return 'the statement contains `yield`, which cannot move into an observation callback';
|
|
2147
|
+
}
|
|
2148
|
+
if (
|
|
2149
|
+
node !== expression &&
|
|
2150
|
+
(node.type === 'FunctionExpression' ||
|
|
2151
|
+
node.type === 'FunctionDeclaration' ||
|
|
2152
|
+
node.type === 'ArrowFunctionExpression')
|
|
2153
|
+
) {
|
|
2154
|
+
continue;
|
|
2155
|
+
}
|
|
2156
|
+
for (const child of Object.values(node)) {
|
|
2157
|
+
if (Array.isArray(child)) pending.push(...child.filter(isAstNode));
|
|
2158
|
+
else if (isAstNode(child)) pending.push(child);
|
|
2159
|
+
}
|
|
2160
|
+
}
|
|
2161
|
+
let inner: AstNode = expression;
|
|
2162
|
+
while (
|
|
2163
|
+
(inner.type === 'TSAsExpression' ||
|
|
2164
|
+
inner.type === 'TSSatisfiesExpression' ||
|
|
2165
|
+
inner.type === 'TSNonNullExpression' ||
|
|
2166
|
+
inner.type === 'TSTypeAssertion' ||
|
|
2167
|
+
inner.type === 'ParenthesizedExpression') &&
|
|
2168
|
+
isAstNode(inner.expression)
|
|
2169
|
+
) {
|
|
2170
|
+
inner = inner.expression;
|
|
2171
|
+
}
|
|
2172
|
+
const anonymousCallable =
|
|
2173
|
+
inner.type === 'ArrowFunctionExpression' ||
|
|
2174
|
+
((inner.type === 'FunctionExpression' || inner.type === 'ClassExpression') &&
|
|
2175
|
+
!isAstNode(inner.id));
|
|
2176
|
+
if (statement?.type === 'VariableDeclaration' && anonymousCallable) {
|
|
2177
|
+
return 'the declaration initializes an anonymous function or class, whose name comes from the declaration';
|
|
2178
|
+
}
|
|
2179
|
+
return null;
|
|
2180
|
+
}
|
|
2181
|
+
|
|
2182
|
+
function instrumentPlayDocflowRuntimeHitsCore(
|
|
2183
|
+
sourceCode: string,
|
|
2184
|
+
options: PlayDocflowInstrumentationOptions,
|
|
2185
|
+
warnings: string[],
|
|
2186
|
+
): string {
|
|
2187
|
+
const helperBindings = options.helperBindings;
|
|
2188
|
+
let fileBindings: readonly PlayDocflowBinding[];
|
|
2189
|
+
if (helperBindings !== undefined) {
|
|
2190
|
+
// An imported module: its annotations were already parsed against the
|
|
2191
|
+
// entry's diagram, and only the boxes that diagram draws are passed here.
|
|
2192
|
+
if (helperBindings.length === 0) return sourceCode;
|
|
2193
|
+
fileBindings = helperBindings;
|
|
2194
|
+
} else {
|
|
2195
|
+
// EVERY block's bindings, not just the export being bundled. Two exports'
|
|
2196
|
+
// statements are disjoint, so instrumenting both is correct for whichever
|
|
2197
|
+
// one runs, and the esbuild plugin never has to learn which export it is
|
|
2198
|
+
// building. The import closure is passed so a box bound in a helper module
|
|
2199
|
+
// resolves instead of failing this file's parse (and with it every box).
|
|
2200
|
+
const parsed = parsePlayDocflowFile(sourceCode, options.moduleSources);
|
|
2201
|
+
if (parsed.blocks.length === 0) return sourceCode;
|
|
2202
|
+
// A binding with a `sourcePath` sits in another module; that module's own
|
|
2203
|
+
// load instruments it (see `docflowRuntimeInstrumentationPlugin`).
|
|
2204
|
+
if (parsed.errors.length > 0) {
|
|
2205
|
+
// `plays check` reports the diagram's problems as warnings. What did not
|
|
2206
|
+
// resolve is not drawn, so only the boxes the diagrams still draw are
|
|
2207
|
+
// tracked; the play runs unchanged either way.
|
|
2208
|
+
warnings.push(
|
|
2209
|
+
`Diagram tracking skipped what did not resolve in this file's @mermaid diagram (${boundedInstrumentationReason(parsed.errors[0])}${parsed.errors.length > 1 ? `, and ${parsed.errors.length - 1} more` : ''}). The play runs unchanged.`,
|
|
2210
|
+
);
|
|
2211
|
+
fileBindings = parsed.blocks
|
|
2212
|
+
.flatMap((block) => block.docflow.bindings)
|
|
2213
|
+
.filter((binding) => !binding.sourcePath);
|
|
2214
|
+
if (fileBindings.length === 0) return sourceCode;
|
|
2215
|
+
} else {
|
|
2216
|
+
fileBindings = parsed.bindings.filter((binding) => !binding.sourcePath);
|
|
2217
|
+
}
|
|
2218
|
+
}
|
|
2219
|
+
const ast = parsePlaySourceAstExact(sourceCode);
|
|
2220
|
+
if (!ast) {
|
|
2221
|
+
warnings.push(
|
|
2222
|
+
'Diagram tracking was skipped for this file: its source could not be parsed exactly for instrumentation. The play runs unchanged.',
|
|
2223
|
+
);
|
|
2224
|
+
return sourceCode;
|
|
2225
|
+
}
|
|
1798
2226
|
const lineStarts = sourceLineStarts(sourceCode);
|
|
1799
2227
|
const replacements: DocflowInstrumentationReplacement[] = [];
|
|
2228
|
+
let statementListStarts: Set<number> | null = null;
|
|
1800
2229
|
|
|
1801
2230
|
// Several annotations may bind one statement — stacked above the dataset
|
|
1802
2231
|
// call, or on a chained `.withColumn(...)` line INSIDE it, where the bound
|
|
@@ -1820,34 +2249,44 @@ export function instrumentPlayDocflowRuntimeHits(sourceCode: string): string {
|
|
|
1820
2249
|
const parents = buildDocflowParentIndex(ast);
|
|
1821
2250
|
// A script play has no run function: its module-level runtime is the context.
|
|
1822
2251
|
const scriptContext = parseScriptPlay(sourceCode)?.contextName ?? null;
|
|
1823
|
-
|
|
2252
|
+
/** Some binding reads the run context from the SDK's async-local store. */
|
|
2253
|
+
let usesRunContextStore = false;
|
|
2254
|
+
for (const binding of fileBindings) {
|
|
1824
2255
|
// ADR 0016 rule 1: prefer the statement the `out:` symbol names; fall back
|
|
1825
2256
|
// to positional resolution. Instrumentation and `plays check` share this
|
|
1826
2257
|
// resolver, so the observed statement and the lint agree.
|
|
1827
2258
|
const resolution = resolveDocflowBinding(ast, binding, lineStarts, parents);
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
2259
|
+
// No owning definePlay and no script runtime: the binding sits in a helper
|
|
2260
|
+
// function (in this module or one the entry imports) with no context in
|
|
2261
|
+
// scope. It reads the run's context from the SDK's async-local store;
|
|
2262
|
+
// outside a run that store is empty and the observation is a pass-through.
|
|
2263
|
+
const context: DocflowContextResolution = (helperBindings === undefined
|
|
2264
|
+
? (findDocflowContext({
|
|
2265
|
+
ast,
|
|
2266
|
+
sourceCode,
|
|
2267
|
+
statement: resolution.statement,
|
|
2268
|
+
bindingLine: binding.line,
|
|
2269
|
+
lineStarts,
|
|
2270
|
+
parents,
|
|
2271
|
+
}) ??
|
|
2272
|
+
(scriptContext ? { kind: 'named' as const, name: scriptContext } : null))
|
|
2273
|
+
: null) ?? { kind: 'store' };
|
|
1841
2274
|
if (context.kind === 'unsupported') {
|
|
1842
|
-
|
|
1843
|
-
`@mermaid-node ${binding.nodeId} (line ${binding.line}) cannot be observed at runtime: ${context.reason}.`,
|
|
2275
|
+
warnings.push(
|
|
2276
|
+
`@mermaid-node ${binding.nodeId} (line ${binding.line}) cannot be observed at runtime: ${context.reason}. The box is drawn but not tracked.`,
|
|
1844
2277
|
);
|
|
2278
|
+
continue;
|
|
1845
2279
|
}
|
|
2280
|
+
if (context.kind === 'store') usesRunContextStore = true;
|
|
1846
2281
|
if (context.kind === 'inject') injectedContextAt.add(context.at);
|
|
1847
2282
|
// An injected parameter is undefined when the run function is invoked
|
|
1848
2283
|
// directly (outside the runtime), so its reads stay null-safe.
|
|
1849
2284
|
const contextName =
|
|
1850
|
-
context.kind === 'inject'
|
|
2285
|
+
context.kind === 'inject'
|
|
2286
|
+
? `(${context.name}??{})`
|
|
2287
|
+
: context.kind === 'store'
|
|
2288
|
+
? `${DOCFLOW_STORE_CONTEXT_READER}()`
|
|
2289
|
+
: context.name;
|
|
1851
2290
|
const target = docflowObservationTarget(resolution.statement);
|
|
1852
2291
|
// A binding naming a `.step('<leg>', …)` leg of a waterfall is NOT
|
|
1853
2292
|
// instrumented, and the omission is deliberate rather than a gap.
|
|
@@ -1881,20 +2320,55 @@ export function instrumentPlayDocflowRuntimeHits(sourceCode: string): string {
|
|
|
1881
2320
|
continue;
|
|
1882
2321
|
}
|
|
1883
2322
|
if (target) {
|
|
2323
|
+
const unwrappable = docflowUnwrappableReason(
|
|
2324
|
+
resolution.statement,
|
|
2325
|
+
target.expression,
|
|
2326
|
+
);
|
|
2327
|
+
if (unwrappable) {
|
|
2328
|
+
warnings.push(
|
|
2329
|
+
`@mermaid-node ${binding.nodeId} (line ${binding.line}) is not tracked: ${unwrappable}.`,
|
|
2330
|
+
);
|
|
2331
|
+
continue;
|
|
2332
|
+
}
|
|
1884
2333
|
targets.push({ ...target, contextName, binding });
|
|
1885
2334
|
continue;
|
|
1886
2335
|
}
|
|
1887
2336
|
|
|
2337
|
+
// No expression to observe (a loop, a block): mark the box reached just
|
|
2338
|
+
// before the statement. The marker is a plain statement, never awaited, so
|
|
2339
|
+
// it adds no suspension point the authored code did not have, and a
|
|
2340
|
+
// throwing or never-settling runtime marker cannot reach the Play. It only
|
|
2341
|
+
// goes where a statement may start; anywhere else the box is not tracked.
|
|
1888
2342
|
const lineStart = lineStarts[binding.line - 1];
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
2343
|
+
const statementBounds = resolution.statement
|
|
2344
|
+
? astNodeBounds(resolution.statement)
|
|
2345
|
+
: null;
|
|
2346
|
+
const indentationLength =
|
|
2347
|
+
lineStart === undefined
|
|
2348
|
+
? 0
|
|
2349
|
+
: (/^\s*/.exec(sourceCode.slice(lineStart))?.[0].length ?? 0);
|
|
2350
|
+
statementListStarts ??= docflowStatementListStarts(ast);
|
|
2351
|
+
const listStarts = statementListStarts;
|
|
2352
|
+
const at = [
|
|
2353
|
+
statementBounds?.start,
|
|
2354
|
+
lineStart === undefined ? undefined : lineStart + indentationLength,
|
|
2355
|
+
].find(
|
|
2356
|
+
(candidate): candidate is number =>
|
|
2357
|
+
candidate !== undefined && listStarts.has(candidate),
|
|
2358
|
+
);
|
|
2359
|
+
if (at === undefined) {
|
|
2360
|
+
warnings.push(
|
|
2361
|
+
`@mermaid-node ${binding.nodeId} (line ${binding.line}) is not tracked: it binds no expression and does not start a statement.`,
|
|
2362
|
+
);
|
|
2363
|
+
continue;
|
|
1897
2364
|
}
|
|
2365
|
+
replacements.push({
|
|
2366
|
+
start: at,
|
|
2367
|
+
end: at,
|
|
2368
|
+
// `void` first: a statement opening with `(` would continue a previous
|
|
2369
|
+
// line written without a semicolon (`f()\n(…)` calls f's result).
|
|
2370
|
+
value: `void ((runtimeContext)=>{try{if(runtimeContext!=null&&typeof runtimeContext.__deeplineDocflowHit==="function"){const pending=runtimeContext.__deeplineDocflowHit(${JSON.stringify(binding.nodeId)});if(pending!=null&&typeof pending.then==="function")pending.then(null,()=>{})}}catch(ignored){}})(${contextName}); `,
|
|
2371
|
+
});
|
|
1898
2372
|
}
|
|
1899
2373
|
|
|
1900
2374
|
// AST spans nest, so after sorting (container first: earliest start, then
|
|
@@ -1946,13 +2420,41 @@ export function instrumentPlayDocflowRuntimeHits(sourceCode: string): string {
|
|
|
1946
2420
|
});
|
|
1947
2421
|
innermost = false;
|
|
1948
2422
|
}
|
|
2423
|
+
// An observed expression statement opens with `(`. Where it starts a
|
|
2424
|
+
// statement after another one, a previous line written without a
|
|
2425
|
+
// semicolon would otherwise call into it (`x = f()\n(…)` calls f's
|
|
2426
|
+
// result), so it opens with `void` instead; an expression statement's
|
|
2427
|
+
// value is discarded either way.
|
|
2428
|
+
statementListStarts ??= docflowStatementListStarts(ast);
|
|
1949
2429
|
replacements.push({
|
|
1950
2430
|
start: group.start,
|
|
1951
2431
|
end: group.end,
|
|
1952
|
-
value:
|
|
2432
|
+
value: statementListStarts.has(group.start)
|
|
2433
|
+
? `void ${expression}`
|
|
2434
|
+
: expression,
|
|
1953
2435
|
});
|
|
1954
2436
|
}
|
|
1955
2437
|
|
|
2438
|
+
// The entry's run functions publish their context to the store helper
|
|
2439
|
+
// observations read. A script play's runtime already does (`runScriptPlay`).
|
|
2440
|
+
const bindRunContext =
|
|
2441
|
+
helperBindings === undefined &&
|
|
2442
|
+
!scriptContext &&
|
|
2443
|
+
(usesRunContextStore || options.bindRunContext === true);
|
|
2444
|
+
if (bindRunContext) {
|
|
2445
|
+
replacements.push(
|
|
2446
|
+
...docflowRunContextBindings(
|
|
2447
|
+
ast,
|
|
2448
|
+
sourceCode,
|
|
2449
|
+
injectedContextAt,
|
|
2450
|
+
warnings,
|
|
2451
|
+
),
|
|
2452
|
+
);
|
|
2453
|
+
}
|
|
2454
|
+
if (usesRunContextStore || bindRunContext) {
|
|
2455
|
+
replacements.push(docflowRunContextPrelude(ast, sourceCode));
|
|
2456
|
+
}
|
|
2457
|
+
|
|
1956
2458
|
for (const at of injectedContextAt) {
|
|
1957
2459
|
replacements.push({
|
|
1958
2460
|
start: at,
|
|
@@ -1962,7 +2464,7 @@ export function instrumentPlayDocflowRuntimeHits(sourceCode: string): string {
|
|
|
1962
2464
|
}
|
|
1963
2465
|
|
|
1964
2466
|
return replacements
|
|
1965
|
-
.sort((left, right) => right.start - left.start)
|
|
2467
|
+
.sort((left, right) => right.start - left.start || right.end - left.end)
|
|
1966
2468
|
.reduce(
|
|
1967
2469
|
(source, replacement) =>
|
|
1968
2470
|
`${source.slice(0, replacement.start)}${replacement.value}${source.slice(replacement.end)}`,
|
|
@@ -1976,6 +2478,7 @@ export function instrumentPlayDocflowRuntimeHits(sourceCode: string): string {
|
|
|
1976
2478
|
*/
|
|
1977
2479
|
function docflowRuntimeInstrumentationPlugin(
|
|
1978
2480
|
analyzedSources: Readonly<Record<string, string>>,
|
|
2481
|
+
entryFile: string,
|
|
1979
2482
|
scriptEntry: { path: string; source: string } | null,
|
|
1980
2483
|
): Plugin {
|
|
1981
2484
|
const customerSourceFiles = new Map(
|
|
@@ -1983,18 +2486,47 @@ function docflowRuntimeInstrumentationPlugin(
|
|
|
1983
2486
|
.filter(([path]) => extname(path).toLowerCase() !== '.json')
|
|
1984
2487
|
.map(([path, contents]) => [resolve(path), contents]),
|
|
1985
2488
|
);
|
|
2489
|
+
const entryPath = resolve(entryFile);
|
|
2490
|
+
const planWarnings: string[] = [];
|
|
2491
|
+
const plan = docflowHelperInstrumentationPlanFailOpen(
|
|
2492
|
+
entryPath,
|
|
2493
|
+
scriptEntry?.source ?? customerSourceFiles.get(entryPath) ?? null,
|
|
2494
|
+
customerSourceFiles,
|
|
2495
|
+
planWarnings,
|
|
2496
|
+
);
|
|
2497
|
+
const entryOptions: PlayDocflowInstrumentationOptions = {
|
|
2498
|
+
moduleSources: plan.moduleSources,
|
|
2499
|
+
bindRunContext: plan.helperBindings.size > 0,
|
|
2500
|
+
};
|
|
2501
|
+
// Instrumentation warnings travel as esbuild warnings (`result.warnings`):
|
|
2502
|
+
// tracking is display-only, so they never become bundle errors.
|
|
2503
|
+
const asWarnings = (path: string, warnings: readonly string[]) =>
|
|
2504
|
+
warnings.map((text) => ({
|
|
2505
|
+
text: `${DOCFLOW_INSTRUMENTATION_WARNING_PREFIX}${text}`,
|
|
2506
|
+
location: { file: path },
|
|
2507
|
+
}));
|
|
1986
2508
|
return {
|
|
1987
2509
|
name: 'deepline-docflow-runtime-instrumentation',
|
|
1988
2510
|
setup(buildContext) {
|
|
1989
2511
|
buildContext.onLoad({ filter: /./ }, (args) => {
|
|
1990
|
-
|
|
2512
|
+
const path = resolve(args.path);
|
|
2513
|
+
if (scriptEntry && path === resolve(scriptEntry.path)) {
|
|
2514
|
+
const script = scriptEntryModule(
|
|
2515
|
+
scriptEntry.source,
|
|
2516
|
+
args.path,
|
|
2517
|
+
entryOptions,
|
|
2518
|
+
);
|
|
1991
2519
|
return {
|
|
1992
|
-
contents:
|
|
2520
|
+
contents: script.contents,
|
|
1993
2521
|
loader: sourceLoaderForPath(args.path),
|
|
1994
2522
|
resolveDir: dirname(args.path),
|
|
2523
|
+
warnings: asWarnings(args.path, [
|
|
2524
|
+
...planWarnings,
|
|
2525
|
+
...script.warnings,
|
|
2526
|
+
]),
|
|
1995
2527
|
};
|
|
1996
2528
|
}
|
|
1997
|
-
const contents = customerSourceFiles.get(
|
|
2529
|
+
const contents = customerSourceFiles.get(path);
|
|
1998
2530
|
if (contents === undefined) return undefined;
|
|
1999
2531
|
if (isTextImportFile(args.path)) {
|
|
2000
2532
|
return {
|
|
@@ -2003,33 +2535,143 @@ function docflowRuntimeInstrumentationPlugin(
|
|
|
2003
2535
|
resolveDir: dirname(args.path),
|
|
2004
2536
|
};
|
|
2005
2537
|
}
|
|
2538
|
+
const helperBindings = plan.helperBindings.get(path);
|
|
2539
|
+
const report = instrumentPlayDocflowRuntimeHitsWithReport(
|
|
2540
|
+
contents,
|
|
2541
|
+
path === entryPath
|
|
2542
|
+
? entryOptions
|
|
2543
|
+
: helperBindings
|
|
2544
|
+
? { helperBindings }
|
|
2545
|
+
: {},
|
|
2546
|
+
);
|
|
2006
2547
|
return {
|
|
2007
|
-
contents:
|
|
2548
|
+
contents: report.code,
|
|
2008
2549
|
loader: sourceLoaderForPath(args.path),
|
|
2009
2550
|
resolveDir: dirname(args.path),
|
|
2551
|
+
warnings: asWarnings(args.path, [
|
|
2552
|
+
...(path === entryPath ? planWarnings : []),
|
|
2553
|
+
...report.warnings,
|
|
2554
|
+
]),
|
|
2010
2555
|
};
|
|
2011
2556
|
});
|
|
2012
2557
|
},
|
|
2013
2558
|
};
|
|
2014
2559
|
}
|
|
2015
2560
|
|
|
2561
|
+
/** Marks an esbuild warning as a display-only diagram-tracking warning. */
|
|
2562
|
+
export const DOCFLOW_INSTRUMENTATION_WARNING_PREFIX = '[diagram tracking] ';
|
|
2563
|
+
|
|
2564
|
+
function docflowHelperInstrumentationPlanFailOpen(
|
|
2565
|
+
entryPath: string,
|
|
2566
|
+
entrySource: string | null,
|
|
2567
|
+
sources: ReadonlyMap<string, string>,
|
|
2568
|
+
warnings: string[],
|
|
2569
|
+
): ReturnType<typeof docflowHelperInstrumentationPlan> {
|
|
2570
|
+
try {
|
|
2571
|
+
return docflowHelperInstrumentationPlan(entryPath, entrySource, sources);
|
|
2572
|
+
} catch (error) {
|
|
2573
|
+
warnings.push(
|
|
2574
|
+
`Diagram tracking in imported helper modules was skipped: ${boundedInstrumentationReason(error)}.`,
|
|
2575
|
+
);
|
|
2576
|
+
return {
|
|
2577
|
+
moduleSources: new Map(
|
|
2578
|
+
[...sources].filter(
|
|
2579
|
+
([path]) => path !== entryPath && !isTextImportFile(path),
|
|
2580
|
+
),
|
|
2581
|
+
),
|
|
2582
|
+
helperBindings: new Map(),
|
|
2583
|
+
};
|
|
2584
|
+
}
|
|
2585
|
+
}
|
|
2586
|
+
|
|
2587
|
+
/**
|
|
2588
|
+
* Which imported modules hold annotations the entry's diagram draws. The entry
|
|
2589
|
+
* is parsed against its import closure exactly as `plays check` parses it, and
|
|
2590
|
+
* each binding found in another module is routed to that module's load. Only
|
|
2591
|
+
* boxes the entry draws are kept: one helper can serve several plays, and an
|
|
2592
|
+
* annotation for another play's box must stay inert in this one.
|
|
2593
|
+
*/
|
|
2594
|
+
export function docflowHelperInstrumentationPlan(
|
|
2595
|
+
entryPath: string,
|
|
2596
|
+
entrySource: string | null,
|
|
2597
|
+
sources: ReadonlyMap<string, string>,
|
|
2598
|
+
): {
|
|
2599
|
+
moduleSources: ReadonlyMap<string, string>;
|
|
2600
|
+
helperBindings: ReadonlyMap<string, PlayDocflowBinding[]>;
|
|
2601
|
+
} {
|
|
2602
|
+
const moduleSources = new Map(
|
|
2603
|
+
[...sources].filter(
|
|
2604
|
+
([path]) => path !== entryPath && !isTextImportFile(path),
|
|
2605
|
+
),
|
|
2606
|
+
);
|
|
2607
|
+
const helperBindings = new Map<string, PlayDocflowBinding[]>();
|
|
2608
|
+
if (entrySource === null || moduleSources.size === 0) {
|
|
2609
|
+
return { moduleSources, helperBindings };
|
|
2610
|
+
}
|
|
2611
|
+
const parsed = parsePlayDocflowFile(entrySource, moduleSources);
|
|
2612
|
+
const drawn = new Set(
|
|
2613
|
+
parsed.blocks.flatMap((block) =>
|
|
2614
|
+
block.docflow.nodes.map((node) => node.id),
|
|
2615
|
+
),
|
|
2616
|
+
);
|
|
2617
|
+
// With diagram problems, only the bindings the surviving diagrams attached
|
|
2618
|
+
// are tracked; the rest were dropped from the drawing.
|
|
2619
|
+
const tracked =
|
|
2620
|
+
parsed.errors.length > 0
|
|
2621
|
+
? parsed.blocks.flatMap((block) => block.docflow.bindings)
|
|
2622
|
+
: parsed.bindings;
|
|
2623
|
+
for (const binding of tracked) {
|
|
2624
|
+
if (!binding.sourcePath || !drawn.has(binding.nodeId)) continue;
|
|
2625
|
+
const path = resolve(binding.sourcePath);
|
|
2626
|
+
helperBindings.set(path, [...(helperBindings.get(path) ?? []), binding]);
|
|
2627
|
+
}
|
|
2628
|
+
return { moduleSources, helperBindings };
|
|
2629
|
+
}
|
|
2630
|
+
|
|
2016
2631
|
/**
|
|
2017
2632
|
* A script-play entry, instrumented, as the function the runner calls: the
|
|
2018
2633
|
* module body runs inside the run and its default-exported play function, if
|
|
2019
2634
|
* any, is dispatched (see `wrapScriptPlay`).
|
|
2020
2635
|
*/
|
|
2021
|
-
function scriptEntryModule(
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2636
|
+
function scriptEntryModule(
|
|
2637
|
+
source: string,
|
|
2638
|
+
path: string,
|
|
2639
|
+
options: PlayDocflowInstrumentationOptions = {},
|
|
2640
|
+
): { contents: string; warnings: string[] } {
|
|
2641
|
+
const typed = /^tsx?$/.test(sourceLoaderForPath(path));
|
|
2642
|
+
const report = instrumentPlayDocflowRuntimeHitsWithReport(source, options);
|
|
2643
|
+
if (report.instrumented) {
|
|
2644
|
+
try {
|
|
2645
|
+
const script = parseScriptPlay(report.code);
|
|
2646
|
+
if (script) {
|
|
2647
|
+
return {
|
|
2648
|
+
contents: wrapScriptPlay(report.code, script, {
|
|
2649
|
+
typed,
|
|
2650
|
+
authoredSource: source,
|
|
2651
|
+
}),
|
|
2652
|
+
warnings: report.warnings,
|
|
2653
|
+
};
|
|
2654
|
+
}
|
|
2655
|
+
} catch {
|
|
2656
|
+
// Fall through to the authored source below.
|
|
2657
|
+
}
|
|
2658
|
+
report.warnings.push(
|
|
2659
|
+
'Diagram tracking was skipped for this script play: the instrumented source is no longer a script play. The play runs unchanged.',
|
|
2027
2660
|
);
|
|
2028
2661
|
}
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2662
|
+
// The authored source, uninstrumented. A failure here is the play's own,
|
|
2663
|
+
// not tracking's, and stays loud.
|
|
2664
|
+
const script = parseScriptPlay(source);
|
|
2665
|
+
if (!script) {
|
|
2666
|
+
throw new Error('Script play entry could not be parsed as a script play.');
|
|
2667
|
+
}
|
|
2668
|
+
return {
|
|
2669
|
+
contents: wrapScriptPlay(source, script, {
|
|
2670
|
+
typed,
|
|
2671
|
+
authoredSource: source,
|
|
2672
|
+
}),
|
|
2673
|
+
warnings: report.warnings,
|
|
2674
|
+
};
|
|
2033
2675
|
}
|
|
2034
2676
|
|
|
2035
2677
|
function buildImportedPlayProxyModule(playName: string): string {
|
|
@@ -2564,6 +3206,8 @@ type EsbuildBundleOutput = {
|
|
|
2564
3206
|
bundledCode: string;
|
|
2565
3207
|
sourceMapText: string;
|
|
2566
3208
|
outputExtension: 'cjs';
|
|
3209
|
+
/** Display-only diagram-tracking warnings (never bundle errors). */
|
|
3210
|
+
docflowInstrumentationWarnings: string[];
|
|
2567
3211
|
};
|
|
2568
3212
|
|
|
2569
3213
|
async function runEsbuildForCjsNode(
|
|
@@ -2579,6 +3223,7 @@ async function runEsbuildForCjsNode(
|
|
|
2579
3223
|
const playProxyPlugin = importedPlayProxyPlugin(importedPlayDependencies);
|
|
2580
3224
|
const docflowPlugin = docflowRuntimeInstrumentationPlugin(
|
|
2581
3225
|
analyzedSources,
|
|
3226
|
+
entryFile,
|
|
2582
3227
|
entryScript === null ? null : { path: entryFile, source: entryScript },
|
|
2583
3228
|
);
|
|
2584
3229
|
const namedExportShim =
|
|
@@ -2628,6 +3273,18 @@ async function runEsbuildForCjsNode(
|
|
|
2628
3273
|
bundledCode: codeFile.text,
|
|
2629
3274
|
sourceMapText: mapFile.text,
|
|
2630
3275
|
outputExtension: 'cjs',
|
|
3276
|
+
docflowInstrumentationWarnings: [
|
|
3277
|
+
...new Set(
|
|
3278
|
+
result.warnings
|
|
3279
|
+
.map((warning) => warning.text)
|
|
3280
|
+
.filter((text) =>
|
|
3281
|
+
text.startsWith(DOCFLOW_INSTRUMENTATION_WARNING_PREFIX),
|
|
3282
|
+
)
|
|
3283
|
+
.map((text) =>
|
|
3284
|
+
text.slice(DOCFLOW_INSTRUMENTATION_WARNING_PREFIX.length),
|
|
3285
|
+
),
|
|
3286
|
+
),
|
|
3287
|
+
],
|
|
2631
3288
|
};
|
|
2632
3289
|
}
|
|
2633
3290
|
|
|
@@ -2800,7 +3457,12 @@ export async function bundlePlayFile(
|
|
|
2800
3457
|
errors: buildOutcome,
|
|
2801
3458
|
};
|
|
2802
3459
|
}
|
|
2803
|
-
const {
|
|
3460
|
+
const {
|
|
3461
|
+
bundledCode,
|
|
3462
|
+
sourceMapText,
|
|
3463
|
+
outputExtension,
|
|
3464
|
+
docflowInstrumentationWarnings,
|
|
3465
|
+
} = buildOutcome;
|
|
2804
3466
|
|
|
2805
3467
|
const normalizedSourceMap = normalizeSourceMapForRuntime(
|
|
2806
3468
|
sourceMapText,
|
|
@@ -2872,6 +3534,9 @@ export async function bundlePlayFile(
|
|
|
2872
3534
|
packagedFiles: discoveredFiles.files,
|
|
2873
3535
|
unresolvedFileReferences: discoveredFiles.unresolved,
|
|
2874
3536
|
importedPlayDependencies: analysis.importedPlayDependencies,
|
|
3537
|
+
...(docflowInstrumentationWarnings.length > 0
|
|
3538
|
+
? { docflowInstrumentationWarnings }
|
|
3539
|
+
: {}),
|
|
2875
3540
|
};
|
|
2876
3541
|
} catch (error) {
|
|
2877
3542
|
if (error instanceof AggregateError) {
|