@valbuild/server 0.150.22 → 0.151.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 (66) hide show
  1. package/CHANGELOG.md +326 -0
  2. package/browser/dist/valbuild-server-browser.cjs.dev.js +5 -137
  3. package/browser/dist/valbuild-server-browser.cjs.prod.js +5 -137
  4. package/browser/dist/valbuild-server-browser.esm.js +4 -140
  5. package/dist/ValRouter-2827d620.esm.js +14489 -0
  6. package/dist/ValRouter-ca467c83.cjs.dev.js +14585 -0
  7. package/dist/ValRouter-d43e0a33.cjs.prod.js +14585 -0
  8. package/dist/{ValRouterCore-3431ce5f.cjs.dev.js → ValRouterCore-0921fe9c.cjs.dev.js} +3156 -1758
  9. package/dist/{ValRouterCore-c5f6885a.esm.js → ValRouterCore-6c29fb75.esm.js} +3147 -1753
  10. package/dist/{ValRouterCore-df3f99c6.cjs.prod.js → ValRouterCore-eb1f53f5.cjs.prod.js} +3156 -1758
  11. package/dist/declarations/src/ValOps.d.ts +314 -68
  12. package/dist/declarations/src/ValOpsFS.d.ts +32 -0
  13. package/dist/declarations/src/ValOpsHttp.d.ts +93 -3
  14. package/dist/declarations/src/ValOpsMemory.d.ts +22 -47
  15. package/dist/declarations/src/ValRouter.d.ts +10 -0
  16. package/dist/declarations/src/ValServer.d.ts +0 -10
  17. package/dist/declarations/src/browser/inTabFetch.d.ts +19 -2
  18. package/dist/declarations/src/draftOverlay.d.ts +51 -0
  19. package/dist/declarations/src/draftReads.d.ts +103 -0
  20. package/dist/declarations/src/head.d.ts +312 -0
  21. package/dist/declarations/src/history/getJsonEntryAtCommit.d.ts +52 -0
  22. package/dist/declarations/src/index.d.ts +1 -0
  23. package/dist/declarations/src/internal/browser/index.d.ts +11 -0
  24. package/dist/declarations/src/internal/index.d.ts +15 -0
  25. package/dist/declarations/src/patch/jsonValuesPatch.d.ts +2 -165
  26. package/dist/declarations/src/patch/ts/jsonValuesModule.d.ts +38 -0
  27. package/dist/declarations/src/patch/ts/loadTypeScriptKit.d.ts +14 -0
  28. package/dist/declarations/src/patch/ts/ops.d.ts +45 -0
  29. package/dist/declarations/src/patch/ts/publishKit.d.ts +26 -0
  30. package/dist/declarations/src/platform.d.ts +14 -0
  31. package/dist/declarations/src/proposal.d.ts +54 -3
  32. package/dist/declarations/src/valRuntime.d.ts +35 -0
  33. package/dist/draftReads-05415ff6.cjs.dev.js +366 -0
  34. package/dist/draftReads-5f99edd3.esm.js +361 -0
  35. package/dist/draftReads-ea3946e0.cjs.prod.js +366 -0
  36. package/dist/inTabFetch-0cd45721.esm.js +176 -0
  37. package/dist/inTabFetch-35cf5698.cjs.prod.js +179 -0
  38. package/dist/inTabFetch-49db354b.cjs.dev.js +179 -0
  39. package/dist/{getJsonEntryAtCommit-b52171b1.cjs.prod.js → publishKit-24e1406b.cjs.prod.js} +55 -6
  40. package/dist/{getJsonEntryAtCommit-21a4bbfa.cjs.dev.js → publishKit-3afe011d.cjs.dev.js} +55 -6
  41. package/dist/{getJsonEntryAtCommit-93f9aba9.esm.js → publishKit-d2e3e44d.esm.js} +48 -5
  42. package/dist/valbuild-server.cjs.dev.js +160 -13319
  43. package/dist/valbuild-server.cjs.prod.js +160 -13319
  44. package/dist/valbuild-server.esm.js +34 -13174
  45. package/internal/browser/dist/valbuild-server-internal-browser.cjs.d.ts +2 -0
  46. package/internal/browser/dist/valbuild-server-internal-browser.cjs.dev.js +19 -0
  47. package/internal/browser/dist/valbuild-server-internal-browser.cjs.js +7 -0
  48. package/internal/browser/dist/valbuild-server-internal-browser.cjs.prod.js +19 -0
  49. package/internal/browser/dist/valbuild-server-internal-browser.esm.js +10 -0
  50. package/internal/browser/package.json +4 -0
  51. package/internal/dist/valbuild-server-internal.cjs.d.ts +2 -0
  52. package/internal/dist/valbuild-server-internal.cjs.dev.js +43 -0
  53. package/internal/dist/valbuild-server-internal.cjs.js +7 -0
  54. package/internal/dist/valbuild-server-internal.cjs.prod.js +43 -0
  55. package/internal/dist/valbuild-server-internal.esm.js +24 -0
  56. package/internal/package.json +4 -0
  57. package/package.json +17 -6
  58. package/dist/jsonValuesModule-235bd751.cjs.dev.js +0 -326
  59. package/dist/jsonValuesModule-23eb6f53.esm.js +0 -310
  60. package/dist/jsonValuesModule-625ebae8.cjs.prod.js +0 -326
  61. package/dist/ops-0e54b388.cjs.prod.js +0 -361
  62. package/dist/ops-9ca2ef2a.cjs.dev.js +0 -361
  63. package/dist/ops-b904007e.esm.js +0 -353
  64. package/dist/publishKit-34f71e50.cjs.dev.js +0 -42
  65. package/dist/publishKit-65e9e564.cjs.prod.js +0 -42
  66. package/dist/publishKit-7441c0fd.esm.js +0 -31
@@ -1,145 +1,9 @@
1
- import { DEFAULT_CONTENT_HOST } from '@valbuild/core';
2
- import { o as ValOpsMemory, M as bytesToBase64, F as ValServer, G as createValRequestHandler } from '../../dist/ValRouterCore-c5f6885a.esm.js';
3
- import '@valbuild/shared/internal';
1
+ export { c as createInTabValFetch } from '../../dist/inTabFetch-0cd45721.esm.js';
2
+ import '@valbuild/core';
3
+ import '../../dist/ValRouterCore-6c29fb75.esm.js';
4
4
  import 'zod';
5
+ import '@valbuild/shared/internal';
5
6
  import 'zod-validation-error';
6
7
  import '@valbuild/core/fp';
7
8
  import '@valbuild/core/patch';
8
9
  import 'image-size';
9
-
10
- const NO_SESSIONS = "Val: sessions are not available here -- this server runs in the browser, " + "has no secret to sign them with, and serves without authenticating.";
11
-
12
- /**
13
- * The platform for a server running in a browser tab.
14
- *
15
- * Memory mode only: there is no filesystem for `fs` mode and no credential for
16
- * `http` mode. Everything else answers as a server without those things does
17
- * -- no `val login` token, no credential for remote files, no link checks --
18
- * and the session functions refuse, because a tab has no secret to sign with
19
- * and the server is constructed with `unsafelyAllowUnauthenticated`, so
20
- * nothing asks for one.
21
- */
22
- const browserPlatform = {
23
- createOps: (valModules, options) => {
24
- if (options.mode !== "memory") {
25
- throw new Error(`Val: a server in the browser runs in memory mode, not '${options.mode}'.`);
26
- }
27
- return new ValOpsMemory(valModules, {
28
- formatter: options.formatter,
29
- config: options.config,
30
- sourceFiles: options.sourceFiles,
31
- patchStore: options.patchStore,
32
- unsafelyAllowUnauthenticated: options.unsafelyAllowUnauthenticated,
33
- // Nothing can reach a server in a tab but the page it runs in.
34
- warnUnauthenticated: false,
35
- contentUrl: options.valContentUrl
36
- });
37
- },
38
- probeUrl: async () => ({
39
- kind: "skipped",
40
- message: "Links are not checked in the browser."
41
- }),
42
- jwt: {
43
- verifyJwt: () => ({
44
- success: false,
45
- reason: "missing-secret",
46
- message: NO_SESSIONS
47
- }),
48
- decodeJwtWithoutVerifying: () => ({
49
- success: false,
50
- reason: "missing-secret",
51
- message: NO_SESSIONS
52
- }),
53
- encodeJwt: () => {
54
- throw new Error(NO_SESSIONS);
55
- },
56
- getExpire: () => Math.floor(Date.now() / 1000) + 60 * 60
57
- },
58
- bytesToBase64,
59
- readValLoginToken: async () => null,
60
- resolveRemoteFileAuth: async () => ({
61
- status: "error",
62
- errorCode: "api-key-missing",
63
- message: "Remote files are not available in the browser."
64
- })
65
- };
66
-
67
- /** A `fetch`, as far as the Studio's client calls one. */
68
-
69
- /**
70
- * Val's API, served in this tab: a `fetch` that never touches the network.
71
- *
72
- * The whole server -- the router's request parsing, `ValServer`'s routes,
73
- * memory mode's patch chain -- runs here, exactly as it runs on a server.
74
- * What is removed is the hop between them, and nothing else, which is why the
75
- * demo built on it cannot drift from the product: there is no second
76
- * implementation to drift. See `docs/plans/demo-mode.md`.
77
- *
78
- * Memory mode with no source files, because nothing here publishes (only a
79
- * publish reads `.val.ts` text), and without authentication, because the only
80
- * caller is the page this runs in.
81
- */
82
- function createInTabValFetch(valModules, options) {
83
- const route = options.route ?? "/api/val";
84
- const serverConfig = {
85
- mode: "memory",
86
- route,
87
- sourceFiles: {},
88
- patchStore: options.patchStore,
89
- unsafelyAllowUnauthenticated: true,
90
- valContentUrl: DEFAULT_CONTENT_HOST,
91
- config: options.config,
92
- ...(options.framework !== undefined ? {
93
- framework: options.framework
94
- } : {})
95
- };
96
- const server = ValServer(valModules, serverConfig, {
97
- // Draft content is the only content a demo has.
98
- isEnabled: async () => true,
99
- onEnable: async () => {},
100
- onDisable: async () => {}
101
- }, browserPlatform);
102
- const handle = createValRequestHandler(route, Promise.resolve(server), toResponse);
103
- return (input, init) => {
104
- const base = typeof window === "undefined" ? "http://localhost" : window.location.origin;
105
- // A `Request` already has an absolute URL, and `init` overrides what it
106
- // carries, as it does for `fetch`. Only a string or URL is resolved.
107
- return handle(input instanceof Request ? new Request(input, init) : new Request(new URL(String(input), base).href, init));
108
- };
109
- }
110
-
111
- /**
112
- * The server's answer as a `Response`. The same conversion a host makes,
113
- * less the cookies: a `Response` made in the page cannot set one, and a server
114
- * that never authenticates has none to set.
115
- */
116
- function toResponse(valRes) {
117
- const headers = new Headers();
118
- const valResHeaders = "headers" in valRes && valRes.headers || {};
119
- for (const key in valResHeaders) {
120
- const value = valResHeaders[key];
121
- if (typeof value === "string") {
122
- headers.set(key, value);
123
- }
124
- }
125
- if ("json" in valRes) {
126
- headers.set("Content-Type", "application/json");
127
- return new Response(JSON.stringify(valRes.json), {
128
- headers,
129
- status: valRes.status
130
- });
131
- }
132
- if (valRes.status === 302) {
133
- headers.set("Location", valRes.redirectTo);
134
- return new Response(null, {
135
- status: valRes.status,
136
- headers
137
- });
138
- }
139
- return new Response("body" in valRes ? valRes.body : null, {
140
- headers,
141
- status: valRes.status
142
- });
143
- }
144
-
145
- export { createInTabValFetch };