@snap/valdi 1.0.6 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. package/README.md +22 -10
  2. package/bundled-skills/CONTRIBUTING_SKILLS.md +74 -0
  3. package/bundled-skills/registry.json +20 -0
  4. package/bundled-skills/skills/valdi-android/skill.md +89 -0
  5. package/bundled-skills/skills/valdi-async/skill.md +246 -0
  6. package/bundled-skills/skills/valdi-async/tests/BUILD.bazel +19 -0
  7. package/bundled-skills/skills/valdi-async/tests/README.md +25 -0
  8. package/bundled-skills/skills/valdi-async/tests/src/reference.tsx +210 -0
  9. package/bundled-skills/skills/valdi-async/tests/tsconfig.json +1 -0
  10. package/bundled-skills/skills/valdi-bazel/skill.md +122 -0
  11. package/bundled-skills/skills/valdi-compiler/skill.md +108 -0
  12. package/bundled-skills/skills/valdi-component-tests/skill.md +430 -0
  13. package/bundled-skills/skills/valdi-component-tests/tests/BUILD.bazel +24 -0
  14. package/bundled-skills/skills/valdi-component-tests/tests/README.md +35 -0
  15. package/bundled-skills/skills/valdi-component-tests/tests/src/ProfileCard.tsx +38 -0
  16. package/bundled-skills/skills/valdi-component-tests/tests/test/ProfileCardTest.spec.tsx +107 -0
  17. package/bundled-skills/skills/valdi-component-tests/tests/tsconfig.json +1 -0
  18. package/bundled-skills/skills/valdi-cpp-runtime/skill.md +103 -0
  19. package/bundled-skills/skills/valdi-custom-view/skill.md +62 -0
  20. package/bundled-skills/skills/valdi-ios/skill.md +93 -0
  21. package/bundled-skills/skills/valdi-migrate/skill.md +175 -0
  22. package/bundled-skills/skills/valdi-migrate/tests/BUILD.bazel +23 -0
  23. package/bundled-skills/skills/valdi-migrate/tests/README.md +70 -0
  24. package/bundled-skills/skills/valdi-migrate/tests/check_antipatterns.py +89 -0
  25. package/bundled-skills/skills/valdi-migrate/tests/compose_example.kt +94 -0
  26. package/bundled-skills/skills/valdi-migrate/tests/flutter_example.dart +129 -0
  27. package/bundled-skills/skills/valdi-migrate/tests/react_example.tsx +98 -0
  28. package/bundled-skills/skills/valdi-migrate/tests/src/expected_valdi.tsx +267 -0
  29. package/bundled-skills/skills/valdi-migrate/tests/tsconfig.json +3 -0
  30. package/{.metadata/.cursorrules.template → bundled-skills/skills/valdi-overview/skill.md} +23 -13
  31. package/bundled-skills/skills/valdi-perf/skill.md +197 -0
  32. package/bundled-skills/skills/valdi-perf/tests/BUILD.bazel +19 -0
  33. package/bundled-skills/skills/valdi-perf/tests/README.md +26 -0
  34. package/bundled-skills/skills/valdi-perf/tests/src/reference.tsx +202 -0
  35. package/bundled-skills/skills/valdi-perf/tests/tsconfig.json +1 -0
  36. package/bundled-skills/skills/valdi-polyglot-module/skill.md +85 -0
  37. package/bundled-skills/skills/valdi-setup/skill.md +129 -0
  38. package/bundled-skills/skills/valdi-testing/skill.md +65 -0
  39. package/bundled-skills/skills/valdi-tsx/skill.md +385 -0
  40. package/bundled-skills/skills/valdi-tsx/tests/BUILD.bazel +19 -0
  41. package/bundled-skills/skills/valdi-tsx/tests/README.md +29 -0
  42. package/bundled-skills/skills/valdi-tsx/tests/src/reference.tsx +173 -0
  43. package/bundled-skills/skills/valdi-tsx/tests/tsconfig.json +1 -0
  44. package/dist/commands/bootstrap.js +3 -9
  45. package/dist/commands/newModule.js +10 -14
  46. package/dist/commands/skills.js +16 -0
  47. package/dist/commands/skills_commands/create.js +125 -0
  48. package/dist/commands/skills_commands/install.js +96 -0
  49. package/dist/commands/skills_commands/list.js +83 -0
  50. package/dist/commands/skills_commands/remove.js +41 -0
  51. package/dist/commands/skills_commands/update.js +59 -0
  52. package/dist/core/constants.js +1 -1
  53. package/dist/index.js +5 -0
  54. package/dist/setup/versions.js +1 -1
  55. package/dist/utils/skillsAdapters.js +140 -0
  56. package/dist/utils/skillsRegistry.js +40 -0
  57. package/package.json +6 -1
  58. package/.bazelignore +0 -2
  59. package/.bootstrap/apps/cli_application/AGENTS.md.template +0 -291
  60. package/.bootstrap/apps/cli_application/BUILD.bazel.template +0 -7
  61. package/.bootstrap/apps/cli_application/modules/{{MODULE_NAME}}/BUILD.bazel.template +0 -11
  62. package/.bootstrap/apps/cli_application/modules/{{MODULE_NAME}}/src/index.ts +0 -1
  63. package/.bootstrap/apps/ui_application/.eslint.rc +0 -27
  64. package/.bootstrap/apps/ui_application/AGENTS.md.template +0 -278
  65. package/.bootstrap/apps/ui_application/BUILD.bazel.template +0 -19
  66. package/.bootstrap/apps/ui_application/modules/{{MODULE_NAME}}/BUILD.bazel.template +0 -21
  67. package/.bootstrap/apps/ui_application/modules/{{MODULE_NAME}}/res/valdi@3x.png +0 -0
  68. package/.bootstrap/apps/ui_application/modules/{{MODULE_NAME}}/src/App.tsx +0 -133
  69. package/.bootstrap/apps/ui_application/package.json +0 -24
  70. package/.bootstrap/modules/cpp_bridge_module/BUILD.bazel.template +0 -21
  71. package/.bootstrap/modules/cpp_bridge_module/cpp/CalculatorModuleFactory.cpp.template +0 -28
  72. package/.bootstrap/modules/cpp_bridge_module/src/Calculator.d.ts +0 -4
  73. package/.bootstrap/modules/ios_android_bridge_module/BUILD.bazel.template +0 -39
  74. package/.bootstrap/modules/ios_android_bridge_module/android/CalculatorModuleFactory.kt.template +0 -18
  75. package/.bootstrap/modules/ios_android_bridge_module/ios/SCCCalculatorModuleFactory.m.template +0 -31
  76. package/.bootstrap/modules/ios_android_bridge_module/src/Calculator.d.ts +0 -4
  77. package/.bootstrap/modules/ios_android_view_module/BUILD.bazel.template +0 -41
  78. package/.bootstrap/modules/ios_android_view_module/android/CircleView.kt.template +0 -42
  79. package/.bootstrap/modules/ios_android_view_module/android/CircleViewAttributesBinder.kt.template +0 -60
  80. package/.bootstrap/modules/ios_android_view_module/ios/SCCCircleView.h +0 -6
  81. package/.bootstrap/modules/ios_android_view_module/ios/SCCCircleView.m +0 -82
  82. package/.bootstrap/modules/ios_android_view_module/src/Circle.tsx.template +0 -15
  83. package/.bootstrap/modules/ui_component/BUILD.bazel.template +0 -34
  84. package/.bootstrap/modules/ui_component/src/NewModuleComponent.tsx +0 -45
  85. package/.config/copyconfig.json +0 -10
  86. package/.editorconfig +0 -21
  87. package/.eslintignore +0 -1
  88. package/.eslintrc.js +0 -72
  89. package/.github/README.md +0 -164
  90. package/.metadata/.bazelrc.template +0 -91
  91. package/.metadata/.bazelversion.template +0 -1
  92. package/.metadata/.editorconfig.template +0 -37
  93. package/.metadata/.eslintrc.js.template +0 -27
  94. package/.metadata/.gitignore.template +0 -4
  95. package/.metadata/.prettierrc.json.template +0 -7
  96. package/.metadata/.watchmanconfig.template +0 -8
  97. package/.metadata/README.md.template +0 -31
  98. package/.metadata/WORKSPACE.template +0 -57
  99. package/.metadata/config.yaml.template +0 -1
  100. package/.metadata/package.json.template +0 -23
  101. package/.prettierignore +0 -2
  102. package/.prettierrc.json +0 -7
  103. package/LINUX_COMPATIBILITY.md +0 -248
  104. package/prettier.config.js +0 -4
  105. package/scripts/sync-agents-md.sh +0 -44
  106. package/scripts/update-agents-templates.ts +0 -170
  107. package/spec/support/jasmine.json +0 -6
  108. package/src/commands/bootstrap.ts +0 -409
  109. package/src/commands/build.ts +0 -89
  110. package/src/commands/devSetup.ts +0 -17
  111. package/src/commands/doctor.ts +0 -1832
  112. package/src/commands/export.ts +0 -131
  113. package/src/commands/hotreload.ts +0 -108
  114. package/src/commands/install.ts +0 -93
  115. package/src/commands/lint.ts +0 -15
  116. package/src/commands/lint_commands/lintCheck.ts +0 -53
  117. package/src/commands/lint_commands/lintFormat.ts +0 -49
  118. package/src/commands/log.ts +0 -108
  119. package/src/commands/newModule.ts +0 -286
  120. package/src/commands/package.ts +0 -102
  121. package/src/commands/projectsync.ts +0 -488
  122. package/src/commands/test.ts +0 -68
  123. package/src/core/constants.ts +0 -97
  124. package/src/core/errors.ts +0 -10
  125. package/src/index.ts +0 -22
  126. package/src/setup/DevSetupHelper.ts +0 -290
  127. package/src/setup/linuxSetup.ts +0 -261
  128. package/src/setup/macOSSetup.ts +0 -156
  129. package/src/setup/setupEntryPoint.ts +0 -64
  130. package/src/setup/versions.ts +0 -8
  131. package/src/utils/ArgumentsResolver.ts +0 -23
  132. package/src/utils/BazelClient.ts +0 -285
  133. package/src/utils/Digraph.ts +0 -81
  134. package/src/utils/LoadingIndicator.ts +0 -43
  135. package/src/utils/applicationUtils.ts +0 -276
  136. package/src/utils/buildInfo.ts +0 -99
  137. package/src/utils/byString.ts +0 -3
  138. package/src/utils/cliUtils.ts +0 -112
  139. package/src/utils/copyBootstrapFiles.ts +0 -30
  140. package/src/utils/deviceUtils.ts +0 -76
  141. package/src/utils/errorUtils.ts +0 -63
  142. package/src/utils/fileUtils.ts +0 -257
  143. package/src/utils/githubUtils.ts +0 -102
  144. package/src/utils/jsonUtils.ts +0 -30
  145. package/src/utils/lintUtils.ts +0 -190
  146. package/src/utils/linuxDistro.spec.ts +0 -219
  147. package/src/utils/linuxDistro.ts +0 -326
  148. package/src/utils/logUtils.ts +0 -9
  149. package/src/utils/pathUtils.ts +0 -12
  150. package/src/utils/stringUtils.spec.ts +0 -95
  151. package/src/utils/stringUtils.ts +0 -103
  152. package/src/utils/tempDir.ts +0 -24
  153. package/src/utils/zipUtils.ts +0 -14
  154. package/test/ValdiSmokeTest.ts +0 -279
  155. package/test/helpers/AsyncHelpers.ts +0 -113
  156. package/test/helpers/CommandHelpers.ts +0 -37
  157. package/test/helpers/ProjectHelpers.ts +0 -153
  158. package/test/helpers/StreamHelpers.ts +0 -37
  159. package/test/helpers/TypeScriptClient.ts +0 -217
  160. package/tsconfig.dist.json +0 -8
  161. package/tsconfig.json +0 -42
@@ -1,153 +0,0 @@
1
- import { spawn } from 'child_process';
2
- import { mkdir, readFile, writeFile } from 'fs/promises';
3
- import path from 'path';
4
- import { eachLine } from './StreamHelpers';
5
- import type { FilePosition, TSServerClient } from './TypeScriptClient';
6
- import { lineAndOffset } from './TypeScriptClient';
7
-
8
- type FileUpdater = (contents: Buffer) => Promise<Buffer>;
9
-
10
- export interface ProjectConfig {
11
- rootPath: string;
12
- name: string;
13
- findFile: (fileName: string, withinModule?: string) => Promise<string>;
14
- updateFile: (fileName: string, withinModule: string | undefined, change: FileUpdater) => Promise<void>;
15
- createFile: (
16
- fileName: string,
17
- withinModule: string | undefined,
18
- source: Parameters<typeof writeFile>[1],
19
- ) => Promise<string>;
20
- }
21
-
22
- interface TaskContext {
23
- project: ProjectConfig;
24
- client: TSServerClient;
25
- }
26
-
27
- export function createProject(name: string, rootPath: string): ProjectConfig {
28
- const findFile: ProjectConfig['findFile'] = (fileName, withinModule) => {
29
- return new Promise((resolve, reject) => {
30
- const buffers: Buffer[] = [];
31
-
32
- const errorBuffers: Buffer[] = [];
33
- const directory = path.join(...['.', 'modules'].concat(withinModule ?? []));
34
-
35
- const child = spawn('find', [directory]);
36
- child.stdout.on('data', (chunk: Buffer) => {
37
- buffers.push(chunk);
38
- });
39
-
40
- child.stderr.on('data', (chunk: Buffer) => {
41
- errorBuffers.push(chunk);
42
- });
43
-
44
- child.on('close', code => {
45
- if (!!code && code > 0) {
46
- reject(new Error('exited with error code: ' + code.toString()));
47
- }
48
-
49
- const output = Buffer.concat(buffers).toString('utf8');
50
-
51
- const files = output.trim().split('\n');
52
-
53
- const found = files.find(file => file.endsWith(`/${fileName}`));
54
-
55
- if (!found) {
56
- reject(new Error('File not found: ' + fileName));
57
- return;
58
- }
59
-
60
- resolve(path.join(rootPath, found));
61
- });
62
- });
63
- };
64
- return {
65
- name,
66
- rootPath,
67
- findFile,
68
- updateFile: async (file, withinModule, updater) => {
69
- const path = await findFile(file, withinModule);
70
- const contents = await readFile(path);
71
- const updated = await updater(contents);
72
- await writeFile(path, updated);
73
- },
74
- createFile: async (filePath, withinModule, source) => {
75
- const fullPath = path.resolve(path.join(rootPath, withinModule ? `modules/${withinModule}` : '.', filePath));
76
- await mkdir(path.dirname(fullPath), { recursive: true });
77
- await writeFile(fullPath, source);
78
- return fullPath;
79
- },
80
- };
81
- }
82
-
83
- type LineMatcher = (line: string) => boolean;
84
-
85
- export function lineMatches(search: string | RegExp): LineMatcher {
86
- return line => {
87
- if (typeof search === 'string') {
88
- return line.toString().includes(search);
89
- }
90
- return search.test(line);
91
- };
92
- }
93
-
94
- export const atBeginning: LineMatcher = () => true;
95
-
96
- export function insertLine(position: 'before' | 'after', search: LineMatcher, content: string | Buffer): FileUpdater {
97
- const match = (content: Buffer | string): boolean => search(content.toString());
98
- return contents => {
99
- let found = false;
100
- let buffer = Buffer.from([]);
101
- for (const line of eachLine(contents)) {
102
- const bufferLine = typeof line === 'string' ? Buffer.from(line) : line;
103
- if (position === 'after') {
104
- buffer = Buffer.concat([buffer, bufferLine]);
105
- }
106
- if (!found && match(line)) {
107
- found = true;
108
- buffer = Buffer.concat([buffer, typeof content === 'string' ? Buffer.from(content) : content]);
109
- }
110
- if (position === 'before') {
111
- buffer = Buffer.concat([buffer, bufferLine]);
112
- }
113
- }
114
- return Promise.resolve(buffer);
115
- };
116
- }
117
-
118
- export function insertLineBefore(search: LineMatcher, content: string | Buffer): FileUpdater {
119
- return insertLine('before', search, content);
120
- }
121
-
122
- export function insertLineAfter(search: LineMatcher, content: string | Buffer): FileUpdater {
123
- return insertLine('after', search, content);
124
- }
125
-
126
- export async function findDefinitionForTokenInFile(
127
- context: TaskContext,
128
- token: string,
129
- file: string,
130
- valdiModuleName?: string,
131
- ): Promise<[pathDescriptor: string, position: FilePosition, location: { file: string }, token: string]> {
132
- const appSource = await context.project.findFile(file, valdiModuleName);
133
- const position = await lineAndOffset(token, appSource);
134
- const definition = await context.client.command('definition', {
135
- file: appSource,
136
- line: position.line,
137
- offset: position.offset + 1,
138
- });
139
-
140
- if ('success' in definition && !definition['success']) {
141
- console.error(definition['message']);
142
- throw new Error('failed to get typeDefinition');
143
- }
144
-
145
- const body = definition['body'] as { file: string; start: { line: number; offset: number } }[];
146
- const location = body.at(0);
147
-
148
- if (!location) {
149
- throw new Error('No library definitions found for: ' + token + ' at ' + JSON.stringify(position));
150
- }
151
-
152
- return [`${location.file}:${location.start.line}:${location.start.offset}`, position, location, token];
153
- }
@@ -1,37 +0,0 @@
1
- export function* eachLine(chunkOrString: Buffer | string): Generator<Buffer | string> {
2
- let position = 0;
3
- const chunk = typeof chunkOrString === 'string' ? Buffer.from(chunkOrString) : chunkOrString;
4
- while (position < chunk.length) {
5
- const newline = chunk.indexOf('\n', position);
6
- if (newline === -1) {
7
- yield chunk.subarray(position).toString('utf8') + '\n';
8
- break;
9
- }
10
- yield chunk.subarray(position, newline).toString('utf8') + `\n`;
11
- position = newline + 1;
12
- }
13
- }
14
-
15
- export async function* pipeEachLine(source: AsyncGenerator<Buffer | string>): AsyncGenerator<Buffer | string> {
16
- for await (const chunk of source) {
17
- for (const line of eachLine(chunk)) {
18
- yield line;
19
- }
20
- }
21
- }
22
-
23
- /**
24
- * Reads the input of source and calls `fn` for each line as a side-effect.
25
- *
26
- * The input/output is not changed and cannot be mutated by the callback.
27
- */
28
- export function onEachLine(
29
- fn: (line: Buffer) => void,
30
- ): (source: AsyncGenerator<Buffer | string>) => AsyncGenerator<string | Buffer> {
31
- return async function* (source) {
32
- for await (const line of pipeEachLine(source)) {
33
- fn(typeof line === 'string' ? Buffer.from(line) : line);
34
- yield line;
35
- }
36
- };
37
- }
@@ -1,217 +0,0 @@
1
- import { EventEmitter } from 'node:events';
2
- import { readFile } from 'node:fs/promises';
3
- import { run } from './CommandHelpers';
4
-
5
- const HEADER_END = '\r\n\r\n';
6
-
7
- export interface TSServerClient {
8
- command: (command: string, args?: Record<string, unknown>) => Promise<Record<string, unknown>>;
9
- disconnect: () => Promise<number>;
10
- }
11
-
12
- export function createClient(workingDir: string): TSServerClient {
13
- const reserveSequence = createNonceService();
14
- const read = createMessageBuffer();
15
-
16
- // eslint-disable-next-line unicorn/prefer-event-target
17
- const queue = new EventEmitter<{
18
- response: [Record<string, unknown>];
19
- message: [Record<string, unknown>];
20
- }>();
21
-
22
- const service = run('npx', ['tsserver'], {cwd: workingDir});
23
-
24
- service.process.stdout?.on('data', (chunk: Buffer) => {
25
- for (const [message] of read(chunk)) {
26
- if ('type' in message && message['type'] === 'response') {
27
- queue.emit('response', message);
28
- }
29
- queue.emit('message', message);
30
- }
31
- });
32
-
33
- service.process.stderr?.pipe(process.stderr)
34
-
35
- const send = (
36
- request: Record<string, unknown>,
37
- { timeout = 300000 }: { timeout?: number } = {},
38
- ): Promise<Record<string, unknown>> => {
39
- const seq = reserveSequence();
40
- const body = JSON.stringify({
41
- seq,
42
- ...request,
43
- });
44
- const payload = body + '\r\n';
45
- service.process.stdin.write(payload);
46
-
47
- return withTimeout(
48
- new Promise(resolve => {
49
- const listener = (message: Record<string, unknown>) => {
50
- if ('request_seq' in message && message['request_seq'] !== seq) {
51
- return;
52
- }
53
- queue.removeListener('response', listener);
54
- resolve(message);
55
- };
56
- queue.addListener('response', listener);
57
- }),
58
- timeout,
59
- );
60
- };
61
-
62
- return {
63
- command: (command: string, args?: Record<string, unknown>) =>
64
- send({
65
- command,
66
- ...(args ? { arguments: args } : null),
67
- }),
68
- disconnect: () => {
69
- service.process.stdin.end();
70
- service.process.kill('SIGINT');
71
- return service.wait();
72
- },
73
- };
74
- }
75
-
76
- export interface FilePosition {
77
- /**
78
- * 1 indexed line number (first line is line 1)
79
- */
80
- line: number;
81
- /**
82
- * 1 indexed column number (first column is column 1)
83
- */
84
- offset: number;
85
- /**
86
- * 0-index within the file content, the nth character
87
- */
88
- position: number;
89
- }
90
-
91
- export async function lineAndOffset(searchToken: string, file: string): Promise<FilePosition> {
92
- const buffer = await readFile(file);
93
- const position = buffer.indexOf(searchToken);
94
-
95
- if (position === -1) {
96
- throw new Error('searchToken not found in file');
97
- }
98
-
99
- let line = 1;
100
- let index = 0;
101
- let offset = -1;
102
- while (index <= position) {
103
- const nextLine = buffer.indexOf('\n', index);
104
- if (nextLine < position) {
105
- line += 1;
106
- index = nextLine + 1;
107
- continue;
108
- } else {
109
- offset = position - index;
110
- break;
111
- }
112
- }
113
- return { line, offset: Math.max(0, offset), position };
114
- }
115
-
116
- function withTimeout<T>(promise: Promise<T>, ms: number | false = 300000): Promise<T> {
117
- if (ms === false) {
118
- return promise;
119
- }
120
- let timer: NodeJS.Timeout;
121
- return Promise.race([
122
- new Promise<never>((_resolve, reject) => {
123
- timer = setTimeout(() => reject(new Error('timeout')), ms);
124
- }),
125
- promise.then(value => {
126
- clearTimeout(timer);
127
- return value;
128
- }),
129
- ]);
130
- }
131
-
132
- function* eachLine(buffer: Buffer) {
133
- let index = 0;
134
- while (index > -1 && index < buffer.length) {
135
- const endIndex = buffer.indexOf('\n', index);
136
- if (endIndex === -1) {
137
- yield buffer.subarray(index);
138
- break;
139
- }
140
- yield buffer.subarray(index, endIndex);
141
- index = endIndex;
142
- }
143
- }
144
-
145
- function* parseHeaders(chunk: Buffer): Generator<[name: string, value: string]> {
146
- for (const line of eachLine(chunk)) {
147
- const sep = line.indexOf(':');
148
- const name = line.subarray(0, sep);
149
- const value = line.subarray(sep + 1);
150
- yield [name.toString('utf8'), value.toString('utf8').trim()];
151
- }
152
- }
153
-
154
- /**
155
- * Create a statefull message buffer that parses TSServer messages.
156
- *
157
- * @returns {(chunk: Buffer) => Generator<[body: Record<string, unknown>, headers: Array<[name: string, value: string]>]>}
158
- */
159
- function createMessageBuffer(): (
160
- chunk: Buffer,
161
- ) => Generator<[body: Record<string, unknown>, headers: Array<[name: string, value: string]>]> {
162
- let buffer = Buffer.from([]);
163
- /**
164
- *
165
- * @param {Buffer} chunk
166
- * @return {Generator<[body: Record<string, unknown>, headers: Array<[name: string, value: string]>]>}
167
- */
168
- return function* read(chunk) {
169
- buffer = Buffer.concat([buffer, chunk]);
170
-
171
- let position = 0;
172
-
173
- while (position < buffer.length) {
174
- const headerSuffix = buffer.indexOf(HEADER_END, position);
175
-
176
- if (headerSuffix === -1) {
177
- throw new Error('no headers ' + buffer.toString('utf8'));
178
- }
179
-
180
- const headers: [string, string][] = Array.from(parseHeaders(buffer.subarray(position, headerSuffix)));
181
-
182
- // Content length
183
- const contentLength = Number.parseInt(
184
- headers.find(([name]) => name === 'Content-Length')?.[1] ?? Number.NaN.toString(),
185
- );
186
- if (Number.isNaN(contentLength)) {
187
- throw new TypeError('invalid message, no Content-Length');
188
- }
189
-
190
- const bodyStart = headerSuffix + HEADER_END.length;
191
- const bodyEnd = bodyStart + contentLength;
192
-
193
- if (bodyEnd > buffer.length) {
194
- buffer = buffer.subarray(position);
195
- return;
196
- }
197
-
198
- yield [JSON.parse(buffer.subarray(bodyStart, bodyEnd).toString('utf8')), headers];
199
-
200
- position = bodyEnd;
201
- }
202
- };
203
- }
204
-
205
- /**
206
- * Every time the returned function is called it will return a new sequenc.
207
- *
208
- * @returns {() => number}
209
- */
210
- function createNonceService() {
211
- let sequence = 1;
212
- return () => {
213
- const seq = sequence;
214
- sequence += 1;
215
- return seq;
216
- };
217
- }
@@ -1,8 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "rootDirs": [],
5
- "rootDir": "./src",
6
- },
7
- "include": ["./src/**/*.ts"]
8
- }
package/tsconfig.json DELETED
@@ -1,42 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- // Main settings
4
- "rootDirs": ["./src", "./test"],
5
- "outDir": "./dist",
6
-
7
- // Modules
8
- "module": "CommonJS",
9
- "moduleResolution": "node",
10
- "esModuleInterop": true,
11
- "resolveJsonModule": true,
12
-
13
- // Type Checking
14
- "exactOptionalPropertyTypes": true,
15
- "noFallthroughCasesInSwitch": true,
16
- "noImplicitOverride": true,
17
- "noImplicitReturns": true,
18
- "noPropertyAccessFromIndexSignature": true,
19
- "noUncheckedIndexedAccess": true,
20
- "noUnusedLocals": false,
21
- "noUnusedParameters": true,
22
- "strict": true,
23
-
24
- // Emit
25
- "importHelpers": true,
26
- "noEmitHelpers": true,
27
- "noEmitOnError": true,
28
- "removeComments": true,
29
-
30
- // Interop Constraints
31
- "allowSyntheticDefaultImports": true,
32
- "forceConsistentCasingInFileNames": true,
33
- "isolatedModules": true,
34
-
35
- // Language and Environment
36
- "experimentalDecorators": true,
37
- "lib": ["ESNext"],
38
- "target": "ESNext",
39
- "useDefineForClassFields": true
40
- },
41
- "include": ["./src/**/*.ts", "./test/**/*.ts"]
42
- }