@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.
- package/CHANGELOG.md +326 -0
- package/browser/dist/valbuild-server-browser.cjs.dev.js +5 -137
- package/browser/dist/valbuild-server-browser.cjs.prod.js +5 -137
- package/browser/dist/valbuild-server-browser.esm.js +4 -140
- package/dist/ValRouter-2827d620.esm.js +14489 -0
- package/dist/ValRouter-ca467c83.cjs.dev.js +14585 -0
- package/dist/ValRouter-d43e0a33.cjs.prod.js +14585 -0
- package/dist/{ValRouterCore-3431ce5f.cjs.dev.js → ValRouterCore-0921fe9c.cjs.dev.js} +3156 -1758
- package/dist/{ValRouterCore-c5f6885a.esm.js → ValRouterCore-6c29fb75.esm.js} +3147 -1753
- package/dist/{ValRouterCore-df3f99c6.cjs.prod.js → ValRouterCore-eb1f53f5.cjs.prod.js} +3156 -1758
- package/dist/declarations/src/ValOps.d.ts +314 -68
- package/dist/declarations/src/ValOpsFS.d.ts +32 -0
- package/dist/declarations/src/ValOpsHttp.d.ts +93 -3
- package/dist/declarations/src/ValOpsMemory.d.ts +22 -47
- package/dist/declarations/src/ValRouter.d.ts +10 -0
- package/dist/declarations/src/ValServer.d.ts +0 -10
- package/dist/declarations/src/browser/inTabFetch.d.ts +19 -2
- package/dist/declarations/src/draftOverlay.d.ts +51 -0
- package/dist/declarations/src/draftReads.d.ts +103 -0
- package/dist/declarations/src/head.d.ts +312 -0
- package/dist/declarations/src/history/getJsonEntryAtCommit.d.ts +52 -0
- package/dist/declarations/src/index.d.ts +1 -0
- package/dist/declarations/src/internal/browser/index.d.ts +11 -0
- package/dist/declarations/src/internal/index.d.ts +15 -0
- package/dist/declarations/src/patch/jsonValuesPatch.d.ts +2 -165
- package/dist/declarations/src/patch/ts/jsonValuesModule.d.ts +38 -0
- package/dist/declarations/src/patch/ts/loadTypeScriptKit.d.ts +14 -0
- package/dist/declarations/src/patch/ts/ops.d.ts +45 -0
- package/dist/declarations/src/patch/ts/publishKit.d.ts +26 -0
- package/dist/declarations/src/platform.d.ts +14 -0
- package/dist/declarations/src/proposal.d.ts +54 -3
- package/dist/declarations/src/valRuntime.d.ts +35 -0
- package/dist/draftReads-05415ff6.cjs.dev.js +366 -0
- package/dist/draftReads-5f99edd3.esm.js +361 -0
- package/dist/draftReads-ea3946e0.cjs.prod.js +366 -0
- package/dist/inTabFetch-0cd45721.esm.js +176 -0
- package/dist/inTabFetch-35cf5698.cjs.prod.js +179 -0
- package/dist/inTabFetch-49db354b.cjs.dev.js +179 -0
- package/dist/{getJsonEntryAtCommit-b52171b1.cjs.prod.js → publishKit-24e1406b.cjs.prod.js} +55 -6
- package/dist/{getJsonEntryAtCommit-21a4bbfa.cjs.dev.js → publishKit-3afe011d.cjs.dev.js} +55 -6
- package/dist/{getJsonEntryAtCommit-93f9aba9.esm.js → publishKit-d2e3e44d.esm.js} +48 -5
- package/dist/valbuild-server.cjs.dev.js +160 -13319
- package/dist/valbuild-server.cjs.prod.js +160 -13319
- package/dist/valbuild-server.esm.js +34 -13174
- package/internal/browser/dist/valbuild-server-internal-browser.cjs.d.ts +2 -0
- package/internal/browser/dist/valbuild-server-internal-browser.cjs.dev.js +19 -0
- package/internal/browser/dist/valbuild-server-internal-browser.cjs.js +7 -0
- package/internal/browser/dist/valbuild-server-internal-browser.cjs.prod.js +19 -0
- package/internal/browser/dist/valbuild-server-internal-browser.esm.js +10 -0
- package/internal/browser/package.json +4 -0
- package/internal/dist/valbuild-server-internal.cjs.d.ts +2 -0
- package/internal/dist/valbuild-server-internal.cjs.dev.js +43 -0
- package/internal/dist/valbuild-server-internal.cjs.js +7 -0
- package/internal/dist/valbuild-server-internal.cjs.prod.js +43 -0
- package/internal/dist/valbuild-server-internal.esm.js +24 -0
- package/internal/package.json +4 -0
- package/package.json +17 -6
- package/dist/jsonValuesModule-235bd751.cjs.dev.js +0 -326
- package/dist/jsonValuesModule-23eb6f53.esm.js +0 -310
- package/dist/jsonValuesModule-625ebae8.cjs.prod.js +0 -326
- package/dist/ops-0e54b388.cjs.prod.js +0 -361
- package/dist/ops-9ca2ef2a.cjs.dev.js +0 -361
- package/dist/ops-b904007e.esm.js +0 -353
- package/dist/publishKit-34f71e50.cjs.dev.js +0 -42
- package/dist/publishKit-65e9e564.cjs.prod.js +0 -42
- package/dist/publishKit-7441c0fd.esm.js +0 -31
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var core = require('@valbuild/core');
|
|
4
|
+
var ValRouterCore = require('./ValRouterCore-eb1f53f5.cjs.prod.js');
|
|
5
|
+
|
|
6
|
+
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.";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The platform for a server running in a browser tab.
|
|
10
|
+
*
|
|
11
|
+
* Memory mode only: there is no filesystem for `fs` mode and no credential for
|
|
12
|
+
* `http` mode. Everything else answers as a server without those things does
|
|
13
|
+
* -- no `val login` token, no credential for remote files, no link checks --
|
|
14
|
+
* and the session functions refuse, because a tab has no secret to sign with
|
|
15
|
+
* and the server is constructed with `unsafelyAllowUnauthenticated`, so
|
|
16
|
+
* nothing asks for one.
|
|
17
|
+
*/
|
|
18
|
+
const browserPlatform = {
|
|
19
|
+
createOps: (valModules, options) => {
|
|
20
|
+
if (options.mode !== "memory") {
|
|
21
|
+
throw new Error(`Val: a server in the browser runs in memory mode, not '${options.mode}'.`);
|
|
22
|
+
}
|
|
23
|
+
return new ValRouterCore.ValOpsMemory(valModules, {
|
|
24
|
+
formatter: options.formatter,
|
|
25
|
+
config: options.config,
|
|
26
|
+
sourceFiles: options.sourceFiles,
|
|
27
|
+
patchStore: options.patchStore,
|
|
28
|
+
unsafelyAllowUnauthenticated: options.unsafelyAllowUnauthenticated,
|
|
29
|
+
// Nothing can reach a server in a tab but the page it runs in.
|
|
30
|
+
warnUnauthenticated: false,
|
|
31
|
+
contentUrl: options.valContentUrl
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
probeUrl: async () => ({
|
|
35
|
+
kind: "skipped",
|
|
36
|
+
message: "Links are not checked in the browser."
|
|
37
|
+
}),
|
|
38
|
+
jwt: {
|
|
39
|
+
verifyJwt: () => ({
|
|
40
|
+
success: false,
|
|
41
|
+
reason: "missing-secret",
|
|
42
|
+
message: NO_SESSIONS
|
|
43
|
+
}),
|
|
44
|
+
decodeJwtWithoutVerifying: () => ({
|
|
45
|
+
success: false,
|
|
46
|
+
reason: "missing-secret",
|
|
47
|
+
message: NO_SESSIONS
|
|
48
|
+
}),
|
|
49
|
+
encodeJwt: () => {
|
|
50
|
+
throw new Error(NO_SESSIONS);
|
|
51
|
+
},
|
|
52
|
+
getExpire: () => Math.floor(Date.now() / 1000) + 60 * 60
|
|
53
|
+
},
|
|
54
|
+
bytesToBase64: ValRouterCore.bytesToBase64,
|
|
55
|
+
readValLoginToken: async () => null,
|
|
56
|
+
resolveRemoteFileAuth: async () => ({
|
|
57
|
+
status: "error",
|
|
58
|
+
errorCode: "api-key-missing",
|
|
59
|
+
message: "Remote files are not available in the browser."
|
|
60
|
+
})
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/** A `fetch`, as far as the Studio's client calls one. */
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Val's API, served in this tab: a `fetch` that never touches the network.
|
|
67
|
+
*
|
|
68
|
+
* The whole server -- the router's request parsing, `ValServer`'s routes,
|
|
69
|
+
* memory mode's patch chain -- runs here, exactly as it runs on a server.
|
|
70
|
+
* What is removed is the hop between them, and nothing else, which is why the
|
|
71
|
+
* demo built on it cannot drift from the product: there is no second
|
|
72
|
+
* implementation to drift. See `docs/plans/demo-mode.md`.
|
|
73
|
+
*
|
|
74
|
+
* Memory mode with no source files, because nothing here publishes (only a
|
|
75
|
+
* publish reads `.val.ts` text), and without authentication, because the only
|
|
76
|
+
* caller is the page this runs in.
|
|
77
|
+
*/
|
|
78
|
+
function createInTabValFetch(valModules, options) {
|
|
79
|
+
return createInTabVal(valModules, options).fetch;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* {@link createInTabValFetch}, and the runtime behind it: the data layer the
|
|
83
|
+
* server reads through, whose head (`runtime.ops.head`) is what a draft
|
|
84
|
+
* reader reads (`serverDraftSource`). So a caller that reads in-process reads
|
|
85
|
+
* what the API serves, through the same object, as `createValRuntime` gives
|
|
86
|
+
* a server's readers. The isolate probe (`scenarios/measure/isolate/`) reads
|
|
87
|
+
* a draft page this way.
|
|
88
|
+
*
|
|
89
|
+
* `authorize` lets every session read the draft: the server is made with
|
|
90
|
+
* `unsafelyAllowUnauthenticated`, and the only caller is the page it runs in.
|
|
91
|
+
*/
|
|
92
|
+
function createInTabVal(valModules, options) {
|
|
93
|
+
const route = options.route ?? "/api/val";
|
|
94
|
+
const serverConfig = {
|
|
95
|
+
mode: "memory",
|
|
96
|
+
route,
|
|
97
|
+
sourceFiles: {},
|
|
98
|
+
patchStore: options.patchStore,
|
|
99
|
+
unsafelyAllowUnauthenticated: true,
|
|
100
|
+
valContentUrl: core.DEFAULT_CONTENT_HOST,
|
|
101
|
+
config: options.config,
|
|
102
|
+
...(options.framework !== undefined ? {
|
|
103
|
+
framework: options.framework
|
|
104
|
+
} : {})
|
|
105
|
+
};
|
|
106
|
+
// The server makes its ops once, when it is constructed: kept here so they
|
|
107
|
+
// can be handed out.
|
|
108
|
+
const made = {
|
|
109
|
+
ops: null
|
|
110
|
+
};
|
|
111
|
+
const platform = {
|
|
112
|
+
...browserPlatform,
|
|
113
|
+
createOps: (modules, config) => {
|
|
114
|
+
const ops = browserPlatform.createOps(modules, config);
|
|
115
|
+
made.ops = ops;
|
|
116
|
+
return ops;
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
const server = ValRouterCore.ValServer(valModules, serverConfig, {
|
|
120
|
+
// Draft content is the only content a demo has.
|
|
121
|
+
isEnabled: async () => true,
|
|
122
|
+
onEnable: async () => {},
|
|
123
|
+
onDisable: async () => {}
|
|
124
|
+
}, platform);
|
|
125
|
+
const ops = made.ops;
|
|
126
|
+
if (ops === null) throw new Error("the server made no data layer");
|
|
127
|
+
const runtime = {
|
|
128
|
+
ops,
|
|
129
|
+
authorize: () => true
|
|
130
|
+
};
|
|
131
|
+
const handle = ValRouterCore.createValRequestHandler(route, Promise.resolve(server), toResponse);
|
|
132
|
+
const fetch = (input, init) => {
|
|
133
|
+
const base = typeof window === "undefined" ? "http://localhost" : window.location.origin;
|
|
134
|
+
// A `Request` already has an absolute URL, and `init` overrides what it
|
|
135
|
+
// carries, as it does for `fetch`. Only a string or URL is resolved.
|
|
136
|
+
return handle(input instanceof Request ? new Request(input, init) : new Request(new URL(String(input), base).href, init));
|
|
137
|
+
};
|
|
138
|
+
return {
|
|
139
|
+
fetch,
|
|
140
|
+
runtime
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* The server's answer as a `Response`. The same conversion a host makes,
|
|
146
|
+
* less the cookies: a `Response` made in the page cannot set one, and a server
|
|
147
|
+
* that never authenticates has none to set.
|
|
148
|
+
*/
|
|
149
|
+
function toResponse(valRes) {
|
|
150
|
+
const headers = new Headers();
|
|
151
|
+
const valResHeaders = "headers" in valRes && valRes.headers || {};
|
|
152
|
+
for (const key in valResHeaders) {
|
|
153
|
+
const value = valResHeaders[key];
|
|
154
|
+
if (typeof value === "string") {
|
|
155
|
+
headers.set(key, value);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
if ("json" in valRes) {
|
|
159
|
+
headers.set("Content-Type", "application/json");
|
|
160
|
+
return new Response(JSON.stringify(valRes.json), {
|
|
161
|
+
headers,
|
|
162
|
+
status: valRes.status
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
if (valRes.status === 302) {
|
|
166
|
+
headers.set("Location", valRes.redirectTo);
|
|
167
|
+
return new Response(null, {
|
|
168
|
+
status: valRes.status,
|
|
169
|
+
headers
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
return new Response("body" in valRes ? valRes.body : null, {
|
|
173
|
+
headers,
|
|
174
|
+
status: valRes.status
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
exports.createInTabVal = createInTabVal;
|
|
179
|
+
exports.createInTabValFetch = createInTabValFetch;
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var core = require('@valbuild/core');
|
|
4
|
+
var ValRouterCore = require('./ValRouterCore-0921fe9c.cjs.dev.js');
|
|
5
|
+
|
|
6
|
+
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.";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The platform for a server running in a browser tab.
|
|
10
|
+
*
|
|
11
|
+
* Memory mode only: there is no filesystem for `fs` mode and no credential for
|
|
12
|
+
* `http` mode. Everything else answers as a server without those things does
|
|
13
|
+
* -- no `val login` token, no credential for remote files, no link checks --
|
|
14
|
+
* and the session functions refuse, because a tab has no secret to sign with
|
|
15
|
+
* and the server is constructed with `unsafelyAllowUnauthenticated`, so
|
|
16
|
+
* nothing asks for one.
|
|
17
|
+
*/
|
|
18
|
+
const browserPlatform = {
|
|
19
|
+
createOps: (valModules, options) => {
|
|
20
|
+
if (options.mode !== "memory") {
|
|
21
|
+
throw new Error(`Val: a server in the browser runs in memory mode, not '${options.mode}'.`);
|
|
22
|
+
}
|
|
23
|
+
return new ValRouterCore.ValOpsMemory(valModules, {
|
|
24
|
+
formatter: options.formatter,
|
|
25
|
+
config: options.config,
|
|
26
|
+
sourceFiles: options.sourceFiles,
|
|
27
|
+
patchStore: options.patchStore,
|
|
28
|
+
unsafelyAllowUnauthenticated: options.unsafelyAllowUnauthenticated,
|
|
29
|
+
// Nothing can reach a server in a tab but the page it runs in.
|
|
30
|
+
warnUnauthenticated: false,
|
|
31
|
+
contentUrl: options.valContentUrl
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
probeUrl: async () => ({
|
|
35
|
+
kind: "skipped",
|
|
36
|
+
message: "Links are not checked in the browser."
|
|
37
|
+
}),
|
|
38
|
+
jwt: {
|
|
39
|
+
verifyJwt: () => ({
|
|
40
|
+
success: false,
|
|
41
|
+
reason: "missing-secret",
|
|
42
|
+
message: NO_SESSIONS
|
|
43
|
+
}),
|
|
44
|
+
decodeJwtWithoutVerifying: () => ({
|
|
45
|
+
success: false,
|
|
46
|
+
reason: "missing-secret",
|
|
47
|
+
message: NO_SESSIONS
|
|
48
|
+
}),
|
|
49
|
+
encodeJwt: () => {
|
|
50
|
+
throw new Error(NO_SESSIONS);
|
|
51
|
+
},
|
|
52
|
+
getExpire: () => Math.floor(Date.now() / 1000) + 60 * 60
|
|
53
|
+
},
|
|
54
|
+
bytesToBase64: ValRouterCore.bytesToBase64,
|
|
55
|
+
readValLoginToken: async () => null,
|
|
56
|
+
resolveRemoteFileAuth: async () => ({
|
|
57
|
+
status: "error",
|
|
58
|
+
errorCode: "api-key-missing",
|
|
59
|
+
message: "Remote files are not available in the browser."
|
|
60
|
+
})
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/** A `fetch`, as far as the Studio's client calls one. */
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Val's API, served in this tab: a `fetch` that never touches the network.
|
|
67
|
+
*
|
|
68
|
+
* The whole server -- the router's request parsing, `ValServer`'s routes,
|
|
69
|
+
* memory mode's patch chain -- runs here, exactly as it runs on a server.
|
|
70
|
+
* What is removed is the hop between them, and nothing else, which is why the
|
|
71
|
+
* demo built on it cannot drift from the product: there is no second
|
|
72
|
+
* implementation to drift. See `docs/plans/demo-mode.md`.
|
|
73
|
+
*
|
|
74
|
+
* Memory mode with no source files, because nothing here publishes (only a
|
|
75
|
+
* publish reads `.val.ts` text), and without authentication, because the only
|
|
76
|
+
* caller is the page this runs in.
|
|
77
|
+
*/
|
|
78
|
+
function createInTabValFetch(valModules, options) {
|
|
79
|
+
return createInTabVal(valModules, options).fetch;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* {@link createInTabValFetch}, and the runtime behind it: the data layer the
|
|
83
|
+
* server reads through, whose head (`runtime.ops.head`) is what a draft
|
|
84
|
+
* reader reads (`serverDraftSource`). So a caller that reads in-process reads
|
|
85
|
+
* what the API serves, through the same object, as `createValRuntime` gives
|
|
86
|
+
* a server's readers. The isolate probe (`scenarios/measure/isolate/`) reads
|
|
87
|
+
* a draft page this way.
|
|
88
|
+
*
|
|
89
|
+
* `authorize` lets every session read the draft: the server is made with
|
|
90
|
+
* `unsafelyAllowUnauthenticated`, and the only caller is the page it runs in.
|
|
91
|
+
*/
|
|
92
|
+
function createInTabVal(valModules, options) {
|
|
93
|
+
const route = options.route ?? "/api/val";
|
|
94
|
+
const serverConfig = {
|
|
95
|
+
mode: "memory",
|
|
96
|
+
route,
|
|
97
|
+
sourceFiles: {},
|
|
98
|
+
patchStore: options.patchStore,
|
|
99
|
+
unsafelyAllowUnauthenticated: true,
|
|
100
|
+
valContentUrl: core.DEFAULT_CONTENT_HOST,
|
|
101
|
+
config: options.config,
|
|
102
|
+
...(options.framework !== undefined ? {
|
|
103
|
+
framework: options.framework
|
|
104
|
+
} : {})
|
|
105
|
+
};
|
|
106
|
+
// The server makes its ops once, when it is constructed: kept here so they
|
|
107
|
+
// can be handed out.
|
|
108
|
+
const made = {
|
|
109
|
+
ops: null
|
|
110
|
+
};
|
|
111
|
+
const platform = {
|
|
112
|
+
...browserPlatform,
|
|
113
|
+
createOps: (modules, config) => {
|
|
114
|
+
const ops = browserPlatform.createOps(modules, config);
|
|
115
|
+
made.ops = ops;
|
|
116
|
+
return ops;
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
const server = ValRouterCore.ValServer(valModules, serverConfig, {
|
|
120
|
+
// Draft content is the only content a demo has.
|
|
121
|
+
isEnabled: async () => true,
|
|
122
|
+
onEnable: async () => {},
|
|
123
|
+
onDisable: async () => {}
|
|
124
|
+
}, platform);
|
|
125
|
+
const ops = made.ops;
|
|
126
|
+
if (ops === null) throw new Error("the server made no data layer");
|
|
127
|
+
const runtime = {
|
|
128
|
+
ops,
|
|
129
|
+
authorize: () => true
|
|
130
|
+
};
|
|
131
|
+
const handle = ValRouterCore.createValRequestHandler(route, Promise.resolve(server), toResponse);
|
|
132
|
+
const fetch = (input, init) => {
|
|
133
|
+
const base = typeof window === "undefined" ? "http://localhost" : window.location.origin;
|
|
134
|
+
// A `Request` already has an absolute URL, and `init` overrides what it
|
|
135
|
+
// carries, as it does for `fetch`. Only a string or URL is resolved.
|
|
136
|
+
return handle(input instanceof Request ? new Request(input, init) : new Request(new URL(String(input), base).href, init));
|
|
137
|
+
};
|
|
138
|
+
return {
|
|
139
|
+
fetch,
|
|
140
|
+
runtime
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* The server's answer as a `Response`. The same conversion a host makes,
|
|
146
|
+
* less the cookies: a `Response` made in the page cannot set one, and a server
|
|
147
|
+
* that never authenticates has none to set.
|
|
148
|
+
*/
|
|
149
|
+
function toResponse(valRes) {
|
|
150
|
+
const headers = new Headers();
|
|
151
|
+
const valResHeaders = "headers" in valRes && valRes.headers || {};
|
|
152
|
+
for (const key in valResHeaders) {
|
|
153
|
+
const value = valResHeaders[key];
|
|
154
|
+
if (typeof value === "string") {
|
|
155
|
+
headers.set(key, value);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
if ("json" in valRes) {
|
|
159
|
+
headers.set("Content-Type", "application/json");
|
|
160
|
+
return new Response(JSON.stringify(valRes.json), {
|
|
161
|
+
headers,
|
|
162
|
+
status: valRes.status
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
if (valRes.status === 302) {
|
|
166
|
+
headers.set("Location", valRes.redirectTo);
|
|
167
|
+
return new Response(null, {
|
|
168
|
+
status: valRes.status,
|
|
169
|
+
headers
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
return new Response("body" in valRes ? valRes.body : null, {
|
|
173
|
+
headers,
|
|
174
|
+
status: valRes.status
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
exports.createInTabVal = createInTabVal;
|
|
179
|
+
exports.createInTabValFetch = createInTabValFetch;
|
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var ts = require('typescript');
|
|
4
|
-
var ValRouterCore = require('./ValRouterCore-df3f99c6.cjs.prod.js');
|
|
5
4
|
var fp = require('@valbuild/core/fp');
|
|
6
|
-
var
|
|
5
|
+
var ValRouter = require('./ValRouter-d43e0a33.cjs.prod.js');
|
|
6
|
+
var ValRouterCore = require('./ValRouterCore-eb1f53f5.cjs.prod.js');
|
|
7
7
|
require('@valbuild/core');
|
|
8
|
-
require('@valbuild/
|
|
8
|
+
require('@valbuild/ui/server');
|
|
9
|
+
require('path');
|
|
9
10
|
require('zod');
|
|
11
|
+
require('fs');
|
|
10
12
|
require('zod-validation-error');
|
|
13
|
+
require('@valbuild/shared/internal');
|
|
14
|
+
require('os');
|
|
15
|
+
require('crypto');
|
|
16
|
+
require('buffer');
|
|
11
17
|
require('@valbuild/core/patch');
|
|
18
|
+
require('node:vm');
|
|
19
|
+
require('node:module');
|
|
20
|
+
require('node:http');
|
|
21
|
+
require('node:https');
|
|
22
|
+
require('node:net');
|
|
12
23
|
require('image-size');
|
|
24
|
+
require('http');
|
|
25
|
+
require('https');
|
|
13
26
|
|
|
14
27
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
15
28
|
|
|
@@ -101,7 +114,7 @@ moduleGitPath, valTsSource, key) {
|
|
|
101
114
|
const sourceFile = ts__default["default"].createSourceFile(moduleFilePath, valTsSource, ts__default["default"].ScriptTarget.ES2015, true);
|
|
102
115
|
let analysis;
|
|
103
116
|
try {
|
|
104
|
-
analysis =
|
|
117
|
+
analysis = ValRouter.analyzeValModule(sourceFile);
|
|
105
118
|
} catch (err) {
|
|
106
119
|
// `file-unavailable` rather than a kind of its own: the module's TEXT is
|
|
107
120
|
// the file we could not use, and adding a wire kind for "unparseable"
|
|
@@ -119,7 +132,7 @@ moduleGitPath, valTsSource, key) {
|
|
|
119
132
|
message: "could not read the module at this commit"
|
|
120
133
|
});
|
|
121
134
|
}
|
|
122
|
-
const entries =
|
|
135
|
+
const entries = ValRouter.analyzeJsonValuesEntries(analysis.value.source);
|
|
123
136
|
const entry = entries.get(key);
|
|
124
137
|
if (entry === undefined) {
|
|
125
138
|
/*
|
|
@@ -138,5 +151,41 @@ moduleGitPath, valTsSource, key) {
|
|
|
138
151
|
return fp.result.ok(ValRouterCore.posixPath.join(moduleDir, entry.importPath));
|
|
139
152
|
}
|
|
140
153
|
|
|
141
|
-
|
|
154
|
+
/**
|
|
155
|
+
* Everything Val's server needs from the TypeScript compiler, in one module:
|
|
156
|
+
* what a publish needs (`ValOps.prepare`) and what the history reader needs
|
|
157
|
+
* (`/history/json`, which reads a `.val.ts` at a commit to find an entry's
|
|
158
|
+
* file).
|
|
159
|
+
*
|
|
160
|
+
* The compiler is 10.8 MB of source -- 84% of Val's server as a Worker
|
|
161
|
+
* bundles it -- and a server in a browser tab or a memory-mode Worker never
|
|
162
|
+
* publishes from it. So it is not imported by the request handlers at all,
|
|
163
|
+
* not even dynamically: a bundler that does not split chunks (wrangler,
|
|
164
|
+
* esbuild with one output file) inlines a dynamic `import()` and ships the
|
|
165
|
+
* compiler anyway. It reaches the server through `ValServerPlatform`'s
|
|
166
|
+
* `typescript` (the platform) and `ValOpsOptions.typescript` (the data layer),
|
|
167
|
+
* both of which `nodePlatform` fills with `loadTypeScriptKit`, and the browser
|
|
168
|
+
* platform leaves empty. `noNodeFromBrowser.test.ts` fails, naming the chain,
|
|
169
|
+
* if TypeScript becomes reachable from `@valbuild/server/browser` again.
|
|
170
|
+
*/
|
|
171
|
+
|
|
172
|
+
const tsOps = new ValRouter.TSOps(document => {
|
|
173
|
+
return fp.pipe(ValRouter.analyzeValModule(document), fp.result.map(({
|
|
174
|
+
source
|
|
175
|
+
}) => source));
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
/** A `.val.ts` file's text, parsed. */
|
|
179
|
+
function parseValFile(text) {
|
|
180
|
+
return ts__default["default"].createSourceFile("<val>", text, ts__default["default"].ScriptTarget.ES2015);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
exports.analyzeJsonValuesEntries = ValRouter.analyzeJsonValuesEntries;
|
|
184
|
+
exports.analyzeValModule = ValRouter.analyzeValModule;
|
|
185
|
+
exports.evaluateModuleSource = ValRouter.evaluateModuleSource;
|
|
186
|
+
exports.insertValJsonEntry = ValRouter.insertValJsonEntry;
|
|
187
|
+
exports.jsonValuesRecordKeys = ValRouter.jsonValuesRecordKeys;
|
|
188
|
+
exports.removeValJsonEntry = ValRouter.removeValJsonEntry;
|
|
142
189
|
exports.getJsonEntryAtCommit = getJsonEntryAtCommit;
|
|
190
|
+
exports.parseValFile = parseValFile;
|
|
191
|
+
exports.tsOps = tsOps;
|
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var ts = require('typescript');
|
|
4
|
-
var ValRouterCore = require('./ValRouterCore-3431ce5f.cjs.dev.js');
|
|
5
4
|
var fp = require('@valbuild/core/fp');
|
|
6
|
-
var
|
|
5
|
+
var ValRouter = require('./ValRouter-ca467c83.cjs.dev.js');
|
|
6
|
+
var ValRouterCore = require('./ValRouterCore-0921fe9c.cjs.dev.js');
|
|
7
7
|
require('@valbuild/core');
|
|
8
|
-
require('@valbuild/
|
|
8
|
+
require('@valbuild/ui/server');
|
|
9
|
+
require('path');
|
|
9
10
|
require('zod');
|
|
11
|
+
require('fs');
|
|
10
12
|
require('zod-validation-error');
|
|
13
|
+
require('@valbuild/shared/internal');
|
|
14
|
+
require('os');
|
|
15
|
+
require('crypto');
|
|
16
|
+
require('buffer');
|
|
11
17
|
require('@valbuild/core/patch');
|
|
18
|
+
require('node:vm');
|
|
19
|
+
require('node:module');
|
|
20
|
+
require('node:http');
|
|
21
|
+
require('node:https');
|
|
22
|
+
require('node:net');
|
|
12
23
|
require('image-size');
|
|
24
|
+
require('http');
|
|
25
|
+
require('https');
|
|
13
26
|
|
|
14
27
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
15
28
|
|
|
@@ -101,7 +114,7 @@ moduleGitPath, valTsSource, key) {
|
|
|
101
114
|
const sourceFile = ts__default["default"].createSourceFile(moduleFilePath, valTsSource, ts__default["default"].ScriptTarget.ES2015, true);
|
|
102
115
|
let analysis;
|
|
103
116
|
try {
|
|
104
|
-
analysis =
|
|
117
|
+
analysis = ValRouter.analyzeValModule(sourceFile);
|
|
105
118
|
} catch (err) {
|
|
106
119
|
// `file-unavailable` rather than a kind of its own: the module's TEXT is
|
|
107
120
|
// the file we could not use, and adding a wire kind for "unparseable"
|
|
@@ -119,7 +132,7 @@ moduleGitPath, valTsSource, key) {
|
|
|
119
132
|
message: "could not read the module at this commit"
|
|
120
133
|
});
|
|
121
134
|
}
|
|
122
|
-
const entries =
|
|
135
|
+
const entries = ValRouter.analyzeJsonValuesEntries(analysis.value.source);
|
|
123
136
|
const entry = entries.get(key);
|
|
124
137
|
if (entry === undefined) {
|
|
125
138
|
/*
|
|
@@ -138,5 +151,41 @@ moduleGitPath, valTsSource, key) {
|
|
|
138
151
|
return fp.result.ok(ValRouterCore.posixPath.join(moduleDir, entry.importPath));
|
|
139
152
|
}
|
|
140
153
|
|
|
141
|
-
|
|
154
|
+
/**
|
|
155
|
+
* Everything Val's server needs from the TypeScript compiler, in one module:
|
|
156
|
+
* what a publish needs (`ValOps.prepare`) and what the history reader needs
|
|
157
|
+
* (`/history/json`, which reads a `.val.ts` at a commit to find an entry's
|
|
158
|
+
* file).
|
|
159
|
+
*
|
|
160
|
+
* The compiler is 10.8 MB of source -- 84% of Val's server as a Worker
|
|
161
|
+
* bundles it -- and a server in a browser tab or a memory-mode Worker never
|
|
162
|
+
* publishes from it. So it is not imported by the request handlers at all,
|
|
163
|
+
* not even dynamically: a bundler that does not split chunks (wrangler,
|
|
164
|
+
* esbuild with one output file) inlines a dynamic `import()` and ships the
|
|
165
|
+
* compiler anyway. It reaches the server through `ValServerPlatform`'s
|
|
166
|
+
* `typescript` (the platform) and `ValOpsOptions.typescript` (the data layer),
|
|
167
|
+
* both of which `nodePlatform` fills with `loadTypeScriptKit`, and the browser
|
|
168
|
+
* platform leaves empty. `noNodeFromBrowser.test.ts` fails, naming the chain,
|
|
169
|
+
* if TypeScript becomes reachable from `@valbuild/server/browser` again.
|
|
170
|
+
*/
|
|
171
|
+
|
|
172
|
+
const tsOps = new ValRouter.TSOps(document => {
|
|
173
|
+
return fp.pipe(ValRouter.analyzeValModule(document), fp.result.map(({
|
|
174
|
+
source
|
|
175
|
+
}) => source));
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
/** A `.val.ts` file's text, parsed. */
|
|
179
|
+
function parseValFile(text) {
|
|
180
|
+
return ts__default["default"].createSourceFile("<val>", text, ts__default["default"].ScriptTarget.ES2015);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
exports.analyzeJsonValuesEntries = ValRouter.analyzeJsonValuesEntries;
|
|
184
|
+
exports.analyzeValModule = ValRouter.analyzeValModule;
|
|
185
|
+
exports.evaluateModuleSource = ValRouter.evaluateModuleSource;
|
|
186
|
+
exports.insertValJsonEntry = ValRouter.insertValJsonEntry;
|
|
187
|
+
exports.jsonValuesRecordKeys = ValRouter.jsonValuesRecordKeys;
|
|
188
|
+
exports.removeValJsonEntry = ValRouter.removeValJsonEntry;
|
|
142
189
|
exports.getJsonEntryAtCommit = getJsonEntryAtCommit;
|
|
190
|
+
exports.parseValFile = parseValFile;
|
|
191
|
+
exports.tsOps = tsOps;
|
|
@@ -1,13 +1,27 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
2
|
+
import { result, pipe } from '@valbuild/core/fp';
|
|
3
|
+
import { a as analyzeValModule, c as analyzeJsonValuesEntries, T as TSOps } from './ValRouter-2827d620.esm.js';
|
|
4
|
+
export { c as analyzeJsonValuesEntries, a as analyzeValModule, a7 as evaluateModuleSource, i as insertValJsonEntry, a8 as jsonValuesRecordKeys, r as removeValJsonEntry } from './ValRouter-2827d620.esm.js';
|
|
5
|
+
import { R as bytesToUtf8, S as posixPath } from './ValRouterCore-6c29fb75.esm.js';
|
|
5
6
|
import '@valbuild/core';
|
|
6
|
-
import '@valbuild/
|
|
7
|
+
import '@valbuild/ui/server';
|
|
8
|
+
import 'path';
|
|
7
9
|
import 'zod';
|
|
10
|
+
import 'fs';
|
|
8
11
|
import 'zod-validation-error';
|
|
12
|
+
import '@valbuild/shared/internal';
|
|
13
|
+
import 'os';
|
|
14
|
+
import 'crypto';
|
|
15
|
+
import 'buffer';
|
|
9
16
|
import '@valbuild/core/patch';
|
|
17
|
+
import 'node:vm';
|
|
18
|
+
import 'node:module';
|
|
19
|
+
import 'node:http';
|
|
20
|
+
import 'node:https';
|
|
21
|
+
import 'node:net';
|
|
10
22
|
import 'image-size';
|
|
23
|
+
import 'http';
|
|
24
|
+
import 'https';
|
|
11
25
|
|
|
12
26
|
/**
|
|
13
27
|
* One `.jsonValues()` entry's content, as it was at a commit.
|
|
@@ -132,4 +146,33 @@ moduleGitPath, valTsSource, key) {
|
|
|
132
146
|
return result.ok(posixPath.join(moduleDir, entry.importPath));
|
|
133
147
|
}
|
|
134
148
|
|
|
135
|
-
|
|
149
|
+
/**
|
|
150
|
+
* Everything Val's server needs from the TypeScript compiler, in one module:
|
|
151
|
+
* what a publish needs (`ValOps.prepare`) and what the history reader needs
|
|
152
|
+
* (`/history/json`, which reads a `.val.ts` at a commit to find an entry's
|
|
153
|
+
* file).
|
|
154
|
+
*
|
|
155
|
+
* The compiler is 10.8 MB of source -- 84% of Val's server as a Worker
|
|
156
|
+
* bundles it -- and a server in a browser tab or a memory-mode Worker never
|
|
157
|
+
* publishes from it. So it is not imported by the request handlers at all,
|
|
158
|
+
* not even dynamically: a bundler that does not split chunks (wrangler,
|
|
159
|
+
* esbuild with one output file) inlines a dynamic `import()` and ships the
|
|
160
|
+
* compiler anyway. It reaches the server through `ValServerPlatform`'s
|
|
161
|
+
* `typescript` (the platform) and `ValOpsOptions.typescript` (the data layer),
|
|
162
|
+
* both of which `nodePlatform` fills with `loadTypeScriptKit`, and the browser
|
|
163
|
+
* platform leaves empty. `noNodeFromBrowser.test.ts` fails, naming the chain,
|
|
164
|
+
* if TypeScript becomes reachable from `@valbuild/server/browser` again.
|
|
165
|
+
*/
|
|
166
|
+
|
|
167
|
+
const tsOps = new TSOps(document => {
|
|
168
|
+
return pipe(analyzeValModule(document), result.map(({
|
|
169
|
+
source
|
|
170
|
+
}) => source));
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
/** A `.val.ts` file's text, parsed. */
|
|
174
|
+
function parseValFile(text) {
|
|
175
|
+
return ts.createSourceFile("<val>", text, ts.ScriptTarget.ES2015);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export { getJsonEntryAtCommit, parseValFile, tsOps };
|