@temelj/workflow 0.0.0-alpha.1
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/LICENSE +21 -0
- package/README.md +38 -0
- package/dist/attributes.d.mts +15 -0
- package/dist/attributes.mjs +30 -0
- package/dist/client/create.d.mts +31 -0
- package/dist/client/create.mjs +67 -0
- package/dist/client/facades.d.mts +21 -0
- package/dist/client/facades.mjs +142 -0
- package/dist/client/mod.d.mts +2 -0
- package/dist/client/mod.mjs +2 -0
- package/dist/client/run-handle.d.mts +66 -0
- package/dist/client/run-handle.mjs +156 -0
- package/dist/client/worker-options.d.mts +17 -0
- package/dist/client/worker-options.mjs +25 -0
- package/dist/collection.d.mts +15 -0
- package/dist/collection.mjs +33 -0
- package/dist/compiled-function.d.mts +27 -0
- package/dist/compiled-function.mjs +54 -0
- package/dist/definition.d.mts +37 -0
- package/dist/definition.mjs +83 -0
- package/dist/engine/child-workflow.d.mts +10 -0
- package/dist/engine/child-workflow.mjs +333 -0
- package/dist/engine/command-identity.d.mts +9 -0
- package/dist/engine/command-identity.mjs +14 -0
- package/dist/engine/create.d.mts +106 -0
- package/dist/engine/create.mjs +402 -0
- package/dist/engine/deterministic.d.mts +12 -0
- package/dist/engine/deterministic.mjs +102 -0
- package/dist/engine/durable-command.d.mts +10 -0
- package/dist/engine/durable-command.mjs +17 -0
- package/dist/engine/execution-api.d.mts +29 -0
- package/dist/engine/execution-api.mjs +33 -0
- package/dist/engine/execution-service.d.mts +41 -0
- package/dist/engine/execution-service.mjs +288 -0
- package/dist/engine/hooks.d.mts +56 -0
- package/dist/engine/hooks.mjs +237 -0
- package/dist/engine/inspection-api.d.mts +34 -0
- package/dist/engine/inspection-api.mjs +77 -0
- package/dist/engine/inspection.d.mts +18 -0
- package/dist/engine/inspection.mjs +149 -0
- package/dist/engine/lifecycle.d.mts +18 -0
- package/dist/engine/lifecycle.mjs +38 -0
- package/dist/engine/lock-replay.d.mts +30 -0
- package/dist/engine/lock-replay.mjs +38 -0
- package/dist/engine/lock.d.mts +21 -0
- package/dist/engine/lock.mjs +197 -0
- package/dist/engine/message.d.mts +47 -0
- package/dist/engine/message.mjs +357 -0
- package/dist/engine/mod.d.mts +4 -0
- package/dist/engine/mod.mjs +2 -0
- package/dist/engine/observation.d.mts +35 -0
- package/dist/engine/observation.mjs +201 -0
- package/dist/engine/recovery.d.mts +26 -0
- package/dist/engine/recovery.mjs +92 -0
- package/dist/engine/replay.d.mts +41 -0
- package/dist/engine/replay.mjs +122 -0
- package/dist/engine/retry-policy.d.mts +4 -0
- package/dist/engine/retry-policy.mjs +4 -0
- package/dist/engine/retry.d.mts +23 -0
- package/dist/engine/retry.mjs +75 -0
- package/dist/engine/run-data.d.mts +9 -0
- package/dist/engine/run-data.mjs +74 -0
- package/dist/engine/run-service.d.mts +38 -0
- package/dist/engine/run-service.mjs +133 -0
- package/dist/engine/run-utils.d.mts +16 -0
- package/dist/engine/run-utils.mjs +83 -0
- package/dist/engine/schedule.d.mts +25 -0
- package/dist/engine/schedule.mjs +207 -0
- package/dist/engine/serialization.d.mts +9 -0
- package/dist/engine/serialization.mjs +85 -0
- package/dist/engine/start-api.d.mts +30 -0
- package/dist/engine/start-api.mjs +98 -0
- package/dist/engine/state.d.mts +77 -0
- package/dist/engine/state.mjs +464 -0
- package/dist/engine/step-api.d.mts +9 -0
- package/dist/engine/step-api.mjs +25 -0
- package/dist/engine/stream.d.mts +55 -0
- package/dist/engine/stream.mjs +333 -0
- package/dist/engine/summary/active-events.d.mts +34 -0
- package/dist/engine/summary/active-events.mjs +69 -0
- package/dist/engine/summary/child-workflow-runs.d.mts +24 -0
- package/dist/engine/summary/child-workflow-runs.mjs +138 -0
- package/dist/engine/summary/child-workflow-waits.d.mts +21 -0
- package/dist/engine/summary/child-workflow-waits.mjs +67 -0
- package/dist/engine/summary/recovery-child-workflow-waits.d.mts +11 -0
- package/dist/engine/summary/recovery-child-workflow-waits.mjs +89 -0
- package/dist/engine/summary/recovery-due-runs.d.mts +16 -0
- package/dist/engine/summary/recovery-due-runs.mjs +52 -0
- package/dist/engine/summary/recovery-failed-runs.d.mts +14 -0
- package/dist/engine/summary/recovery-failed-runs.mjs +33 -0
- package/dist/engine/summary/recovery-lease-runs.d.mts +16 -0
- package/dist/engine/summary/recovery-lease-runs.mjs +69 -0
- package/dist/engine/summary/recovery-locks.d.mts +18 -0
- package/dist/engine/summary/recovery-locks.mjs +100 -0
- package/dist/engine/summary/recovery-message-waits.d.mts +11 -0
- package/dist/engine/summary/recovery-message-waits.mjs +74 -0
- package/dist/engine/summary/recovery-retry-runs.d.mts +17 -0
- package/dist/engine/summary/recovery-retry-runs.mjs +65 -0
- package/dist/engine/summary/recovery-run-timestamps.d.mts +13 -0
- package/dist/engine/summary/recovery-run-timestamps.mjs +18 -0
- package/dist/engine/summary/recovery-runs.d.mts +23 -0
- package/dist/engine/summary/recovery-runs.mjs +54 -0
- package/dist/engine/summary/recovery-schedules.d.mts +10 -0
- package/dist/engine/summary/recovery-schedules.mjs +46 -0
- package/dist/engine/summary/recovery-sleep-waits.d.mts +10 -0
- package/dist/engine/summary/recovery-sleep-waits.mjs +53 -0
- package/dist/engine/summary/recovery-waits.d.mts +21 -0
- package/dist/engine/summary/recovery-waits.mjs +29 -0
- package/dist/engine/summary/run-availability.d.mts +13 -0
- package/dist/engine/summary/run-availability.mjs +37 -0
- package/dist/engine/summary/run-cleanup.d.mts +14 -0
- package/dist/engine/summary/run-cleanup.mjs +44 -0
- package/dist/engine/summary/run-failure.d.mts +14 -0
- package/dist/engine/summary/run-failure.mjs +62 -0
- package/dist/engine/summary/run-hooks.d.mts +14 -0
- package/dist/engine/summary/run-hooks.mjs +63 -0
- package/dist/engine/summary/run-lease.d.mts +11 -0
- package/dist/engine/summary/run-lease.mjs +64 -0
- package/dist/engine/summary/run-message-waits.d.mts +15 -0
- package/dist/engine/summary/run-message-waits.mjs +62 -0
- package/dist/engine/summary/run-metrics.d.mts +31 -0
- package/dist/engine/summary/run-metrics.mjs +93 -0
- package/dist/engine/summary/run-retry.d.mts +9 -0
- package/dist/engine/summary/run-retry.mjs +69 -0
- package/dist/engine/summary/run-sleeps.d.mts +15 -0
- package/dist/engine/summary/run-sleeps.mjs +61 -0
- package/dist/engine/summary/run-state.d.mts +26 -0
- package/dist/engine/summary/run-state.mjs +48 -0
- package/dist/engine/summary/run-status.d.mts +16 -0
- package/dist/engine/summary/run-status.mjs +35 -0
- package/dist/engine/summary/run-streams.d.mts +14 -0
- package/dist/engine/summary/run-streams.mjs +46 -0
- package/dist/engine/summary/run-transition.d.mts +9 -0
- package/dist/engine/summary/run-transition.mjs +39 -0
- package/dist/engine/summary/run-workflow.d.mts +9 -0
- package/dist/engine/summary/run-workflow.mjs +47 -0
- package/dist/engine/summary/step-attempt-active-child-workflows.d.mts +13 -0
- package/dist/engine/summary/step-attempt-active-child-workflows.mjs +55 -0
- package/dist/engine/summary/step-attempt-active-fields.d.mts +23 -0
- package/dist/engine/summary/step-attempt-active-fields.mjs +14 -0
- package/dist/engine/summary/step-attempt-active-message-waits.d.mts +12 -0
- package/dist/engine/summary/step-attempt-active-message-waits.mjs +47 -0
- package/dist/engine/summary/step-attempt-active-sleeps.d.mts +19 -0
- package/dist/engine/summary/step-attempt-active-sleeps.mjs +44 -0
- package/dist/engine/summary/step-attempt-buckets.d.mts +22 -0
- package/dist/engine/summary/step-attempt-buckets.mjs +152 -0
- package/dist/engine/summary/step-attempt-failure.d.mts +12 -0
- package/dist/engine/summary/step-attempt-failure.mjs +61 -0
- package/dist/engine/summary/step-attempt-lifecycle.d.mts +13 -0
- package/dist/engine/summary/step-attempt-lifecycle.mjs +19 -0
- package/dist/engine/summary/step-attempts.d.mts +11 -0
- package/dist/engine/summary/step-attempts.mjs +43 -0
- package/dist/engine/summary.d.mts +32 -0
- package/dist/engine/summary.mjs +37 -0
- package/dist/engine/task.d.mts +6 -0
- package/dist/engine/task.mjs +207 -0
- package/dist/errors/base.d.mts +99 -0
- package/dist/errors/base.mjs +426 -0
- package/dist/errors/capability.d.mts +11 -0
- package/dist/errors/capability.mjs +23 -0
- package/dist/errors/definition.d.mts +21 -0
- package/dist/errors/definition.mjs +51 -0
- package/dist/errors/details.d.mts +13 -0
- package/dist/errors/details.mjs +65 -0
- package/dist/errors/failures.d.mts +81 -0
- package/dist/errors/failures.mjs +168 -0
- package/dist/errors/hook.d.mts +14 -0
- package/dist/errors/hook.mjs +30 -0
- package/dist/errors/implementation.d.mts +11 -0
- package/dist/errors/implementation.mjs +25 -0
- package/dist/errors/lock.d.mts +28 -0
- package/dist/errors/lock.mjs +70 -0
- package/dist/errors/message.d.mts +106 -0
- package/dist/errors/message.mjs +122 -0
- package/dist/errors/mod.d.mts +17 -0
- package/dist/errors/mod.mjs +17 -0
- package/dist/errors/record-view.d.mts +11 -0
- package/dist/errors/record-view.mjs +24 -0
- package/dist/errors/records.d.mts +7 -0
- package/dist/errors/records.mjs +280 -0
- package/dist/errors/run.d.mts +116 -0
- package/dist/errors/run.mjs +232 -0
- package/dist/errors/runtime.d.mts +12 -0
- package/dist/errors/runtime.mjs +24 -0
- package/dist/errors/schedule.d.mts +27 -0
- package/dist/errors/schedule.mjs +65 -0
- package/dist/errors/step.d.mts +76 -0
- package/dist/errors/step.mjs +113 -0
- package/dist/errors/stream.d.mts +24 -0
- package/dist/errors/stream.mjs +64 -0
- package/dist/esbuild.d.mts +7 -0
- package/dist/esbuild.mjs +6 -0
- package/dist/events/descriptors.d.mts +245 -0
- package/dist/events/descriptors.mjs +405 -0
- package/dist/events/mod.d.mts +3 -0
- package/dist/events/mod.mjs +2 -0
- package/dist/history/attempt-key.d.mts +6 -0
- package/dist/history/attempt-key.mjs +7 -0
- package/dist/history/mod.d.mts +71 -0
- package/dist/history/mod.mjs +195 -0
- package/dist/history/projection.d.mts +8 -0
- package/dist/history/projection.mjs +259 -0
- package/dist/history/replay-projection.d.mts +88 -0
- package/dist/history/replay-projection.mjs +369 -0
- package/dist/history/sequencer.d.mts +16 -0
- package/dist/history/sequencer.mjs +78 -0
- package/dist/history/step-attempts.d.mts +9 -0
- package/dist/history/step-attempts.mjs +50 -0
- package/dist/history/timeline.d.mts +16 -0
- package/dist/history/timeline.mjs +272 -0
- package/dist/history/validator.d.mts +9 -0
- package/dist/history/validator.mjs +110 -0
- package/dist/inspection/mod.d.mts +5 -0
- package/dist/inspection/mod.mjs +3 -0
- package/dist/message-options.d.mts +8 -0
- package/dist/message-options.mjs +25 -0
- package/dist/mod.d.mts +52 -0
- package/dist/mod.mjs +26 -0
- package/dist/otel/support.d.mts +18 -0
- package/dist/otel/support.mjs +102 -0
- package/dist/otel.d.mts +30 -0
- package/dist/otel.mjs +588 -0
- package/dist/pagination.d.mts +25 -0
- package/dist/pagination.mjs +73 -0
- package/dist/registry.d.mts +20 -0
- package/dist/registry.mjs +48 -0
- package/dist/rolldown.d.mts +7 -0
- package/dist/rolldown.mjs +6 -0
- package/dist/rollup.d.mts +7 -0
- package/dist/rollup.mjs +6 -0
- package/dist/rspack.d.mts +7 -0
- package/dist/rspack.mjs +6 -0
- package/dist/runtime.d.mts +34 -0
- package/dist/runtime.mjs +194 -0
- package/dist/step-definition.d.mts +10 -0
- package/dist/step-definition.mjs +15 -0
- package/dist/store/append-projection.d.mts +15 -0
- package/dist/store/append-projection.mjs +26 -0
- package/dist/store/capabilities.d.mts +14 -0
- package/dist/store/capabilities.mjs +42 -0
- package/dist/store/cleanup.d.mts +18 -0
- package/dist/store/cleanup.mjs +338 -0
- package/dist/store/compaction.d.mts +5 -0
- package/dist/store/compaction.mjs +8 -0
- package/dist/store/create.d.mts +52 -0
- package/dist/store/create.mjs +159 -0
- package/dist/store/event-append-project.d.mts +15 -0
- package/dist/store/event-append-project.mjs +77 -0
- package/dist/store/event-append.d.mts +37 -0
- package/dist/store/event-append.mjs +80 -0
- package/dist/store/event-history.d.mts +22 -0
- package/dist/store/event-history.mjs +75 -0
- package/dist/store/event.d.mts +10 -0
- package/dist/store/event.mjs +28 -0
- package/dist/store/idempotency.d.mts +10 -0
- package/dist/store/idempotency.mjs +167 -0
- package/dist/store/instrumentation.d.mts +7 -0
- package/dist/store/instrumentation.mjs +123 -0
- package/dist/store/lock.d.mts +8 -0
- package/dist/store/lock.mjs +28 -0
- package/dist/store/materialization.d.mts +30 -0
- package/dist/store/materialization.mjs +127 -0
- package/dist/store/message-index.d.mts +21 -0
- package/dist/store/message-index.mjs +121 -0
- package/dist/store/mod.d.mts +5 -0
- package/dist/store/mod.mjs +4 -0
- package/dist/store/query.d.mts +24 -0
- package/dist/store/query.mjs +82 -0
- package/dist/store/revision.d.mts +4 -0
- package/dist/store/revision.mjs +7 -0
- package/dist/store/run.d.mts +49 -0
- package/dist/store/run.mjs +236 -0
- package/dist/store/schedule.d.mts +12 -0
- package/dist/store/schedule.mjs +41 -0
- package/dist/store/schema.d.mts +14 -0
- package/dist/store/schema.mjs +17 -0
- package/dist/store/step-attempt.d.mts +14 -0
- package/dist/store/step-attempt.mjs +23 -0
- package/dist/store/storage-value.d.mts +5 -0
- package/dist/store/storage-value.mjs +6 -0
- package/dist/store/validation.d.mts +35 -0
- package/dist/store/validation.mjs +77 -0
- package/dist/store-keys.d.mts +49 -0
- package/dist/store-keys.mjs +63 -0
- package/dist/telemetry.d.mts +132 -0
- package/dist/telemetry.mjs +172 -0
- package/dist/temporal.d.mts +23 -0
- package/dist/temporal.mjs +59 -0
- package/dist/timer.d.mts +12 -0
- package/dist/timer.mjs +28 -0
- package/dist/types/cleanup.d.mts +112 -0
- package/dist/types/cleanup.mjs +22 -0
- package/dist/types/client.d.mts +270 -0
- package/dist/types/client.mjs +1 -0
- package/dist/types/common.d.mts +19 -0
- package/dist/types/common.mjs +15 -0
- package/dist/types/definition.d.mts +92 -0
- package/dist/types/definition.mjs +1 -0
- package/dist/types/engine-options.d.mts +76 -0
- package/dist/types/engine-options.mjs +1 -0
- package/dist/types/engine.d.mts +309 -0
- package/dist/types/engine.mjs +1 -0
- package/dist/types/error-code.d.mts +256 -0
- package/dist/types/error-code.mjs +131 -0
- package/dist/types/error.d.mts +236 -0
- package/dist/types/error.mjs +48 -0
- package/dist/types/events.d.mts +2869 -0
- package/dist/types/events.mjs +283 -0
- package/dist/types/hook.d.mts +149 -0
- package/dist/types/hook.mjs +66 -0
- package/dist/types/lock.d.mts +63 -0
- package/dist/types/lock.mjs +18 -0
- package/dist/types/message-id.d.mts +7 -0
- package/dist/types/message-id.mjs +5 -0
- package/dist/types/message.d.mts +87 -0
- package/dist/types/message.mjs +1 -0
- package/dist/types/observation.d.mts +146 -0
- package/dist/types/observation.mjs +1 -0
- package/dist/types/pagination.d.mts +32 -0
- package/dist/types/pagination.mjs +13 -0
- package/dist/types/result.d.mts +62 -0
- package/dist/types/result.mjs +1 -0
- package/dist/types/retry.d.mts +48 -0
- package/dist/types/retry.mjs +1 -0
- package/dist/types/run-id.d.mts +7 -0
- package/dist/types/run-id.mjs +5 -0
- package/dist/types/run-list.d.mts +43 -0
- package/dist/types/run-list.mjs +1 -0
- package/dist/types/run-options.d.mts +86 -0
- package/dist/types/run-options.mjs +1 -0
- package/dist/types/run.d.mts +355 -0
- package/dist/types/run.mjs +207 -0
- package/dist/types/runtime.d.mts +143 -0
- package/dist/types/runtime.mjs +21 -0
- package/dist/types/schedule.d.mts +127 -0
- package/dist/types/schedule.mjs +48 -0
- package/dist/types/step-attempts.d.mts +326 -0
- package/dist/types/step-attempts.mjs +43 -0
- package/dist/types/step-id.d.mts +7 -0
- package/dist/types/step-id.mjs +5 -0
- package/dist/types/step.d.mts +183 -0
- package/dist/types/step.mjs +5 -0
- package/dist/types/store.d.mts +254 -0
- package/dist/types/store.mjs +1 -0
- package/dist/types/stream-id.d.mts +7 -0
- package/dist/types/stream-id.mjs +5 -0
- package/dist/types/stream.d.mts +126 -0
- package/dist/types/stream.mjs +1 -0
- package/dist/types/summary.d.mts +318 -0
- package/dist/types/summary.mjs +1 -0
- package/dist/types/telemetry.d.mts +74 -0
- package/dist/types/telemetry.mjs +9 -0
- package/dist/types/timeline.d.mts +237 -0
- package/dist/types/timeline.mjs +1 -0
- package/dist/types/vite.d.mts +65 -0
- package/dist/types/vite.mjs +1 -0
- package/dist/types/worker-id.d.mts +7 -0
- package/dist/types/worker-id.mjs +5 -0
- package/dist/types/worker.d.mts +94 -0
- package/dist/types/worker.mjs +1 -0
- package/dist/utility.d.mts +49 -0
- package/dist/utility.mjs +122 -0
- package/dist/vite/ast.d.mts +23 -0
- package/dist/vite/ast.mjs +73 -0
- package/dist/vite/error.d.mts +19 -0
- package/dist/vite/error.mjs +47 -0
- package/dist/vite/generated-name.d.mts +7 -0
- package/dist/vite/generated-name.mjs +9 -0
- package/dist/vite/manifest.d.mts +7 -0
- package/dist/vite/manifest.mjs +106 -0
- package/dist/vite/plugin.d.mts +7 -0
- package/dist/vite/plugin.mjs +190 -0
- package/dist/vite/safety.d.mts +12 -0
- package/dist/vite/safety.mjs +96 -0
- package/dist/vite/source-edit.d.mts +12 -0
- package/dist/vite/source-edit.mjs +44 -0
- package/dist/vite/source-map.d.mts +11 -0
- package/dist/vite/source-map.mjs +53 -0
- package/dist/vite/source.d.mts +7 -0
- package/dist/vite/source.mjs +14 -0
- package/dist/vite/transform.d.mts +7 -0
- package/dist/vite/transform.mjs +405 -0
- package/dist/vite.d.mts +6 -0
- package/dist/vite.mjs +5 -0
- package/dist/webhook.d.mts +16 -0
- package/dist/webhook.mjs +17 -0
- package/dist/webpack.d.mts +7 -0
- package/dist/webpack.mjs +6 -0
- package/dist/worker/error.d.mts +11 -0
- package/dist/worker/error.mjs +40 -0
- package/dist/worker.d.mts +18 -0
- package/dist/worker.mjs +427 -0
- package/package.json +144 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { VitePluginOptions, WorkflowPluginOptions } from "../types/vite.mjs";
|
|
2
|
+
//#region src/vite/plugin.d.ts
|
|
3
|
+
declare const workflowPlugin: import("unplugin").UnpluginInstance<WorkflowPluginOptions | undefined, false>;
|
|
4
|
+
/** Creates the Vite plugin that compiles workflow and step directives. */
|
|
5
|
+
declare const workflow: (options?: VitePluginOptions) => ReturnType<typeof workflowPlugin.vite>;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { type VitePluginOptions, type WorkflowPluginOptions, workflow, workflowPlugin };
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { stripQuery } from "./source.mjs";
|
|
2
|
+
import { parseWorkflowSource } from "./ast.mjs";
|
|
3
|
+
import { transformWorkflowSource } from "./transform.mjs";
|
|
4
|
+
import fs from "node:fs/promises";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { createUnplugin } from "unplugin";
|
|
7
|
+
//#region src/vite/plugin.ts
|
|
8
|
+
const workflowUnpluginFactory = (options = {}) => {
|
|
9
|
+
const include = options.include?.map((pattern) => new RegExp(pattern));
|
|
10
|
+
const exclude = options.exclude?.map((pattern) => new RegExp(pattern));
|
|
11
|
+
const manifests = /* @__PURE__ */ new Map();
|
|
12
|
+
const manifestFileById = /* @__PURE__ */ new Map();
|
|
13
|
+
const loadingManifests = /* @__PURE__ */ new Set();
|
|
14
|
+
return {
|
|
15
|
+
name: "temelj-workflow",
|
|
16
|
+
enforce: "pre",
|
|
17
|
+
transformInclude(id) {
|
|
18
|
+
return matchesFilters(id, include, exclude);
|
|
19
|
+
},
|
|
20
|
+
async transform(code, id) {
|
|
21
|
+
await loadWorkflowImportManifests({
|
|
22
|
+
context: this,
|
|
23
|
+
code,
|
|
24
|
+
id,
|
|
25
|
+
options,
|
|
26
|
+
include,
|
|
27
|
+
exclude,
|
|
28
|
+
manifests,
|
|
29
|
+
manifestFileById,
|
|
30
|
+
loadingManifests
|
|
31
|
+
});
|
|
32
|
+
const result = transformAndStoreWorkflowManifest(code, id, options, manifests, manifestFileById);
|
|
33
|
+
if (result === void 0) return null;
|
|
34
|
+
return {
|
|
35
|
+
code: result.code,
|
|
36
|
+
...result.map === void 0 ? {} : { map: toUnpluginSourceMap(result.map) }
|
|
37
|
+
};
|
|
38
|
+
},
|
|
39
|
+
vite: { handleHotUpdate(context) {
|
|
40
|
+
if (!matchesFilters(context.file, include, exclude)) return;
|
|
41
|
+
const modules = context.modules.filter((module) => module.id !== null);
|
|
42
|
+
if (modules.length === 0) return;
|
|
43
|
+
return modules;
|
|
44
|
+
} }
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
const JS_TS_EXTENSION_PATTERN = /\.[cm]?[jt]sx?$/;
|
|
48
|
+
function toUnpluginSourceMap(map) {
|
|
49
|
+
return map;
|
|
50
|
+
}
|
|
51
|
+
const workflowPlugin = createUnplugin(workflowUnpluginFactory);
|
|
52
|
+
/** Creates the Vite plugin that compiles workflow and step directives. */
|
|
53
|
+
const workflow = workflowPlugin.vite;
|
|
54
|
+
async function loadWorkflowImportManifests({ context, code, id, options, include, exclude, manifests, manifestFileById, loadingManifests }) {
|
|
55
|
+
if (!hasWorkflowManifestCandidate(code) || loadingManifests.has(id)) return;
|
|
56
|
+
loadingManifests.add(id);
|
|
57
|
+
try {
|
|
58
|
+
for (const source of collectRelativeImportSources(code, id)) if (canLoadWorkflowImportManifests(context)) {
|
|
59
|
+
const resolved = await context.resolve(source, id, { skipSelf: true });
|
|
60
|
+
if (resolved === null || !matchesFilters(resolved.id, include, exclude)) continue;
|
|
61
|
+
await context.load({ id: resolved.id });
|
|
62
|
+
await preloadWorkflowImportFile({
|
|
63
|
+
context,
|
|
64
|
+
id: resolved.id,
|
|
65
|
+
options,
|
|
66
|
+
include,
|
|
67
|
+
exclude,
|
|
68
|
+
manifests,
|
|
69
|
+
manifestFileById,
|
|
70
|
+
loadingManifests
|
|
71
|
+
});
|
|
72
|
+
} else {
|
|
73
|
+
const resolved = await resolveRelativeImportFile(source, id);
|
|
74
|
+
if (resolved === void 0 || !matchesFilters(resolved, include, exclude)) continue;
|
|
75
|
+
await preloadWorkflowImportFile({
|
|
76
|
+
context,
|
|
77
|
+
id: resolved,
|
|
78
|
+
options,
|
|
79
|
+
include,
|
|
80
|
+
exclude,
|
|
81
|
+
manifests,
|
|
82
|
+
manifestFileById,
|
|
83
|
+
loadingManifests
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
} finally {
|
|
87
|
+
loadingManifests.delete(id);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
async function preloadWorkflowImportFile({ context, id, options, include, exclude, manifests, manifestFileById, loadingManifests }) {
|
|
91
|
+
const cleanId = stripQuery(id);
|
|
92
|
+
const importedCode = await fs.readFile(cleanId, "utf8").catch(() => void 0);
|
|
93
|
+
if (importedCode === void 0) return;
|
|
94
|
+
await loadWorkflowImportManifests({
|
|
95
|
+
context,
|
|
96
|
+
code: importedCode,
|
|
97
|
+
id: cleanId,
|
|
98
|
+
options,
|
|
99
|
+
include,
|
|
100
|
+
exclude,
|
|
101
|
+
manifests,
|
|
102
|
+
manifestFileById,
|
|
103
|
+
loadingManifests
|
|
104
|
+
});
|
|
105
|
+
transformAndStoreWorkflowManifest(importedCode, cleanId, options, manifests, manifestFileById);
|
|
106
|
+
}
|
|
107
|
+
function transformAndStoreWorkflowManifest(code, id, options, manifests, manifestFileById) {
|
|
108
|
+
const result = transformWorkflowSource(code, id, {
|
|
109
|
+
...options,
|
|
110
|
+
manifests: [...options.manifests ?? [], ...manifests.values()]
|
|
111
|
+
});
|
|
112
|
+
if (result === void 0) {
|
|
113
|
+
manifests.delete(id);
|
|
114
|
+
const previousFile = manifestFileById.get(id);
|
|
115
|
+
if (previousFile !== void 0) {
|
|
116
|
+
manifests.delete(previousFile);
|
|
117
|
+
manifestFileById.delete(id);
|
|
118
|
+
}
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
manifests.set(id, result.manifest);
|
|
122
|
+
manifests.set(result.manifest.file, result.manifest);
|
|
123
|
+
manifestFileById.set(id, result.manifest.file);
|
|
124
|
+
return result;
|
|
125
|
+
}
|
|
126
|
+
function canLoadWorkflowImportManifests(context) {
|
|
127
|
+
return typeof context.resolve === "function" && typeof context.load === "function";
|
|
128
|
+
}
|
|
129
|
+
function hasWorkflowManifestCandidate(code) {
|
|
130
|
+
return code.includes("\"use workflow\"") || code.includes("'use workflow'") || code.includes("\"use step\"") || code.includes("'use step'") || code.includes(" from ");
|
|
131
|
+
}
|
|
132
|
+
function collectRelativeImportSources(code, id) {
|
|
133
|
+
if (!JS_TS_EXTENSION_PATTERN.test(stripQuery(id))) return [];
|
|
134
|
+
const sourceFile = parseWorkflowSource(id, code);
|
|
135
|
+
const sources = /* @__PURE__ */ new Set();
|
|
136
|
+
for (const statement of sourceFile.program.body) if ((statement.type === "ImportDeclaration" || statement.type === "ExportNamedDeclaration" || statement.type === "ExportAllDeclaration") && statement.source !== null && isRelativeImportSource(statement.source.value)) sources.add(statement.source.value);
|
|
137
|
+
return [...sources];
|
|
138
|
+
}
|
|
139
|
+
function isRelativeImportSource(source) {
|
|
140
|
+
return source.startsWith("./") || source.startsWith("../");
|
|
141
|
+
}
|
|
142
|
+
const RELATIVE_IMPORT_EXTENSIONS = [
|
|
143
|
+
"",
|
|
144
|
+
".ts",
|
|
145
|
+
".tsx",
|
|
146
|
+
".mts",
|
|
147
|
+
".cts",
|
|
148
|
+
".js",
|
|
149
|
+
".jsx",
|
|
150
|
+
".mjs",
|
|
151
|
+
".cjs",
|
|
152
|
+
"/index.ts",
|
|
153
|
+
"/index.tsx",
|
|
154
|
+
"/index.mts",
|
|
155
|
+
"/index.cts",
|
|
156
|
+
"/index.js",
|
|
157
|
+
"/index.jsx",
|
|
158
|
+
"/index.mjs",
|
|
159
|
+
"/index.cjs"
|
|
160
|
+
];
|
|
161
|
+
async function resolveRelativeImportFile(source, importer) {
|
|
162
|
+
const cleanImporter = stripQuery(importer);
|
|
163
|
+
const base = path.resolve(path.dirname(cleanImporter), source);
|
|
164
|
+
for (const candidate of relativeImportCandidates(base)) if ((await fs.stat(candidate).catch(() => void 0))?.isFile() === true) return candidate;
|
|
165
|
+
}
|
|
166
|
+
function relativeImportCandidates(base) {
|
|
167
|
+
const candidates = RELATIVE_IMPORT_EXTENSIONS.map((extension) => `${base}${extension}`);
|
|
168
|
+
const extension = path.extname(base);
|
|
169
|
+
const mappedExtensions = ESM_SOURCE_EXTENSION_BY_IMPORT_EXTENSION.get(extension);
|
|
170
|
+
if (mappedExtensions === void 0) return candidates;
|
|
171
|
+
const withoutExtension = base.slice(0, -extension.length);
|
|
172
|
+
return [
|
|
173
|
+
base,
|
|
174
|
+
...mappedExtensions.map((mappedExtension) => `${withoutExtension}${mappedExtension}`),
|
|
175
|
+
...candidates.slice(1)
|
|
176
|
+
];
|
|
177
|
+
}
|
|
178
|
+
const ESM_SOURCE_EXTENSION_BY_IMPORT_EXTENSION = /* @__PURE__ */ new Map([
|
|
179
|
+
[".js", [".ts", ".tsx"]],
|
|
180
|
+
[".jsx", [".tsx"]],
|
|
181
|
+
[".mjs", [".mts"]],
|
|
182
|
+
[".cjs", [".cts"]]
|
|
183
|
+
]);
|
|
184
|
+
function matchesFilters(id, include, exclude) {
|
|
185
|
+
if (exclude?.some((pattern) => pattern.test(id)) === true) return false;
|
|
186
|
+
if (include !== void 0 && !include.some((pattern) => pattern.test(id))) return false;
|
|
187
|
+
return true;
|
|
188
|
+
}
|
|
189
|
+
//#endregion
|
|
190
|
+
export { workflow, workflowPlugin };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FunctionBody, Program } from "oxc-parser";
|
|
2
|
+
//#region src/vite/safety.d.ts
|
|
3
|
+
interface WorkflowSafetyTarget {
|
|
4
|
+
readonly name: string;
|
|
5
|
+
readonly body: FunctionBody;
|
|
6
|
+
}
|
|
7
|
+
declare function rejectObviousNondeterministicGlobals(entry: WorkflowSafetyTarget, sourceFile: {
|
|
8
|
+
readonly text: string;
|
|
9
|
+
readonly program: Program;
|
|
10
|
+
}): void;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { rejectObviousNondeterministicGlobals };
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { lineAndColumnOfPosition, visitWorkflowNode } from "./ast.mjs";
|
|
2
|
+
import { WorkflowTransformError } from "./error.mjs";
|
|
3
|
+
import { builtinModules } from "node:module";
|
|
4
|
+
//#region src/vite/safety.ts
|
|
5
|
+
const unsafeGlobalCallNames = /* @__PURE__ */ new Set([
|
|
6
|
+
"Date",
|
|
7
|
+
"fetch",
|
|
8
|
+
"setTimeout",
|
|
9
|
+
"setInterval",
|
|
10
|
+
"setImmediate",
|
|
11
|
+
"queueMicrotask"
|
|
12
|
+
]);
|
|
13
|
+
function rejectObviousNondeterministicGlobals(entry, sourceFile) {
|
|
14
|
+
const unsafeImports = collectUnsafeWorkflowImportBindings(sourceFile.program);
|
|
15
|
+
visitWorkflowNode(entry.body, (node) => {
|
|
16
|
+
if (isIdentifier(node) && unsafeImports.has(node.name)) throwNondeterministicGlobalError(entry.name, unsafeImports.get(node.name), node, sourceFile);
|
|
17
|
+
if (isNewExpression(node) && isIdentifier(node.callee) && node.callee.name === "Date") throwNondeterministicGlobalError(entry.name, "Date", node, sourceFile);
|
|
18
|
+
if (isCallExpression(node) && isIdentifier(node.callee) && unsafeGlobalCallNames.has(node.callee.name)) throwNondeterministicGlobalError(entry.name, node.callee.name, node, sourceFile);
|
|
19
|
+
if (isStaticMemberExpression(node)) {
|
|
20
|
+
const unsafeGlobal = unsafeGlobalPropertyAccessName(node);
|
|
21
|
+
if (unsafeGlobal !== void 0) throwNondeterministicGlobalError(entry.name, unsafeGlobal, node, sourceFile);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function collectUnsafeWorkflowImportBindings(sourceFile) {
|
|
26
|
+
const bindings = /* @__PURE__ */ new Map();
|
|
27
|
+
for (const statement of sourceFile.body) {
|
|
28
|
+
if (statement.type !== "ImportDeclaration") continue;
|
|
29
|
+
const specifier = statement.source.value;
|
|
30
|
+
if (!isNodeBuiltinSpecifier(specifier)) continue;
|
|
31
|
+
for (const importSpecifier of statement.specifiers) {
|
|
32
|
+
if (importSpecifier.type === "ImportDefaultSpecifier") {
|
|
33
|
+
bindings.set(importSpecifier.local.name, specifier);
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (importSpecifier.type === "ImportNamespaceSpecifier") {
|
|
37
|
+
bindings.set(importSpecifier.local.name, specifier);
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
bindings.set(importSpecifier.local.name, `${specifier}.${importName(importSpecifier)}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return bindings;
|
|
44
|
+
}
|
|
45
|
+
function importName(importSpecifier) {
|
|
46
|
+
if (importSpecifier.type !== "ImportSpecifier") return importSpecifier.local.name;
|
|
47
|
+
return importSpecifier.imported.type === "Literal" ? String(importSpecifier.imported.value) : importSpecifier.imported.name;
|
|
48
|
+
}
|
|
49
|
+
function isNodeBuiltinSpecifier(specifier) {
|
|
50
|
+
const normalized = specifier.startsWith("node:") ? specifier.slice(5) : specifier;
|
|
51
|
+
const root = normalized.split("/", 1)[0];
|
|
52
|
+
return builtinModules.includes(normalized) || builtinModules.includes(root);
|
|
53
|
+
}
|
|
54
|
+
function throwNondeterministicGlobalError(workflowName, globalName, node, sourceFile) {
|
|
55
|
+
const position = lineAndColumnOfPosition(sourceFile.text, node.start);
|
|
56
|
+
WorkflowTransformError.nondeterministicGlobal(workflowName, globalName, position.line, position.column);
|
|
57
|
+
}
|
|
58
|
+
function unsafeGlobalPropertyAccessName(node) {
|
|
59
|
+
const path = propertyAccessPath(node);
|
|
60
|
+
if (path === void 0) return;
|
|
61
|
+
const normalized = stripGlobalQualifier(path);
|
|
62
|
+
if (normalized === "Date.now" || normalized === "Math.random" || normalized === "process.env" || normalized === "crypto.randomUUID" || normalized === "crypto.getRandomValues" || normalized === "performance.now" || normalized === "import.meta.env") return normalized;
|
|
63
|
+
if (normalized === "setTimeout" || normalized === "setInterval" || normalized === "setImmediate" || normalized === "queueMicrotask") return normalized;
|
|
64
|
+
}
|
|
65
|
+
function propertyAccessPath(node) {
|
|
66
|
+
const left = propertyAccessExpressionPath(node.object);
|
|
67
|
+
return left === void 0 ? void 0 : `${left}.${node.property.name}`;
|
|
68
|
+
}
|
|
69
|
+
function propertyAccessExpressionPath(expression) {
|
|
70
|
+
if (isIdentifier(expression)) return expression.name;
|
|
71
|
+
if (isMetaProperty(expression)) return `${expression.meta.name}.${expression.property.name}`;
|
|
72
|
+
if (isStaticMemberExpression(expression)) return propertyAccessPath(expression);
|
|
73
|
+
}
|
|
74
|
+
function stripGlobalQualifier(path) {
|
|
75
|
+
if (path.startsWith("globalThis.")) return path.slice(11);
|
|
76
|
+
if (path.startsWith("global.")) return path.slice(7);
|
|
77
|
+
if (path.startsWith("window.")) return path.slice(7);
|
|
78
|
+
return path;
|
|
79
|
+
}
|
|
80
|
+
function isIdentifier(node) {
|
|
81
|
+
return node.type === "Identifier";
|
|
82
|
+
}
|
|
83
|
+
function isCallExpression(node) {
|
|
84
|
+
return node.type === "CallExpression";
|
|
85
|
+
}
|
|
86
|
+
function isNewExpression(node) {
|
|
87
|
+
return node.type === "NewExpression";
|
|
88
|
+
}
|
|
89
|
+
function isMetaProperty(node) {
|
|
90
|
+
return node.type === "MetaProperty";
|
|
91
|
+
}
|
|
92
|
+
function isStaticMemberExpression(node) {
|
|
93
|
+
return node.type === "MemberExpression" && node.computed === false;
|
|
94
|
+
}
|
|
95
|
+
//#endregion
|
|
96
|
+
export { rejectObviousNondeterministicGlobals };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/vite/source-edit.d.ts
|
|
2
|
+
/** Small source rewriting helper for AST-position based transforms. */
|
|
3
|
+
declare class SourceEditor {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(source: string);
|
|
6
|
+
remove(start: number, end: number): void;
|
|
7
|
+
replace(start: number, end: number, text: string): void;
|
|
8
|
+
read(start: number, end: number): string;
|
|
9
|
+
toString(): string;
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { SourceEditor };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { WorkflowTransformError } from "./error.mjs";
|
|
2
|
+
//#region src/vite/source-edit.ts
|
|
3
|
+
/** Small source rewriting helper for AST-position based transforms. */
|
|
4
|
+
var SourceEditor = class {
|
|
5
|
+
#source;
|
|
6
|
+
#replacements = [];
|
|
7
|
+
constructor(source) {
|
|
8
|
+
this.#source = source;
|
|
9
|
+
}
|
|
10
|
+
remove(start, end) {
|
|
11
|
+
this.replace(start, end, "");
|
|
12
|
+
}
|
|
13
|
+
replace(start, end, text) {
|
|
14
|
+
if (start < 0 || end < start || end > this.#source.length) WorkflowTransformError.invalidSourceReplacementRange(start, end);
|
|
15
|
+
this.#replacements.push({
|
|
16
|
+
start,
|
|
17
|
+
end,
|
|
18
|
+
text
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
read(start, end) {
|
|
22
|
+
if (start < 0 || end < start || end > this.#source.length) WorkflowTransformError.invalidSourceReadRange(start, end);
|
|
23
|
+
return this.#source.slice(start, end);
|
|
24
|
+
}
|
|
25
|
+
toString() {
|
|
26
|
+
let result = this.#source;
|
|
27
|
+
for (const replacement of this.#sortedReplacements()) result = `${result.slice(0, replacement.start)}${replacement.text}${result.slice(replacement.end)}`;
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
#sortedReplacements() {
|
|
31
|
+
const replacements = [...this.#replacements].sort((left, right) => {
|
|
32
|
+
if (left.start !== right.start) return right.start - left.start;
|
|
33
|
+
return right.end - left.end;
|
|
34
|
+
});
|
|
35
|
+
for (let index = 1; index < replacements.length; index++) {
|
|
36
|
+
const previous = replacements[index - 1];
|
|
37
|
+
const current = replacements[index];
|
|
38
|
+
if (current.end > previous.start) WorkflowTransformError.overlappingSourceReplacementRanges(current.start, current.end, previous.start, previous.end);
|
|
39
|
+
}
|
|
40
|
+
return replacements;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
//#endregion
|
|
44
|
+
export { SourceEditor };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/vite/source-map.d.ts
|
|
2
|
+
interface GeneratedSourceMapOptions {
|
|
3
|
+
readonly id: string;
|
|
4
|
+
readonly originalCode: string;
|
|
5
|
+
readonly generatedCode: string;
|
|
6
|
+
readonly generatedSource: string;
|
|
7
|
+
readonly sourceText: string;
|
|
8
|
+
}
|
|
9
|
+
declare function createGeneratedSourceMap(options: GeneratedSourceMapOptions): unknown;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { GeneratedSourceMapOptions, createGeneratedSourceMap };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { stripQuery } from "./source.mjs";
|
|
2
|
+
//#region src/vite/source-map.ts
|
|
3
|
+
function createGeneratedSourceMap(options) {
|
|
4
|
+
return {
|
|
5
|
+
version: 3,
|
|
6
|
+
file: stripQuery(options.id),
|
|
7
|
+
sources: [stripQuery(options.id)],
|
|
8
|
+
sourcesContent: [options.originalCode],
|
|
9
|
+
names: [],
|
|
10
|
+
mappings: createWorkflowTransformMappings(options)
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function createWorkflowTransformMappings(options) {
|
|
14
|
+
const generatedLines = options.generatedCode.split("\n");
|
|
15
|
+
const sourceStart = options.sourceText === "" ? -1 : options.generatedSource.indexOf(options.sourceText);
|
|
16
|
+
const generatedStart = options.sourceText === "" ? -1 : options.generatedCode.indexOf(options.sourceText);
|
|
17
|
+
if (sourceStart < 0 || generatedStart < 0) return generatedLines.map(() => "").join(";");
|
|
18
|
+
const sourceStartLine = lineIndexAt(options.generatedSource, sourceStart);
|
|
19
|
+
const generatedStartLine = lineIndexAt(options.generatedCode, generatedStart);
|
|
20
|
+
const sourceLineCount = options.sourceText.split("\n").length;
|
|
21
|
+
let previousSourceLine = 0;
|
|
22
|
+
return generatedLines.map((_line, generatedLine) => {
|
|
23
|
+
if (generatedLine < generatedStartLine || generatedLine >= generatedStartLine + sourceLineCount) return "";
|
|
24
|
+
const sourceLine = sourceStartLine + generatedLine - generatedStartLine;
|
|
25
|
+
const segment = [
|
|
26
|
+
encodeSourceMapVlq(0),
|
|
27
|
+
encodeSourceMapVlq(0),
|
|
28
|
+
encodeSourceMapVlq(sourceLine - previousSourceLine),
|
|
29
|
+
encodeSourceMapVlq(0)
|
|
30
|
+
].join("");
|
|
31
|
+
previousSourceLine = sourceLine;
|
|
32
|
+
return segment;
|
|
33
|
+
}).join(";");
|
|
34
|
+
}
|
|
35
|
+
function lineIndexAt(text, offset) {
|
|
36
|
+
let line = 0;
|
|
37
|
+
for (let index = 0; index < offset; index++) if (text[index] === "\n") line++;
|
|
38
|
+
return line;
|
|
39
|
+
}
|
|
40
|
+
const SOURCE_MAP_BASE64_DIGITS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
41
|
+
function encodeSourceMapVlq(value) {
|
|
42
|
+
let vlq = value < 0 ? (-value << 1) + 1 : value << 1;
|
|
43
|
+
let result = "";
|
|
44
|
+
do {
|
|
45
|
+
let digit = vlq & 31;
|
|
46
|
+
vlq >>>= 5;
|
|
47
|
+
if (vlq > 0) digit |= 32;
|
|
48
|
+
result += SOURCE_MAP_BASE64_DIGITS[digit];
|
|
49
|
+
} while (vlq > 0);
|
|
50
|
+
return result;
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
53
|
+
export { createGeneratedSourceMap };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
//#region src/vite/source.d.ts
|
|
2
|
+
/** Removes a URL or Vite query suffix from an ID. */
|
|
3
|
+
declare function stripQuery(id: string): string;
|
|
4
|
+
type WorkflowSourceKind = "js" | "json" | "ts" | "tsx";
|
|
5
|
+
declare function workflowSourceKindForId(id: string): WorkflowSourceKind;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { WorkflowSourceKind, stripQuery, workflowSourceKindForId };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/vite/source.ts
|
|
2
|
+
/** Removes a URL or Vite query suffix from an ID. */
|
|
3
|
+
function stripQuery(id) {
|
|
4
|
+
return id.split("?", 1)[0];
|
|
5
|
+
}
|
|
6
|
+
function workflowSourceKindForId(id) {
|
|
7
|
+
const cleanId = stripQuery(id);
|
|
8
|
+
if (cleanId.endsWith(".tsx") || cleanId.endsWith(".jsx")) return "tsx";
|
|
9
|
+
if (cleanId.endsWith(".js") || cleanId.endsWith(".mjs") || cleanId.endsWith(".cjs")) return "js";
|
|
10
|
+
if (cleanId.endsWith(".json")) return "json";
|
|
11
|
+
return "ts";
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { stripQuery, workflowSourceKindForId };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DirectiveKind, TransformManifest, TransformManifestFunction, TransformManifestImportEdge, TransformMetadata, TransformMetadataEntry, TransformOptions, TransformResult } from "../types/vite.mjs";
|
|
2
|
+
import { WorkflowTransformError } from "./error.mjs";
|
|
3
|
+
//#region src/vite/transform.d.ts
|
|
4
|
+
/** Transforms one TypeScript module containing workflow or step directives. */
|
|
5
|
+
declare function transformWorkflowSource(code: string, id: string, options?: TransformOptions): TransformResult | undefined;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { type DirectiveKind, type TransformManifest, type TransformManifestFunction, type TransformManifestImportEdge, type TransformMetadata, type TransformMetadataEntry, type TransformOptions, type TransformResult, WorkflowTransformError, transformWorkflowSource };
|