@valbuild/server 0.146.2 → 0.147.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.
Files changed (37) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/browser/dist/valbuild-server-browser.cjs.d.ts +2 -0
  3. package/browser/dist/valbuild-server-browser.cjs.dev.js +146 -0
  4. package/browser/dist/valbuild-server-browser.cjs.js +7 -0
  5. package/browser/dist/valbuild-server-browser.cjs.prod.js +146 -0
  6. package/browser/dist/valbuild-server-browser.esm.js +142 -0
  7. package/browser/package.json +4 -0
  8. package/dist/ValRouterCore-3fd3d444.cjs.dev.js +9897 -0
  9. package/dist/ValRouterCore-7ffcc08c.cjs.prod.js +9897 -0
  10. package/dist/ValRouterCore-f5004f8f.esm.js +9866 -0
  11. package/dist/declarations/src/ValOps.d.ts +13 -1
  12. package/dist/declarations/src/ValOpsFS.d.ts +1 -0
  13. package/dist/declarations/src/ValOpsHttp.d.ts +11 -0
  14. package/dist/declarations/src/ValOpsMemory.d.ts +9 -0
  15. package/dist/declarations/src/ValRouter.d.ts +1 -1
  16. package/dist/declarations/src/ValServer.d.ts +9 -2
  17. package/dist/declarations/src/browser/inTabFetch.d.ts +27 -0
  18. package/dist/declarations/src/browser/index.d.ts +9 -0
  19. package/dist/declarations/src/fixHandlers.d.ts +1 -1
  20. package/dist/declarations/src/linkCheck/probeUrl.d.ts +40 -0
  21. package/dist/declarations/src/platform.d.ts +39 -0
  22. package/dist/getJsonEntryAtCommit-1e08d724.esm.js +136 -0
  23. package/dist/getJsonEntryAtCommit-df65d861.cjs.prod.js +143 -0
  24. package/dist/getJsonEntryAtCommit-e96beb9e.cjs.dev.js +143 -0
  25. package/dist/jsonValuesModule-427d68c8.esm.js +273 -0
  26. package/dist/jsonValuesModule-8ae503a8.cjs.dev.js +288 -0
  27. package/dist/jsonValuesModule-d1bb8d8f.cjs.prod.js +288 -0
  28. package/dist/ops-0d05feaf.esm.js +353 -0
  29. package/dist/ops-b15239ac.cjs.prod.js +361 -0
  30. package/dist/ops-f37d18c6.cjs.dev.js +361 -0
  31. package/dist/publishKit-580f558a.cjs.prod.js +41 -0
  32. package/dist/publishKit-5865095c.cjs.dev.js +41 -0
  33. package/dist/publishKit-bc8df53d.esm.js +31 -0
  34. package/dist/valbuild-server.cjs.dev.js +7795 -18093
  35. package/dist/valbuild-server.cjs.prod.js +7795 -18093
  36. package/dist/valbuild-server.esm.js +7988 -18285
  37. package/package.json +18 -5
@@ -0,0 +1,361 @@
1
+ 'use strict';
2
+
3
+ var ts = require('typescript');
4
+ var fp = require('@valbuild/core/fp');
5
+ var jsonValuesModule = require('./jsonValuesModule-8ae503a8.cjs.dev.js');
6
+ var patch = require('@valbuild/core/patch');
7
+
8
+ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
9
+
10
+ var ts__default = /*#__PURE__*/_interopDefault(ts);
11
+
12
+ function isValidIdentifier(text) {
13
+ if (text.length === 0) {
14
+ return false;
15
+ }
16
+ if (!ts__default["default"].isIdentifierStart(text.charCodeAt(0), ts__default["default"].ScriptTarget.ES2020)) {
17
+ return false;
18
+ }
19
+ for (let i = 1; i < text.length; ++i) {
20
+ if (!ts__default["default"].isIdentifierPart(text.charCodeAt(i), ts__default["default"].ScriptTarget.ES2020)) {
21
+ return false;
22
+ }
23
+ }
24
+ return true;
25
+ }
26
+ function createPropertyAssignment(key, value) {
27
+ return ts__default["default"].factory.createPropertyAssignment(isValidIdentifier(key) ? ts__default["default"].factory.createIdentifier(key) : ts__default["default"].factory.createStringLiteral(key), toExpression(value));
28
+ }
29
+
30
+ /**
31
+ * Builds the expression `c.json(() => import("<importPath>"))` used to reference
32
+ * a lazily-loaded `*.val.json` entry of a `.jsonValues()` record.
33
+ */
34
+ function createValJsonReference(importPath) {
35
+ // () => import("<importPath>")
36
+ // NOTE: an `import` identifier prints as the dynamic-import keyword call,
37
+ // which avoids casting the ImportKeyword token (not typed as an Expression).
38
+ const importCall = ts__default["default"].factory.createCallExpression(ts__default["default"].factory.createIdentifier("import"), undefined, [ts__default["default"].factory.createStringLiteral(importPath)]);
39
+ const thunk = ts__default["default"].factory.createArrowFunction(undefined, undefined, [], undefined, ts__default["default"].factory.createToken(ts__default["default"].SyntaxKind.EqualsGreaterThanToken), importCall);
40
+ // c.json(<thunk>)
41
+ return ts__default["default"].factory.createCallExpression(ts__default["default"].factory.createPropertyAccessExpression(ts__default["default"].factory.createIdentifier("c"), ts__default["default"].factory.createIdentifier("json")), undefined, [thunk]);
42
+ }
43
+
44
+ /**
45
+ * Inserts a new `.jsonValues()` entry `"<key>": c.json(() => import("<importPath>"))`
46
+ * into the record's object literal in a `.val.ts` module. `recordPath` is the
47
+ * path from the module source to the record (empty for a root record/router).
48
+ * Fails if the entry key already exists.
49
+ */
50
+ function insertValJsonEntry(document, recordPath, key, importPath) {
51
+ return fp.pipe(jsonValuesModule.analyzeValModule(document), fp.result.flatMap(({
52
+ source
53
+ }) => getAtPath(source, recordPath)), fp.result.flatMap(recordNode => {
54
+ if (!ts__default["default"].isObjectLiteralExpression(recordNode)) {
55
+ return fp.result.err(new patch.PatchError("Cannot add jsonValues entry: record source is not an object literal"));
56
+ }
57
+ return fp.pipe(jsonValuesModule.findObjectPropertyAssignment(recordNode, key), fp.result.flatMap(assignment => {
58
+ if (assignment) {
59
+ return fp.result.err(new patch.PatchError(`Cannot add jsonValues entry '${key}': it already exists`));
60
+ }
61
+ const property = ts__default["default"].factory.createPropertyAssignment(isValidIdentifier(key) ? ts__default["default"].factory.createIdentifier(key) : ts__default["default"].factory.createStringLiteral(key), createValJsonReference(importPath));
62
+ return fp.result.ok(insertAt(document, recordNode.properties, recordNode.properties.length, property));
63
+ }));
64
+ }));
65
+ }
66
+
67
+ /**
68
+ * Removes the `.jsonValues()` entry `"<key>"` from the record's object literal
69
+ * in a `.val.ts` module. `recordPath` is the path from the module source to the
70
+ * record (empty for a root record/router). Fails if the entry key is missing.
71
+ */
72
+ function removeValJsonEntry(document, recordPath, key) {
73
+ return fp.pipe(jsonValuesModule.analyzeValModule(document), fp.result.flatMap(({
74
+ source
75
+ }) => getAtPath(source, recordPath)), fp.result.flatMap(recordNode => {
76
+ if (!ts__default["default"].isObjectLiteralExpression(recordNode)) {
77
+ return fp.result.err(new patch.PatchError("Cannot remove jsonValues entry: record source is not an object literal"));
78
+ }
79
+ return fp.pipe(jsonValuesModule.findObjectPropertyAssignment(recordNode, key), fp.result.flatMap(assignment => {
80
+ if (!assignment) {
81
+ return fp.result.err(new patch.PatchError(`Cannot remove jsonValues entry '${key}': it does not exist`));
82
+ }
83
+ const [doc] = removeAt(document, recordNode.properties, recordNode.properties.indexOf(assignment));
84
+ return fp.result.ok(doc);
85
+ }));
86
+ }));
87
+ }
88
+ function toExpression(value) {
89
+ if (typeof value === "string") {
90
+ // TODO: Use configuration/heuristics to determine use of single quote or double quote
91
+ return ts__default["default"].factory.createStringLiteral(value);
92
+ } else if (typeof value === "number") {
93
+ // TODO: do we want to do something like this for very large numbers?
94
+ // if (value > Number.MAX_SAFE_INTEGER) {
95
+ // return ts.factory.createBigIntLiteral(`${value}n`);
96
+ // }
97
+ // if (value < Number.MIN_SAFE_INTEGER) {
98
+ // return ts.factory.createPrefixUnaryExpression(
99
+ // ts.SyntaxKind.MinusToken,
100
+ // ts.factory.createBigIntLiteral(`${value}n`),
101
+ // );
102
+ // }
103
+ if (value < 0) {
104
+ return ts__default["default"].factory.createPrefixUnaryExpression(ts__default["default"].SyntaxKind.MinusToken, ts__default["default"].factory.createNumericLiteral(Math.abs(value)));
105
+ }
106
+ return ts__default["default"].factory.createNumericLiteral(value);
107
+ } else if (typeof value === "boolean") {
108
+ return value ? ts__default["default"].factory.createTrue() : ts__default["default"].factory.createFalse();
109
+ } else if (value === null) {
110
+ return ts__default["default"].factory.createNull();
111
+ } else if (Array.isArray(value)) {
112
+ return ts__default["default"].factory.createArrayLiteralExpression(value.map(toExpression));
113
+ } else if (typeof value === "object") {
114
+ return ts__default["default"].factory.createObjectLiteralExpression(Object.entries(value)
115
+ // `patch_id` is injected server-side onto a media source whose bytes are
116
+ // not committed yet. It describes the draft, not the content, and a
117
+ // whole-object write built from the client's optimistic view would
118
+ // otherwise print it into the user's file.
119
+ .filter(([key]) => key !== "patch_id").map(([key, value]) => createPropertyAssignment(key, value)));
120
+ } else {
121
+ return ts__default["default"].factory.createStringLiteral(value);
122
+ }
123
+ }
124
+
125
+ // TODO: Choose newline based on project settings/heuristics/system default?
126
+ const newLine = ts__default["default"].NewLineKind.LineFeed;
127
+ // TODO: Handle indentation of printed code
128
+ const printer = ts__default["default"].createPrinter({
129
+ newLine: newLine
130
+ // neverAsciiEscape: true,
131
+ });
132
+ function replaceNodeValue(document, node, value) {
133
+ const replacementText = printer.printNode(ts__default["default"].EmitHint.Unspecified, toExpression(value), document);
134
+ const span = ts__default["default"].createTextSpanFromBounds(node.getStart(document, false), node.end);
135
+ const newText = `${document.text.substring(0, span.start)}${replacementText}${document.text.substring(ts__default["default"].textSpanEnd(span))}`;
136
+ return [document.update(newText, ts__default["default"].createTextChangeRange(span, replacementText.length)), node];
137
+ }
138
+ function isIndentation(s) {
139
+ for (let i = 0; i < s.length; ++i) {
140
+ const c = s.charAt(i);
141
+ if (c !== " " && c !== "\t") {
142
+ return false;
143
+ }
144
+ }
145
+ return true;
146
+ }
147
+ function newLineStr(kind) {
148
+ if (kind === ts__default["default"].NewLineKind.CarriageReturnLineFeed) {
149
+ return "\r\n";
150
+ } else {
151
+ return "\n";
152
+ }
153
+ }
154
+ function getSeparator(document, neighbor) {
155
+ const startPos = neighbor.getStart(document, true);
156
+ const basis = document.getLineAndCharacterOfPosition(startPos);
157
+ const lineStartPos = document.getPositionOfLineAndCharacter(basis.line, 0);
158
+ const maybeIndentation = document.getText().substring(lineStartPos, startPos);
159
+ if (isIndentation(maybeIndentation)) {
160
+ return `,${newLineStr(newLine)}${maybeIndentation}`;
161
+ } else {
162
+ return `, `;
163
+ }
164
+ }
165
+ function insertAt(document, nodes, index, node) {
166
+ let span;
167
+ let replacementText;
168
+ if (nodes.length === 0) {
169
+ // Replace entire range of nodes
170
+ replacementText = printer.printNode(ts__default["default"].EmitHint.Unspecified, node, document);
171
+ span = ts__default["default"].createTextSpanFromBounds(nodes.pos, nodes.end);
172
+ } else if (index === nodes.length) {
173
+ // Insert after last node
174
+ const neighbor = nodes[nodes.length - 1];
175
+ replacementText = `${getSeparator(document, neighbor)}${printer.printNode(ts__default["default"].EmitHint.Unspecified, node, document)}`;
176
+ span = ts__default["default"].createTextSpan(neighbor.end, 0);
177
+ } else {
178
+ // Insert before node
179
+ const neighbor = nodes[index];
180
+ replacementText = `${printer.printNode(ts__default["default"].EmitHint.Unspecified, node, document)}${getSeparator(document, neighbor)}`;
181
+ span = ts__default["default"].createTextSpan(neighbor.getStart(document, true), 0);
182
+ }
183
+ const newText = `${document.text.substring(0, span.start)}${replacementText}${document.text.substring(ts__default["default"].textSpanEnd(span))}`;
184
+ return document.update(newText, ts__default["default"].createTextChangeRange(span, replacementText.length));
185
+ }
186
+ function removeAt(document, nodes, index) {
187
+ const node = nodes[index];
188
+ let span;
189
+ if (nodes.length === 1) {
190
+ span = ts__default["default"].createTextSpanFromBounds(nodes.pos, nodes.end);
191
+ } else if (index === nodes.length - 1) {
192
+ // Remove until previous node
193
+ const neighbor = nodes[index - 1];
194
+ span = ts__default["default"].createTextSpanFromBounds(neighbor.end, node.end);
195
+ } else {
196
+ // Remove before next node
197
+ const neighbor = nodes[index + 1];
198
+ span = ts__default["default"].createTextSpanFromBounds(node.getStart(document, true), neighbor.getStart(document, true));
199
+ }
200
+ const newText = `${document.text.substring(0, span.start)}${document.text.substring(ts__default["default"].textSpanEnd(span))}`;
201
+ return [document.update(newText, ts__default["default"].createTextChangeRange(span, 0)), node];
202
+ }
203
+ function parseAndValidateArrayInsertIndex(key, nodes) {
204
+ if (key === "-") {
205
+ // For insertion, all nodes up until the insertion index must be valid
206
+ // initializers
207
+ const err = jsonValuesModule.validateInitializers(nodes);
208
+ if (err) {
209
+ return fp.result.err(err);
210
+ }
211
+ return fp.result.ok(nodes.length);
212
+ }
213
+ return fp.pipe(patch.parseAndValidateArrayIndex(key), fp.result.flatMap(index => {
214
+ // For insertion, all nodes up until the insertion index must be valid
215
+ // initializers
216
+ const err = jsonValuesModule.validateInitializers(nodes.slice(0, index));
217
+ if (err) {
218
+ return fp.result.err(err);
219
+ }
220
+ if (index > nodes.length) {
221
+ return fp.result.err(new patch.PatchError("Array index out of bounds"));
222
+ } else {
223
+ return fp.result.ok(index);
224
+ }
225
+ }));
226
+ }
227
+ function parseAndValidateArrayInboundsIndex(key, nodes) {
228
+ return fp.pipe(patch.parseAndValidateArrayIndex(key), fp.result.flatMap(index => {
229
+ // For in-bounds operations, all nodes up until and including the index
230
+ // must be valid initializers
231
+ const err = jsonValuesModule.validateInitializers(nodes.slice(0, index + 1));
232
+ if (err) {
233
+ return fp.result.err(err);
234
+ }
235
+ if (index >= nodes.length) {
236
+ return fp.result.err(new patch.PatchError("Array index out of bounds"));
237
+ } else {
238
+ return fp.result.ok(index);
239
+ }
240
+ }));
241
+ }
242
+ function replaceInNode(document, node, key, value) {
243
+ if (ts__default["default"].isArrayLiteralExpression(node)) {
244
+ return fp.pipe(parseAndValidateArrayInboundsIndex(key, node.elements), fp.result.map(index => replaceNodeValue(document, node.elements[index], value)));
245
+ } else if (ts__default["default"].isObjectLiteralExpression(node)) {
246
+ return fp.pipe(jsonValuesModule.findObjectPropertyAssignment(node, key), fp.result.flatMap(assignment => {
247
+ if (!assignment) {
248
+ return fp.result.err(new patch.PatchError("Cannot replace object element which does not exist"));
249
+ }
250
+ return fp.result.ok(assignment);
251
+ }), fp.result.map(assignment => replaceNodeValue(document, assignment.initializer, value)));
252
+ } else {
253
+ return fp.result.err(jsonValuesModule.shallowValidateExpression(node) ?? new patch.PatchError("Cannot replace in non-object/array"));
254
+ }
255
+ }
256
+ function replaceAtPath(document, rootNode, path, value) {
257
+ if (patch.isNotRoot(path)) {
258
+ return fp.pipe(getPointerFromPath(rootNode, path), fp.result.flatMap(([node, key]) => replaceInNode(document, node, key, value)));
259
+ } else {
260
+ return fp.result.ok(replaceNodeValue(document, rootNode, value));
261
+ }
262
+ }
263
+ function getFromNode(node, key) {
264
+ if (ts__default["default"].isArrayLiteralExpression(node)) {
265
+ return fp.pipe(parseAndValidateArrayInboundsIndex(key, node.elements), fp.result.map(index => node.elements[index]));
266
+ } else if (ts__default["default"].isObjectLiteralExpression(node)) {
267
+ return fp.pipe(jsonValuesModule.findObjectPropertyAssignment(node, key), fp.result.map(assignment => assignment === null || assignment === void 0 ? void 0 : assignment.initializer));
268
+ } else {
269
+ return fp.result.err(jsonValuesModule.shallowValidateExpression(node) ?? new patch.PatchError("Cannot access non-object/array"));
270
+ }
271
+ }
272
+ function getPointerFromPath(node, path) {
273
+ let targetNode = node;
274
+ let key = path[0];
275
+ for (let i = 0; i < path.length - 1; ++i, key = path[i]) {
276
+ const childNode = getFromNode(targetNode, key);
277
+ if (fp.result.isErr(childNode)) {
278
+ return childNode;
279
+ }
280
+ if (childNode.value === undefined) {
281
+ return fp.result.err(new patch.PatchError(`Path refers to non-existing object/array: ${path.join("/")}`));
282
+ }
283
+ targetNode = childNode.value;
284
+ }
285
+ return fp.result.ok([targetNode, key]);
286
+ }
287
+ function getAtPath(rootNode, path) {
288
+ return fp.pipe(path, fp.result.flatMapReduce((node, key) => fp.pipe(getFromNode(node, key), fp.result.filterOrElse(childNode => childNode !== undefined, () => new patch.PatchError("Path refers to non-existing object/array"))), rootNode));
289
+ }
290
+ function removeFromNode(document, node, key) {
291
+ if (ts__default["default"].isArrayLiteralExpression(node)) {
292
+ return fp.pipe(parseAndValidateArrayInboundsIndex(key, node.elements), fp.result.map(index => removeAt(document, node.elements, index)));
293
+ } else if (ts__default["default"].isObjectLiteralExpression(node)) {
294
+ return fp.pipe(jsonValuesModule.findObjectPropertyAssignment(node, key), fp.result.flatMap(assignment => {
295
+ if (!assignment) {
296
+ return fp.result.err(new patch.PatchError("Cannot remove object element which does not exist"));
297
+ }
298
+ return fp.result.ok(assignment);
299
+ }), fp.result.map(assignment => [removeAt(document, node.properties, node.properties.indexOf(assignment))[0], assignment.initializer]));
300
+ } else {
301
+ return fp.result.err(jsonValuesModule.shallowValidateExpression(node) ?? new patch.PatchError("Cannot remove from non-object/array"));
302
+ }
303
+ }
304
+ function removeAtPath(document, rootNode, path) {
305
+ return fp.pipe(getPointerFromPath(rootNode, path), fp.result.flatMap(([node, key]) => removeFromNode(document, node, key)));
306
+ }
307
+ function addToNode(document, node, key, value) {
308
+ if (ts__default["default"].isArrayLiteralExpression(node)) {
309
+ return fp.pipe(parseAndValidateArrayInsertIndex(key, node.elements), fp.result.map(index => [insertAt(document, node.elements, index, toExpression(value))]));
310
+ } else if (ts__default["default"].isObjectLiteralExpression(node)) {
311
+ return fp.pipe(jsonValuesModule.findObjectPropertyAssignment(node, key), fp.result.map(assignment => {
312
+ if (!assignment) {
313
+ return [insertAt(document, node.properties, node.properties.length, createPropertyAssignment(key, value))];
314
+ } else {
315
+ return replaceNodeValue(document, assignment.initializer, value);
316
+ }
317
+ }));
318
+ } else {
319
+ return fp.result.err(jsonValuesModule.shallowValidateExpression(node) ?? new patch.PatchError("Cannot add to non-object/array"));
320
+ }
321
+ }
322
+ function addAtPath(document, rootNode, path, value) {
323
+ if (patch.isNotRoot(path)) {
324
+ return fp.pipe(getPointerFromPath(rootNode, path), fp.result.flatMap(([node, key]) => addToNode(document, node, key, value)));
325
+ } else {
326
+ return fp.result.ok(replaceNodeValue(document, rootNode, value));
327
+ }
328
+ }
329
+ function pickDocument([document]) {
330
+ return document;
331
+ }
332
+ class TSOps {
333
+ constructor(findRoot) {
334
+ this.findRoot = findRoot;
335
+ }
336
+ get(document, path) {
337
+ return fp.pipe(document, this.findRoot, fp.result.flatMap(rootNode => getAtPath(rootNode, path)), fp.result.flatMap(jsonValuesModule.evaluateExpression));
338
+ }
339
+ add(document, path, value) {
340
+ return fp.pipe(document, this.findRoot, fp.result.flatMap(rootNode => addAtPath(document, rootNode, path, value)), fp.result.map(pickDocument));
341
+ }
342
+ remove(document, path) {
343
+ return fp.pipe(document, this.findRoot, fp.result.flatMap(rootNode => removeAtPath(document, rootNode, path)), fp.result.map(pickDocument));
344
+ }
345
+ replace(document, path, value) {
346
+ return fp.pipe(document, this.findRoot, fp.result.flatMap(rootNode => replaceAtPath(document, rootNode, path, value)), fp.result.map(pickDocument));
347
+ }
348
+ move(document, from, path) {
349
+ return fp.pipe(document, this.findRoot, fp.result.flatMap(rootNode => removeAtPath(document, rootNode, from)), fp.result.flatMap(([document, removedNode]) => fp.pipe(jsonValuesModule.evaluateExpression(removedNode), fp.result.map(removedValue => [document, removedValue]))), fp.result.flatMap(([document, removedValue]) => fp.pipe(document, this.findRoot, fp.result.flatMap(root => addAtPath(document, root, path, removedValue)))), fp.result.map(pickDocument));
350
+ }
351
+ copy(document, from, path) {
352
+ return fp.pipe(document, this.findRoot, fp.result.flatMap(rootNode => fp.pipe(getAtPath(rootNode, from), fp.result.flatMap(jsonValuesModule.evaluateExpression), fp.result.flatMap(value => addAtPath(document, rootNode, path, value)))), fp.result.map(pickDocument));
353
+ }
354
+ test(document, path, value) {
355
+ return fp.pipe(document, this.findRoot, fp.result.flatMap(rootNode => getAtPath(rootNode, path)), fp.result.flatMap(jsonValuesModule.evaluateExpression), fp.result.map(documentValue => patch.deepEqual(value, documentValue)));
356
+ }
357
+ }
358
+
359
+ exports.TSOps = TSOps;
360
+ exports.insertValJsonEntry = insertValJsonEntry;
361
+ exports.removeValJsonEntry = removeValJsonEntry;
@@ -0,0 +1,41 @@
1
+ 'use strict';
2
+
3
+ var ts = require('typescript');
4
+ var fp = require('@valbuild/core/fp');
5
+ var ops = require('./ops-b15239ac.cjs.prod.js');
6
+ var jsonValuesModule = require('./jsonValuesModule-d1bb8d8f.cjs.prod.js');
7
+ require('@valbuild/core/patch');
8
+
9
+ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
10
+
11
+ var ts__default = /*#__PURE__*/_interopDefault(ts);
12
+
13
+ /**
14
+ * Everything `ValOps.prepare` needs from the TypeScript compiler, in one module
15
+ * so that it is loaded when a publish asks for it rather than with the server.
16
+ *
17
+ * The compiler is most of the server's weight in a browser: the demo's in-tab
18
+ * server was a 3.6 MB chunk, nearly all of it this, and the demo never
19
+ * publishes. `prepare` imports this module dynamically, which a bundler turns
20
+ * into a chunk of its own; `noNodeFromBrowser.test.ts` fails if TypeScript
21
+ * becomes statically reachable from `@valbuild/server/browser` again.
22
+ */
23
+
24
+ const tsOps = new ops.TSOps(document => {
25
+ return fp.pipe(jsonValuesModule.analyzeValModule(document), fp.result.map(({
26
+ source
27
+ }) => source));
28
+ });
29
+
30
+ /** A `.val.ts` file's text, parsed. */
31
+ function parseValFile(text) {
32
+ return ts__default["default"].createSourceFile("<val>", text, ts__default["default"].ScriptTarget.ES2015);
33
+ }
34
+
35
+ exports.insertValJsonEntry = ops.insertValJsonEntry;
36
+ exports.removeValJsonEntry = ops.removeValJsonEntry;
37
+ exports.analyzeJsonValuesEntries = jsonValuesModule.analyzeJsonValuesEntries;
38
+ exports.analyzeValModule = jsonValuesModule.analyzeValModule;
39
+ exports.jsonValuesRecordKeys = jsonValuesModule.jsonValuesRecordKeys;
40
+ exports.parseValFile = parseValFile;
41
+ exports.tsOps = tsOps;
@@ -0,0 +1,41 @@
1
+ 'use strict';
2
+
3
+ var ts = require('typescript');
4
+ var fp = require('@valbuild/core/fp');
5
+ var ops = require('./ops-f37d18c6.cjs.dev.js');
6
+ var jsonValuesModule = require('./jsonValuesModule-8ae503a8.cjs.dev.js');
7
+ require('@valbuild/core/patch');
8
+
9
+ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
10
+
11
+ var ts__default = /*#__PURE__*/_interopDefault(ts);
12
+
13
+ /**
14
+ * Everything `ValOps.prepare` needs from the TypeScript compiler, in one module
15
+ * so that it is loaded when a publish asks for it rather than with the server.
16
+ *
17
+ * The compiler is most of the server's weight in a browser: the demo's in-tab
18
+ * server was a 3.6 MB chunk, nearly all of it this, and the demo never
19
+ * publishes. `prepare` imports this module dynamically, which a bundler turns
20
+ * into a chunk of its own; `noNodeFromBrowser.test.ts` fails if TypeScript
21
+ * becomes statically reachable from `@valbuild/server/browser` again.
22
+ */
23
+
24
+ const tsOps = new ops.TSOps(document => {
25
+ return fp.pipe(jsonValuesModule.analyzeValModule(document), fp.result.map(({
26
+ source
27
+ }) => source));
28
+ });
29
+
30
+ /** A `.val.ts` file's text, parsed. */
31
+ function parseValFile(text) {
32
+ return ts__default["default"].createSourceFile("<val>", text, ts__default["default"].ScriptTarget.ES2015);
33
+ }
34
+
35
+ exports.insertValJsonEntry = ops.insertValJsonEntry;
36
+ exports.removeValJsonEntry = ops.removeValJsonEntry;
37
+ exports.analyzeJsonValuesEntries = jsonValuesModule.analyzeJsonValuesEntries;
38
+ exports.analyzeValModule = jsonValuesModule.analyzeValModule;
39
+ exports.jsonValuesRecordKeys = jsonValuesModule.jsonValuesRecordKeys;
40
+ exports.parseValFile = parseValFile;
41
+ exports.tsOps = tsOps;
@@ -0,0 +1,31 @@
1
+ import ts from 'typescript';
2
+ import { pipe, result } from '@valbuild/core/fp';
3
+ import { T as TSOps } from './ops-0d05feaf.esm.js';
4
+ export { i as insertValJsonEntry, r as removeValJsonEntry } from './ops-0d05feaf.esm.js';
5
+ import { a as analyzeValModule } from './jsonValuesModule-427d68c8.esm.js';
6
+ export { c as analyzeJsonValuesEntries, a as analyzeValModule, j as jsonValuesRecordKeys } from './jsonValuesModule-427d68c8.esm.js';
7
+ import '@valbuild/core/patch';
8
+
9
+ /**
10
+ * Everything `ValOps.prepare` needs from the TypeScript compiler, in one module
11
+ * so that it is loaded when a publish asks for it rather than with the server.
12
+ *
13
+ * The compiler is most of the server's weight in a browser: the demo's in-tab
14
+ * server was a 3.6 MB chunk, nearly all of it this, and the demo never
15
+ * publishes. `prepare` imports this module dynamically, which a bundler turns
16
+ * into a chunk of its own; `noNodeFromBrowser.test.ts` fails if TypeScript
17
+ * becomes statically reachable from `@valbuild/server/browser` again.
18
+ */
19
+
20
+ const tsOps = new TSOps(document => {
21
+ return pipe(analyzeValModule(document), result.map(({
22
+ source
23
+ }) => source));
24
+ });
25
+
26
+ /** A `.val.ts` file's text, parsed. */
27
+ function parseValFile(text) {
28
+ return ts.createSourceFile("<val>", text, ts.ScriptTarget.ES2015);
29
+ }
30
+
31
+ export { parseValFile, tsOps };