@wpkernel/pipeline 0.12.6-beta.3 → 1.1.0

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.
@@ -1,9 +1,14 @@
1
- import { executeRun as e } from "./execution.js";
2
- import { prepareContext as o } from "./context.js";
3
- const u = (r) => ({
4
- prepareContext: (t) => o(r, t),
5
- executeRun: (t) => e(r, t)
1
+ import { executeResume as n, executeRunWithPause as o, executeRun as x } from "./execution.js";
2
+ import { prepareContext as u } from "./context.js";
3
+ const m = (t) => ({
4
+ prepareContext: (e) => u(t, e),
5
+ executeRun: (e) => x(t, e)
6
+ }), i = (t) => ({
7
+ prepareContext: (e) => u(t, e),
8
+ executeRun: (e) => o(t, e),
9
+ executeResume: (e, r) => n(t, e, r)
6
10
  });
7
11
  export {
8
- u as initAgnosticRunner
12
+ i as initAgnosticResumableRunner,
13
+ m as initAgnosticRunner
9
14
  };
@@ -1,7 +1,10 @@
1
1
  import { Program } from '../async-utils';
2
- import { AgnosticRunnerDependencies, AgnosticRunContext, AgnosticState, Halt } from './types';
2
+ import { AgnosticRunnerDependencies, AgnosticRunContext, AgnosticState, Halt, PipelineStage, PipelineStepResult } from './types';
3
3
  import { PipelineReporter, PipelineDiagnostic } from '../types';
4
+ export declare const createAgnosticStages: <TRunOptions, TUserState, TContext extends {
5
+ reporter: TReporter;
6
+ }, TReporter extends PipelineReporter, TDiagnostic extends PipelineDiagnostic, TRunResult>(dependencies: AgnosticRunnerDependencies<TRunOptions, TUserState, TContext, TReporter, TDiagnostic, TRunResult>, runContext: AgnosticRunContext<TRunOptions, TUserState, TContext, TReporter, TDiagnostic>) => PipelineStage<AgnosticState<TRunOptions, TUserState, TContext, TReporter, TDiagnostic>, Halt<TRunResult>>[];
4
7
  export declare const createAgnosticProgram: <TRunOptions, TUserState, TContext extends {
5
8
  reporter: TReporter;
6
- }, TReporter extends PipelineReporter, TDiagnostic extends PipelineDiagnostic, TRunResult>(dependencies: AgnosticRunnerDependencies<TRunOptions, TUserState, TContext, TReporter, TDiagnostic, TRunResult>, runContext: AgnosticRunContext<TRunOptions, TUserState, TContext, TReporter, TDiagnostic>) => Program<AgnosticState<TRunOptions, TUserState, TContext, TReporter, TDiagnostic> | Halt<TRunResult>>;
9
+ }, TReporter extends PipelineReporter, TDiagnostic extends PipelineDiagnostic, TRunResult>(dependencies: AgnosticRunnerDependencies<TRunOptions, TUserState, TContext, TReporter, TDiagnostic, TRunResult>, runContext: AgnosticRunContext<TRunOptions, TUserState, TContext, TReporter, TDiagnostic>) => Program<PipelineStepResult<AgnosticState<TRunOptions, TUserState, TContext, TReporter, TDiagnostic>, TRunResult>>;
7
10
  //# sourceMappingURL=program.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"program.d.ts","sourceRoot":"","sources":["../../../src/core/runner/program.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,KAAK,EACX,0BAA0B,EAC1B,kBAAkB,EAElB,aAAa,EACb,IAAI,EAGJ,MAAM,SAAS,CAAC;AASjB,OAAO,KAAK,EACX,gBAAgB,EAChB,kBAAkB,EAIlB,MAAM,UAAU,CAAC;AAElB,eAAO,MAAM,qBAAqB,GACjC,WAAW,EACX,UAAU,EACV,QAAQ,SAAS;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,EACxC,SAAS,SAAS,gBAAgB,EAClC,WAAW,SAAS,kBAAkB,EACtC,UAAU,EAEV,cAAc,0BAA0B,CACvC,WAAW,EACX,UAAU,EACV,QAAQ,EACR,SAAS,EACT,WAAW,EACX,UAAU,CACV,EACD,YAAY,kBAAkB,CAC7B,WAAW,EACX,UAAU,EACV,QAAQ,EACR,SAAS,EACT,WAAW,CACX,KACC,OAAO,CACP,aAAa,CAAC,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,CAAC,GACxE,IAAI,CAAC,UAAU,CAAC,CA6SlB,CAAC"}
1
+ {"version":3,"file":"program.d.ts","sourceRoot":"","sources":["../../../src/core/runner/program.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,KAAK,EACX,0BAA0B,EAC1B,kBAAkB,EAElB,aAAa,EACb,IAAI,EAGJ,aAAa,EACb,kBAAkB,EAClB,MAAM,SAAS,CAAC;AAUjB,OAAO,KAAK,EACX,gBAAgB,EAChB,kBAAkB,EAOlB,MAAM,UAAU,CAAC;AAyBlB,eAAO,MAAM,oBAAoB,GAChC,WAAW,EACX,UAAU,EACV,QAAQ,SAAS;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,EACxC,SAAS,SAAS,gBAAgB,EAClC,WAAW,SAAS,kBAAkB,EACtC,UAAU,EAEV,cAAc,0BAA0B,CACvC,WAAW,EACX,UAAU,EACV,QAAQ,EACR,SAAS,EACT,WAAW,EACX,UAAU,CACV,EACD,YAAY,kBAAkB,CAC7B,WAAW,EACX,UAAU,EACV,QAAQ,EACR,SAAS,EACT,WAAW,CACX,KACC,aAAa,CACf,aAAa,CAAC,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,CAAC,EACxE,IAAI,CAAC,UAAU,CAAC,CAChB,EAqTA,CAAC;AAEF,eAAO,MAAM,qBAAqB,GACjC,WAAW,EACX,UAAU,EACV,QAAQ,SAAS;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,EACxC,SAAS,SAAS,gBAAgB,EAClC,WAAW,SAAS,kBAAkB,EACtC,UAAU,EAEV,cAAc,0BAA0B,CACvC,WAAW,EACX,UAAU,EACV,QAAQ,EACR,SAAS,EACT,WAAW,EACX,UAAU,CACV,EACD,YAAY,kBAAkB,CAC7B,WAAW,EACX,UAAU,EACV,QAAQ,EACR,SAAS,EACT,WAAW,CACX,KACC,OAAO,CACT,kBAAkB,CACjB,aAAa,CACZ,WAAW,EACX,UAAU,EACV,QAAQ,EACR,SAAS,EACT,WAAW,CACX,EACD,UAAU,CACV,CAsBD,CAAC"}
@@ -1,146 +1,163 @@
1
1
  import { composeK as h, maybeThen as b } from "../async-utils.js";
2
- import { makeCommitStage as R, makeAfterFragmentsStage as H, makeFinalizeResultStage as A, isHalt as c, makeHelperStageFactory as w } from "./stage-factories.js";
3
- const L = (r, l) => {
4
- const f = (o) => ({
2
+ import { makeCommitStage as R, makeAfterFragmentsStage as A, makeFinalizeResultStage as H, isHalt as l, makeHelperStageFactory as w, isPaused as g } from "./stage-factories.js";
3
+ const _ = (n) => n.stageIndex ?? 0, v = (n, a) => ({
4
+ stageIndex: _(n),
5
+ state: n,
6
+ token: a?.token,
7
+ pauseKind: a?.pauseKind,
8
+ payload: a?.payload,
9
+ createdAt: Date.now()
10
+ }), C = (n, a) => ({
11
+ __paused: !0,
12
+ snapshot: v(n, a)
13
+ }), L = (n, a) => {
14
+ const u = (e) => ({
5
15
  __halt: !0,
6
- error: o
7
- }), g = (o) => (t) => ({
8
- context: o.context,
9
- reporter: o.reporter,
10
- userState: o.userState
11
- }), u = {
12
- pushStep: l.pushStep,
13
- toRollbackContext: (o) => ({
14
- context: o.context,
15
- extensionCoordinator: o.extensionCoordinator,
16
- extensionState: o.extensionState,
17
- extensionStack: o.extensionStack
16
+ error: e
17
+ }), f = (e) => (t) => ({
18
+ context: e.context,
19
+ reporter: e.reporter,
20
+ userState: e.userState
21
+ }), x = {
22
+ pushStep: a.pushStep,
23
+ toRollbackContext: (e) => ({
24
+ context: e.context,
25
+ extensionCoordinator: e.extensionCoordinator,
26
+ extensionState: e.extensionState,
27
+ extensionStack: e.extensionStack
18
28
  }),
19
- halt: f,
20
- isHalt: c,
21
- onHelperRollbackError: r.options.onHelperRollbackError
22
- }, x = w({
23
- pushStep: l.pushStep,
24
- toRollbackContext: (o) => ({
25
- context: o.context,
26
- extensionCoordinator: o.extensionCoordinator,
27
- extensionState: o.extensionState,
28
- extensionStack: o.extensionStack
29
+ halt: u,
30
+ pause: n.options.supportsPause ? (e, t) => C(e, t) : void 0,
31
+ isHalt: l,
32
+ onHelperRollbackError: n.options.onHelperRollbackError
33
+ }, k = w({
34
+ pushStep: a.pushStep,
35
+ toRollbackContext: (e) => ({
36
+ context: e.context,
37
+ extensionCoordinator: e.extensionCoordinator,
38
+ extensionState: e.extensionState,
39
+ extensionStack: e.extensionStack
29
40
  }),
30
- halt: f,
31
- isHalt: c,
32
- onHelperRollbackError: r.options.onHelperRollbackError
33
- }), k = (o, t, i) => {
34
- const a = {
35
- getOrder: (e) => e.helperOrders?.get(o) ?? [],
36
- makeArgs: g,
37
- onVisited: (e, n, s) => t?.onVisited ? t.onVisited(e, n, s) : e,
38
- readRollbacks: (e) => e.helperRollbacks?.get(o)?.map((n) => n.helper) ?? [],
41
+ halt: u,
42
+ isHalt: l,
43
+ onHelperRollbackError: n.options.onHelperRollbackError
44
+ }), p = (e, t, s) => {
45
+ const i = {
46
+ getOrder: (o) => o.helperOrders?.get(e) ?? [],
47
+ makeArgs: f,
48
+ onVisited: (o, r, c) => t?.onVisited ? t.onVisited(o, r, c) : o,
49
+ readRollbacks: (o) => o.helperRollbacks?.get(e)?.map((r) => r.helper) ?? [],
39
50
  invoke: ({
40
- helper: e,
41
- args: n,
42
- next: s
51
+ helper: o,
52
+ args: r,
53
+ next: c
43
54
  }) => {
44
- if (typeof e == "function")
45
- return e(n, s);
46
- if (typeof e == "object" && e !== null && "apply" in e && typeof e.apply == "function")
47
- return e.apply(n, s);
55
+ if (typeof o == "function")
56
+ return o(r, c);
57
+ if (typeof o == "object" && o !== null && "apply" in o && typeof o.apply == "function")
58
+ return o.apply(r, c);
48
59
  throw new Error(
49
- `Invalid helper: expected function or object with .apply method. Got: ${typeof e}`
60
+ `Invalid helper: expected function or object with .apply method. Got: ${typeof o}`
50
61
  );
51
62
  },
52
63
  ...t
53
64
  };
54
- return t?.makeArgs ? a.makeArgs = t.makeArgs : i && (a.makeArgs = (e) => (n) => i({
55
- state: e,
56
- helper: n.helper,
57
- context: e.context
58
- })), x(
59
- o,
60
- a
65
+ return t?.makeArgs ? i.makeArgs = t.makeArgs : s && (i.makeArgs = (o) => (r) => s({
66
+ state: o,
67
+ helper: r.helper,
68
+ context: o.context
69
+ })), k(
70
+ e,
71
+ i
61
72
  );
62
- }, m = (o) => H({
63
- isHalt: c,
73
+ }, m = (e) => A({
74
+ isHalt: l,
75
+ isPaused: g,
64
76
  execute: (t) => {
65
- t.executedLifecycles.add(o);
66
- const i = t.extensionCoordinator;
67
- if (!i)
77
+ t.executedLifecycles.add(e);
78
+ const s = t.extensionCoordinator;
79
+ if (!s)
68
80
  return t;
69
- const a = l.buildHookOptions(
81
+ const i = a.buildHookOptions(
70
82
  t,
71
- o
83
+ e
72
84
  );
73
85
  return b(
74
- i.runLifecycle(
75
- o,
86
+ s.runLifecycle(
87
+ e,
76
88
  {
77
- hooks: r.extensionHooks,
78
- hookOptions: a
89
+ hooks: n.extensionHooks,
90
+ hookOptions: i
79
91
  }
80
92
  ),
81
- (e) => ({
93
+ (o) => ({
82
94
  ...t,
83
- extensionState: e,
95
+ extensionState: o,
84
96
  extensionStack: [
85
97
  ...t.extensionStack ?? [],
86
98
  {
87
- coordinator: i,
88
- state: e
99
+ coordinator: s,
100
+ state: o
89
101
  }
90
102
  ],
91
- userState: e.artifact
103
+ userState: o.artifact
92
104
  })
93
105
  );
94
106
  }
95
107
  }), S = R({
96
- isHalt: c,
97
- commit: (o) => {
98
- const t = o.extensionCoordinator;
108
+ isHalt: l,
109
+ isPaused: g,
110
+ commit: (e) => {
111
+ const t = e.extensionCoordinator;
99
112
  if (t)
100
- return t.commit(o.extensionState);
113
+ return t.commit(e.extensionState);
101
114
  },
102
- rollbackToHalt: (o, t) => ({
115
+ rollbackToHalt: (e, t) => ({
103
116
  __halt: !0,
104
117
  error: t
105
118
  })
106
- }), p = A({
107
- isHalt: c,
108
- finalize: (o) => {
109
- const i = {
110
- ...o,
111
- diagnostics: r.diagnosticManager.readDiagnostics()
119
+ }), d = H({
120
+ isHalt: l,
121
+ isPaused: g,
122
+ finalize: (e) => {
123
+ const s = {
124
+ ...e,
125
+ diagnostics: n.diagnosticManager.readDiagnostics()
112
126
  };
113
- if (r.extensionHooks.length > 0) {
114
- const a = i.executedLifecycles, e = /* @__PURE__ */ new Set();
115
- for (const n of r.extensionHooks)
116
- a?.has(n.lifecycle) || e.add(n.lifecycle);
117
- if (e.size > 0) {
118
- const n = Array.from(e).map((s) => `"${s}"`).join(", ");
119
- i.reporter.warn?.(
120
- `The following extension hooks will be ignored because their lifecycles were not executed: ${n}`
127
+ if (n.extensionHooks.length > 0) {
128
+ const i = s.executedLifecycles, o = /* @__PURE__ */ new Set();
129
+ for (const r of n.extensionHooks)
130
+ i?.has(r.lifecycle) || o.add(r.lifecycle);
131
+ if (o.size > 0) {
132
+ const r = Array.from(o).map((c) => `"${c}"`).join(", ");
133
+ s.reporter.warn?.(
134
+ `The following extension hooks will be ignored because their lifecycles were not executed: ${r}`
121
135
  );
122
136
  }
123
137
  }
124
- return i;
138
+ return s;
125
139
  }
126
140
  }), y = {
127
- runnerEnv: u,
128
- finalizeResult: p,
141
+ runnerEnv: x,
142
+ finalizeResult: d,
129
143
  makeLifecycleStage: m,
130
144
  commitStage: S,
131
- makeHelperStage: k,
145
+ makeHelperStage: p,
132
146
  extensions: {
133
- lifecycles: r.extensionLifecycles
147
+ lifecycles: n.extensionLifecycles
134
148
  },
135
- diagnosticManager: r.diagnosticManager
149
+ diagnosticManager: n.diagnosticManager
136
150
  };
137
- if (!r.stages)
151
+ if (!n.stages)
138
152
  throw new Error(
139
153
  "Agnostic Runner requires 'stages' factory to be defined."
140
154
  );
141
- const d = r.stages(y);
142
- return h(...[...d].reverse());
155
+ return n.stages(y);
156
+ }, E = (n, a) => {
157
+ const u = L(n, a);
158
+ return h(...[...u].reverse());
143
159
  };
144
160
  export {
145
- L as createAgnosticProgram
161
+ E as createAgnosticProgram,
162
+ L as createAgnosticStages
146
163
  };
@@ -1,8 +1,9 @@
1
1
  import { Program } from '../async-utils';
2
- import { Helper, HelperApplyOptions, HelperKind, MaybePromise, PipelineReporter } from '../types';
2
+ import { Helper, HelperApplyOptions, HelperKind, MaybePromise, PipelinePaused, PipelineReporter } from '../types';
3
3
  import { RegisteredHelper } from '../dependency-graph';
4
4
  import { Halt, HelperInvokeOptions, StageEnv, HelperStageSpec } from './types';
5
5
  export declare function isHalt<TRunResult>(value: unknown): value is Halt<TRunResult>;
6
+ export declare function isPaused<TState>(value: unknown): value is PipelinePaused<TState>;
6
7
  /**
7
8
  * Generic stage constructor that executes an ordered helper list with middleware-style `next()`.
8
9
  * @param options
@@ -27,43 +28,51 @@ export declare function createHelpersProgram<TContext, TReporter extends Pipelin
27
28
  * @param options.isHalt
28
29
  * @param options.snapshotFragments
29
30
  * @param options.applyArtifact
31
+ * @param options.isPaused
30
32
  */
31
33
  export declare function makeFinalizeFragmentsStage<TState, THalt extends Halt<unknown>, TFragments>(options: {
32
34
  isHalt: (value: TState | THalt) => value is THalt;
35
+ isPaused?: (value: unknown) => value is PipelinePaused<TState>;
33
36
  snapshotFragments: (state: TState) => TFragments;
34
37
  applyArtifact: (state: TState, fragments: TFragments) => TState;
35
- }): Program<TState | THalt>;
38
+ }): Program<TState | THalt | PipelinePaused<TState>>;
36
39
  /**
37
40
  * Generic stage builder for "after fragments" style hooks.
38
41
  * @param options
39
42
  * @param options.isHalt
40
43
  * @param options.execute
44
+ * @param options.isPaused
41
45
  */
42
46
  export declare function makeAfterFragmentsStage<TState, THalt extends Halt<unknown>>(options: {
43
47
  isHalt: (value: TState | THalt) => value is THalt;
48
+ isPaused?: (value: unknown) => value is PipelinePaused<TState>;
44
49
  execute: (state: TState) => MaybePromise<TState>;
45
- }): Program<TState | THalt>;
50
+ }): Program<TState | THalt | PipelinePaused<TState>>;
46
51
  /**
47
52
  * Commit stage builder.
48
53
  * @param options
49
54
  * @param options.isHalt
50
55
  * @param options.commit
51
56
  * @param options.rollbackToHalt
57
+ * @param options.isPaused
52
58
  */
53
59
  export declare function makeCommitStage<TState, THalt extends Halt<unknown>>(options: {
54
60
  isHalt: (value: TState | THalt) => value is THalt;
61
+ isPaused?: (value: unknown) => value is PipelinePaused<TState>;
55
62
  commit: (state: TState) => MaybePromise<void>;
56
63
  rollbackToHalt: (state: TState, error: unknown) => MaybePromise<THalt>;
57
- }): Program<TState | THalt>;
64
+ }): Program<TState | THalt | PipelinePaused<TState>>;
58
65
  /**
59
66
  * Simple finalizer that snapshots helpers/diagnostics into state.
60
67
  * @param options
61
68
  * @param options.isHalt
62
69
  * @param options.finalize
70
+ * @param options.isPaused
63
71
  */
64
72
  export declare function makeFinalizeResultStage<TState, THalt extends Halt<unknown>>(options: {
65
73
  isHalt: (value: TState | THalt) => value is THalt;
74
+ isPaused?: (value: unknown) => value is PipelinePaused<TState>;
66
75
  finalize: (state: TState) => TState;
67
- }): Program<TState | THalt>;
68
- export declare function makeHelperStageFactory<TState, TRunResult, TContext, TOptions, TReporter extends PipelineReporter, TUserState>(config: StageEnv<TState, TRunResult, TContext, TOptions, TReporter, TUserState>): <TKind extends HelperKind, THelper extends Helper<TContext, TInput, TOutput, TReporter, TKind>, TInput, TOutput>(kind: string, spec: HelperStageSpec<TState, TContext, TReporter, TKind, THelper, TInput, TOutput>) => Program<TState | Halt<TRunResult>>;
76
+ }): Program<TState | THalt | PipelinePaused<TState>>;
77
+ export declare function makeHelperStageFactory<TState, TRunResult, TContext, TOptions, TReporter extends PipelineReporter, TUserState>(config: StageEnv<TState, TRunResult, TContext, TOptions, TReporter, TUserState>): <TKind extends HelperKind, THelper extends Helper<TContext, TInput, TOutput, TReporter, TKind>, TInput, TOutput>(kind: string, spec: HelperStageSpec<TState, TContext, TReporter, TKind, THelper, TInput, TOutput>) => Program<TState | Halt<TRunResult> | PipelinePaused<TState>>;
69
78
  //# sourceMappingURL=stage-factories.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"stage-factories.d.ts","sourceRoot":"","sources":["../../../src/core/runner/stage-factories.ts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AAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,YAAY,CAAC,KAAK,CAAC,CAAC;CACvE,GAAG,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC,CAe1B;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACtC,MAAM,EACN,KAAK,SAAS,IAAI,CAAC,OAAO,CAAC,EAC1B,OAAO,EAAE;IACV,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,KAAK,KAAK,IAAI,KAAK,CAAC;IAClD,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;CACpC,GAAG,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC,CAG1B;AAED,wBAAgB,sBAAsB,CACrC,MAAM,EACN,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,SAAS,SAAS,gBAAgB,EAClC,UAAU,EAEV,MAAM,EAAE,QAAQ,CACf,MAAM,EACN,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,UAAU,CACV,IAGA,KAAK,SAAS,UAAU,EACxB,OAAO,SAAS,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,CAAC,EACnE,MAAM,EACN,OAAO,EAEP,MAAM,MAAM,EACZ,MAAM,eAAe,CACpB,MAAM,EACN,QAAQ,EACR,SAAS,EACT,KAAK,EACL,OAAO,EACP,MAAM,EACN,OAAO,CACP,KACC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CA2IrC"}
1
+ {"version":3,"file":"stage-factories.d.ts","sourceRoot":"","sources":["../../../src/core/runner/stage-factories.ts"],"names":[],"mappings":"AAAA,OAAO,EAIN,KAAK,OAAO,EACZ,MAAM,gBAAgB,CAAC;AAGxB,OAAO,KAAK,EACX,MAAM,EACN,kBAAkB,EAClB,UAAU,EACV,YAAY,EACZ,cAAc,EAEd,gBAAgB,EAChB,MAAM,UAAU,CAAC;AACl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P,MAAM,MAAM,EACZ,MAAM,eAAe,CACpB,MAAM,EACN,QAAQ,EACR,SAAS,EACT,KAAK,EACL,OAAO,EACP,MAAM,EACN,OAAO,CACP,KACC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC,CAgJ9D"}
@@ -1,121 +1,138 @@
1
- import { maybeTry as y, maybeThen as S, isPromiseLike as C } from "../async-utils.js";
2
- import { executeHelpers as E } from "../execution-utils.js";
3
- import { runHelperStageWithRollback as F } from "./rollback.js";
4
- function _(r) {
1
+ import { maybeTry as R, maybeThen as S, isPromiseLike as y } from "../async-utils.js";
2
+ import { executeHelpers as _ } from "../execution-utils.js";
3
+ import { runHelperStageWithRollback as C } from "./rollback.js";
4
+ function v(r) {
5
5
  return !!(r && typeof r == "object" && "__halt" in r && r.__halt === !0);
6
6
  }
7
- function v(r) {
7
+ function E(r) {
8
+ return !!(r && typeof r == "object" && "__paused" in r && r.__paused === !0);
9
+ }
10
+ function F(r) {
8
11
  const {
9
- getOrder: c,
10
- makeArgs: t,
11
- invoke: e,
12
- recordStep: a,
13
- onVisited: i,
14
- registerRollback: u
15
- } = r, f = (n, k, p) => {
16
- const s = e({ helper: n, args: k, next: p });
17
- return u ? C(s) ? s.then((o) => {
18
- u(n, o);
19
- }) : (u(n, s), s) : s;
12
+ getOrder: u,
13
+ makeArgs: n,
14
+ invoke: t,
15
+ recordStep: e,
16
+ onVisited: l,
17
+ registerRollback: i
18
+ } = r, k = (c, f, p) => {
19
+ const s = t({ helper: c, args: f, next: p });
20
+ return i ? y(s) ? s.then((o) => {
21
+ i(c, o);
22
+ }) : (i(c, s), s) : s;
20
23
  };
21
- return (n) => {
22
- const k = c(n), p = E(k, t(n), f, a);
24
+ return (c) => {
25
+ const f = u(c), p = _(f, n(c), k, e);
23
26
  return S(
24
27
  p,
25
- (s) => i(n, s)
28
+ (s) => l(c, s)
26
29
  );
27
30
  };
28
31
  }
29
32
  function z(r) {
30
- const { isHalt: c, snapshotFragments: t, applyArtifact: e } = r;
31
- return (a) => c(a) ? a : e(a, t(a));
33
+ const {
34
+ isHalt: u,
35
+ isPaused: n,
36
+ snapshotFragments: t,
37
+ applyArtifact: e
38
+ } = r;
39
+ return (l) => n && n(l) || u(l) ? l : e(
40
+ l,
41
+ t(l)
42
+ );
32
43
  }
33
44
  function T(r) {
34
- const { isHalt: c, execute: t } = r;
35
- return (e) => c(e) ? e : t(e);
45
+ const { isHalt: u, isPaused: n, execute: t } = r;
46
+ return (e) => n && n(e) || u(e) ? e : t(e);
36
47
  }
37
48
  function V(r) {
38
- const { isHalt: c, commit: t, rollbackToHalt: e } = r, a = (i) => {
39
- const u = () => i;
40
- return y(
41
- () => S(t(i), u),
42
- (n) => e(i, n)
49
+ const {
50
+ isHalt: u,
51
+ isPaused: n,
52
+ commit: t,
53
+ rollbackToHalt: e
54
+ } = r, l = (i) => {
55
+ const k = () => i;
56
+ return R(
57
+ () => S(t(i), k),
58
+ (f) => e(i, f)
43
59
  );
44
60
  };
45
- return (i) => c(i) ? i : a(i);
61
+ return (i) => n && n(i) || u(i) ? i : l(i);
46
62
  }
47
- function j(r) {
48
- const { isHalt: c, finalize: t } = r;
49
- return (e) => c(e) ? e : t(e);
63
+ function B(r) {
64
+ const { isHalt: u, isPaused: n, finalize: t } = r;
65
+ return (e) => n && n(e) || u(e) ? e : t(e);
50
66
  }
51
67
  function M(r) {
52
- return function(t, e) {
68
+ return function(n, t) {
53
69
  const {
54
- pushStep: a,
55
- toRollbackContext: i,
56
- halt: u,
57
- isHalt: f,
58
- onHelperRollbackError: n
59
- } = r, k = ({
70
+ pushStep: e,
71
+ toRollbackContext: l,
72
+ halt: i,
73
+ isHalt: k,
74
+ onHelperRollbackError: c
75
+ } = r, f = t.invoke ?? (({
60
76
  helper: o,
61
77
  args: m,
62
- next: l
63
- }) => o.apply(m, l), p = (o) => (m, l) => {
64
- if (!(!l || typeof l != "object") && "rollback" in l) {
65
- const g = l.rollback;
66
- g && o.push({ helper: m, rollback: g });
78
+ next: a
79
+ }) => o.apply(m, a)), p = (o) => (m, a) => {
80
+ if (!(!a || typeof a != "object") && "rollback" in a) {
81
+ const d = a.rollback;
82
+ d && o.push({ helper: m, rollback: d });
67
83
  }
68
- }, s = () => n ? (o) => n({
84
+ }, s = () => c ? (o) => c({
69
85
  ...o,
70
86
  helper: o.helper
71
87
  }) : void 0;
72
88
  return (o) => {
73
- if (f(o))
89
+ if (k(o) || E(o))
74
90
  return o;
75
91
  let m = o.helperExecution;
76
92
  m || (m = /* @__PURE__ */ new Map(), o.helperExecution = m);
77
- let l = m.get(t);
78
- l || (l = {
79
- kind: t,
93
+ let a = m.get(n);
94
+ a || (a = {
95
+ kind: n,
80
96
  executed: [],
81
97
  missing: [],
82
98
  registered: []
83
99
  // Registered populated by getOrder result?
84
- }, m.set(t, l));
85
- const g = (b) => {
86
- a(b), l.executed.push(
87
- b.helper.key
100
+ }, m.set(n, a));
101
+ const d = (g) => {
102
+ e(g), a.executed.push(
103
+ g.helper.key
88
104
  );
89
- }, H = [
90
- ...e.readRollbacks?.(o) ?? []
91
- ], h = i(o), d = v({
92
- getOrder: e.getOrder,
93
- makeArgs: e.makeArgs,
94
- invoke: k,
95
- recordStep: g,
96
- onVisited: (b, R) => e.onVisited(b, R, H),
97
- registerRollback: p(H)
98
- }), x = {
99
- context: h.context,
100
- rollbackContext: h,
101
- helperRollbacks: H,
105
+ }, b = [
106
+ ...t.readRollbacks?.(o) ?? []
107
+ ], H = l(o), h = F({
108
+ getOrder: t.getOrder,
109
+ makeArgs: t.makeArgs,
110
+ invoke: f,
111
+ recordStep: d,
112
+ onVisited: (g, x) => t.onVisited(g, x, b),
113
+ registerRollback: p(b)
114
+ }), P = {
115
+ context: H.context,
116
+ rollbackContext: H,
117
+ helperRollbacks: b,
102
118
  onHelperRollbackError: s()
103
119
  };
104
- return F({
120
+ return C({
105
121
  state: o,
106
- program: d,
107
- rollbackPlan: x,
108
- halt: u
122
+ program: h,
123
+ rollbackPlan: P,
124
+ halt: i
109
125
  });
110
126
  };
111
127
  };
112
128
  }
113
129
  export {
114
- v as createHelpersProgram,
115
- _ as isHalt,
130
+ F as createHelpersProgram,
131
+ v as isHalt,
132
+ E as isPaused,
116
133
  T as makeAfterFragmentsStage,
117
134
  V as makeCommitStage,
118
135
  z as makeFinalizeFragmentsStage,
119
- j as makeFinalizeResultStage,
136
+ B as makeFinalizeResultStage,
120
137
  M as makeHelperStageFactory
121
138
  };