@workflow/next 5.0.0-beta.2 → 5.0.0-beta.20

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,19 +0,0 @@
1
- export declare const DEFERRED_STEP_COPY_DIR_NAME = "__workflow_step_files__";
2
- export declare const DEFERRED_STEP_SOURCE_METADATA_PREFIX = "WORKFLOW_STEP_SOURCE_B64:";
3
- export interface DeferredStepSourceMetadata {
4
- relativeFilename: string;
5
- absolutePath: string;
6
- }
7
- export declare function isDeferredStepCopyFilePath(filePath: string): boolean;
8
- export declare function createDeferredStepSourceMetadataComment(metadata: DeferredStepSourceMetadata): string;
9
- export declare function createDeferredStepCopyInlineSourceMapComment({ sourcePath, sourceContent, generatedContent, }: {
10
- sourcePath: string;
11
- sourceContent: string;
12
- generatedContent?: string;
13
- }): string;
14
- export declare function parseInlineSourceMapComment(source: string): {
15
- sourceWithoutMapComment: string;
16
- sourceMap: string | null;
17
- };
18
- export declare function parseDeferredStepSourceMetadata(source: string): DeferredStepSourceMetadata | null;
19
- //# sourceMappingURL=step-copy-utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"step-copy-utils.d.ts","sourceRoot":"","sources":["../src/step-copy-utils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,2BAA2B,4BAA4B,CAAC;AACrE,eAAO,MAAM,oCAAoC,8BAA8B,CAAC;AAIhF,MAAM,WAAW,0BAA0B;IACzC,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;CACtB;AAUD,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAKpE;AAED,wBAAgB,uCAAuC,CACrD,QAAQ,EAAE,0BAA0B,GACnC,MAAM,CAKR;AAiBD,wBAAgB,4CAA4C,CAAC,EAC3D,UAAU,EACV,aAAa,EACb,gBAAgB,GACjB,EAAE;IACD,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,GAAG,MAAM,CAiBT;AAED,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,MAAM,GAAG;IAC3D,uBAAuB,EAAE,MAAM,CAAC;IAChC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B,CAuBA;AAED,wBAAgB,+BAA+B,CAC7C,MAAM,EAAE,MAAM,GACb,0BAA0B,GAAG,IAAI,CA8BnC"}
@@ -1,101 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFERRED_STEP_SOURCE_METADATA_PREFIX = exports.DEFERRED_STEP_COPY_DIR_NAME = void 0;
4
- exports.isDeferredStepCopyFilePath = isDeferredStepCopyFilePath;
5
- exports.createDeferredStepSourceMetadataComment = createDeferredStepSourceMetadataComment;
6
- exports.createDeferredStepCopyInlineSourceMapComment = createDeferredStepCopyInlineSourceMapComment;
7
- exports.parseInlineSourceMapComment = parseInlineSourceMapComment;
8
- exports.parseDeferredStepSourceMetadata = parseDeferredStepSourceMetadata;
9
- exports.DEFERRED_STEP_COPY_DIR_NAME = '__workflow_step_files__';
10
- exports.DEFERRED_STEP_SOURCE_METADATA_PREFIX = 'WORKFLOW_STEP_SOURCE_B64:';
11
- const INLINE_SOURCE_MAP_PATTERN = /(?:^|\r?\n)\s*\/\/[#@]\s*sourceMappingURL=data:application\/json(?:;charset=[^;,]+)?;base64,([A-Za-z0-9+/=]+)\s*$/;
12
- function escapeRegExp(input) {
13
- return input.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
14
- }
15
- function normalizePath(filePath) {
16
- return filePath.replace(/\\/g, '/');
17
- }
18
- function isDeferredStepCopyFilePath(filePath) {
19
- const normalizedPath = normalizePath(filePath);
20
- return normalizedPath.includes(`/.well-known/workflow/v1/step/${exports.DEFERRED_STEP_COPY_DIR_NAME}/`);
21
- }
22
- function createDeferredStepSourceMetadataComment(metadata) {
23
- const encoded = Buffer.from(JSON.stringify(metadata), 'utf-8').toString('base64');
24
- return `// ${exports.DEFERRED_STEP_SOURCE_METADATA_PREFIX}${encoded}`;
25
- }
26
- function getLineCount(source) {
27
- if (source.length === 0) {
28
- return 1;
29
- }
30
- const lineBreakMatches = source.match(/\r\n|\r|\n/g);
31
- return (lineBreakMatches?.length ?? 0) + 1;
32
- }
33
- function createIdentityLineMappings(lineCount) {
34
- if (lineCount <= 1) {
35
- return 'AAAA';
36
- }
37
- return `AAAA${';AACA'.repeat(lineCount - 1)}`;
38
- }
39
- function createDeferredStepCopyInlineSourceMapComment({ sourcePath, sourceContent, generatedContent, }) {
40
- const normalizedSourcePath = normalizePath(sourcePath);
41
- const sourceMap = {
42
- version: 3,
43
- file: normalizedSourcePath.split('/').pop() ?? normalizedSourcePath,
44
- sources: [normalizedSourcePath],
45
- sourcesContent: [sourceContent],
46
- names: [],
47
- mappings: createIdentityLineMappings(getLineCount(generatedContent ?? sourceContent)),
48
- };
49
- const encodedSourceMap = Buffer.from(JSON.stringify(sourceMap), 'utf-8').toString('base64');
50
- return `//# sourceMappingURL=data:application/json;base64,${encodedSourceMap}`;
51
- }
52
- function parseInlineSourceMapComment(source) {
53
- const mapMatch = source.match(INLINE_SOURCE_MAP_PATTERN);
54
- if (!mapMatch?.[1]) {
55
- return {
56
- sourceWithoutMapComment: source,
57
- sourceMap: null,
58
- };
59
- }
60
- const sourceWithoutMapComment = source.replace(INLINE_SOURCE_MAP_PATTERN, '');
61
- try {
62
- const decodedMap = Buffer.from(mapMatch[1], 'base64').toString('utf-8');
63
- JSON.parse(decodedMap);
64
- return {
65
- sourceWithoutMapComment,
66
- sourceMap: decodedMap,
67
- };
68
- }
69
- catch {
70
- return {
71
- sourceWithoutMapComment,
72
- sourceMap: null,
73
- };
74
- }
75
- }
76
- function parseDeferredStepSourceMetadata(source) {
77
- const pattern = new RegExp(`^\\s*//\\s*${escapeRegExp(exports.DEFERRED_STEP_SOURCE_METADATA_PREFIX)}([A-Za-z0-9+/=]+)\\s*$`, 'm');
78
- const match = source.match(pattern);
79
- const encoded = match?.[1];
80
- if (!encoded) {
81
- return null;
82
- }
83
- try {
84
- const decoded = Buffer.from(encoded, 'base64').toString('utf-8');
85
- const parsed = JSON.parse(decoded);
86
- if (typeof parsed.relativeFilename !== 'string' ||
87
- parsed.relativeFilename.length === 0 ||
88
- typeof parsed.absolutePath !== 'string' ||
89
- parsed.absolutePath.length === 0) {
90
- return null;
91
- }
92
- return {
93
- relativeFilename: parsed.relativeFilename,
94
- absolutePath: normalizePath(parsed.absolutePath),
95
- };
96
- }
97
- catch {
98
- return null;
99
- }
100
- }
101
- //# sourceMappingURL=step-copy-utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"step-copy-utils.js","sourceRoot":"","sources":["../src/step-copy-utils.ts"],"names":[],"mappings":";;;AAkBA,gEAKC;AAED,0FAOC;AAiBD,oGAyBC;AAED,kEA0BC;AAED,0EAgCC;AAxIY,QAAA,2BAA2B,GAAG,yBAAyB,CAAC;AACxD,QAAA,oCAAoC,GAAG,2BAA2B,CAAC;AAChF,MAAM,yBAAyB,GAC7B,mHAAmH,CAAC;AAOtH,SAAS,YAAY,CAAC,KAAa;IACjC,OAAO,KAAK,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;AACtD,CAAC;AAED,SAAS,aAAa,CAAC,QAAgB;IACrC,OAAO,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AACtC,CAAC;AAED,SAAgB,0BAA0B,CAAC,QAAgB;IACzD,MAAM,cAAc,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC;IAC/C,OAAO,cAAc,CAAC,QAAQ,CAC5B,iCAAiC,mCAA2B,GAAG,CAChE,CAAC;AACJ,CAAC;AAED,SAAgB,uCAAuC,CACrD,QAAoC;IAEpC,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,O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AC1E,IACE,OAAO,MAAM,CAAC,gBAAgB,KAAK,QAAQ;YAC3C,MAAM,CAAC,gBAAgB,CAAC,MAAM,KAAK,CAAC;YACpC,OAAO,MAAM,CAAC,YAAY,KAAK,QAAQ;YACvC,MAAM,CAAC,YAAY,CAAC,MAAM,KAAK,CAAC,EAChC,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO;YACL,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;YACzC,YAAY,EAAE,aAAa,CAAC,MAAM,CAAC,YAAY,CAAC;SACjD,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC","sourcesContent":["export const DEFERRED_STEP_COPY_DIR_NAME = '__workflow_step_files__';\nexport const DEFERRED_STEP_SOURCE_METADATA_PREFIX = 'WORKFLOW_STEP_SOURCE_B64:';\nconst INLINE_SOURCE_MAP_PATTERN =\n /(?:^|\\r?\\n)\\s*\\/\\/[#@]\\s*sourceMappingURL=data:application\\/json(?:;charset=[^;,]+)?;base64,([A-Za-z0-9+/=]+)\\s*$/;\n\nexport interface DeferredStepSourceMetadata {\n relativeFilename: string;\n absolutePath: string;\n}\n\nfunction escapeRegExp(input: string): string {\n return input.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n\nfunction normalizePath(filePath: string): string {\n return filePath.replace(/\\\\/g, '/');\n}\n\nexport function isDeferredStepCopyFilePath(filePath: string): boolean {\n const normalizedPath = normalizePath(filePath);\n return normalizedPath.includes(\n `/.well-known/workflow/v1/step/${DEFERRED_STEP_COPY_DIR_NAME}/`\n );\n}\n\nexport function createDeferredStepSourceMetadataComment(\n metadata: DeferredStepSourceMetadata\n): string {\n const encoded = Buffer.from(JSON.stringify(metadata), 'utf-8').toString(\n 'base64'\n );\n return `// ${DEFERRED_STEP_SOURCE_METADATA_PREFIX}${encoded}`;\n}\n\nfunction getLineCount(source: string): number {\n if (source.length === 0) {\n return 1;\n }\n const lineBreakMatches = source.match(/\\r\\n|\\r|\\n/g);\n return (lineBreakMatches?.length ?? 0) + 1;\n}\n\nfunction createIdentityLineMappings(lineCount: number): string {\n if (lineCount <= 1) {\n return 'AAAA';\n }\n return `AAAA${';AACA'.repeat(lineCount - 1)}`;\n}\n\nexport function createDeferredStepCopyInlineSourceMapComment({\n sourcePath,\n sourceContent,\n generatedContent,\n}: {\n sourcePath: string;\n sourceContent: string;\n generatedContent?: string;\n}): string {\n const normalizedSourcePath = normalizePath(sourcePath);\n const sourceMap = {\n version: 3,\n file: normalizedSourcePath.split('/').pop() ?? normalizedSourcePath,\n sources: [normalizedSourcePath],\n sourcesContent: [sourceContent],\n names: [] as string[],\n mappings: createIdentityLineMappings(\n getLineCount(generatedContent ?? sourceContent)\n ),\n };\n const encodedSourceMap = Buffer.from(\n JSON.stringify(sourceMap),\n 'utf-8'\n ).toString('base64');\n return `//# sourceMappingURL=data:application/json;base64,${encodedSourceMap}`;\n}\n\nexport function parseInlineSourceMapComment(source: string): {\n sourceWithoutMapComment: string;\n sourceMap: string | null;\n} {\n const mapMatch = source.match(INLINE_SOURCE_MAP_PATTERN);\n if (!mapMatch?.[1]) {\n return {\n sourceWithoutMapComment: source,\n sourceMap: null,\n };\n }\n\n const sourceWithoutMapComment = source.replace(INLINE_SOURCE_MAP_PATTERN, '');\n try {\n const decodedMap = Buffer.from(mapMatch[1], 'base64').toString('utf-8');\n JSON.parse(decodedMap);\n return {\n sourceWithoutMapComment,\n sourceMap: decodedMap,\n };\n } catch {\n return {\n sourceWithoutMapComment,\n sourceMap: null,\n };\n }\n}\n\nexport function parseDeferredStepSourceMetadata(\n source: string\n): DeferredStepSourceMetadata | null {\n const pattern = new RegExp(\n `^\\\\s*//\\\\s*${escapeRegExp(DEFERRED_STEP_SOURCE_METADATA_PREFIX)}([A-Za-z0-9+/=]+)\\\\s*$`,\n 'm'\n );\n const match = source.match(pattern);\n const encoded = match?.[1];\n if (!encoded) {\n return null;\n }\n\n try {\n const decoded = Buffer.from(encoded, 'base64').toString('utf-8');\n const parsed = JSON.parse(decoded) as Partial<DeferredStepSourceMetadata>;\n if (\n typeof parsed.relativeFilename !== 'string' ||\n parsed.relativeFilename.length === 0 ||\n typeof parsed.absolutePath !== 'string' ||\n parsed.absolutePath.length === 0\n ) {\n return null;\n }\n\n return {\n relativeFilename: parsed.relativeFilename,\n absolutePath: normalizePath(parsed.absolutePath),\n };\n } catch {\n return null;\n }\n}\n"]}