@plitzi/sdk-server 0.38.16 → 0.38.18
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 +115 -0
- package/README.md +33 -18
- package/dist/adapters/cloudAdapters.js +2 -2
- package/dist/core/auth/csrf.d.ts +16 -11
- package/dist/core/auth/csrf.js +35 -17
- package/dist/core/configSeam.js +1 -1
- package/dist/core/http/stages/crossSiteWrites.d.ts +5 -4
- package/dist/core/http/stages/crossSiteWrites.js +6 -5
- package/dist/core/http/stages/images.js +1 -1
- package/dist/core/http/stages/livePages.d.ts +43 -0
- package/dist/core/http/stages/livePages.js +80 -0
- package/dist/core/server/baseServer.d.ts +6 -2
- package/dist/core/server/baseServer.js +1 -0
- package/dist/core/server/fleet/channel.js +1 -1
- package/dist/core/server/fleet/relay.js +1 -1
- package/dist/core/server/pageServer.js +11 -8
- package/dist/helpers/cache/keys.js +1 -1
- package/dist/helpers/flagOverrides.d.ts +2 -1
- package/dist/helpers/paintedCookie.js +2 -2
- package/dist/{modules → hosts}/authoringHost/index.d.ts +13 -5
- package/dist/{modules → hosts}/authoringHost/index.js +31 -26
- package/dist/{modules → hosts}/project/plugins.d.ts +2 -2
- package/dist/{modules → hosts}/project/plugins.js +5 -6
- package/dist/{modules → hosts}/project/serveProject.d.ts +2 -2
- package/dist/{modules → hosts}/project/serveProject.js +12 -15
- package/dist/{modules → hosts}/project/spaceFailure.js +3 -3
- package/dist/{modules → hosts}/project/watchSpace.js +3 -3
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/layers.test.d.ts +1 -0
- package/dist/modules/actions/jobs/later.js +1 -1
- package/dist/modules/actions/runtime/credentials.js +1 -1
- package/dist/modules/actions/runtime/kvList.js +1 -1
- package/dist/modules/actions/runtime/runAction.js +1 -1
- package/dist/modules/connectors/resolver.js +1 -1
- package/dist/modules/functions/capabilities.js +1 -1
- package/dist/modules/functions/load.js +1 -1
- package/dist/modules/functions/manifest.js +2 -2
- package/dist/modules/functions/routes.js +1 -1
- package/dist/modules/functions/runner/messages.js +1 -1
- package/dist/modules/functions/scope.js +1 -1
- package/dist/modules/images/imageProxy.js +1 -1
- package/dist/modules/realtime/socket.js +1 -1
- package/dist/modules/rsc/publicFileResolver.js +1 -1
- package/dist/modules/rsc/resolveRscData.d.ts +2 -1
- package/dist/modules/rsc/resolveRscData.js +1 -1
- package/dist/modules/runtime/bundle.js +1 -1
- package/dist/modules/ssr/prepareRender.js +8 -7
- package/dist/modules/ssr/resolvePageSeo.js +1 -1
- package/dist/modules/ssr/views/template.ejs +18 -9
- package/dist/plugins/compile.js +1 -1
- package/dist/plugins/copy.js +1 -1
- package/dist/plugins/watch.d.ts +1 -1
- package/dist/plugins/watch.js +1 -1
- package/dist/project.d.ts +4 -4
- package/dist/project.js +1 -2
- package/dist/sqlite.js +1 -2
- package/package.json +30 -15
- package/dist/core/http/stages/devReload.d.ts +0 -29
- package/dist/core/http/stages/devReload.js +0 -57
- /package/dist/core/{createServer.devReload.test.d.ts → createServer.livePages.test.d.ts} +0 -0
- /package/dist/{modules → hosts}/authoringHost/index.test.d.ts +0 -0
- /package/dist/{modules → hosts}/project/serveProject.test.d.ts +0 -0
- /package/dist/{modules → hosts}/project/spaceFailure.d.ts +0 -0
- /package/dist/{modules → hosts}/project/watchSpace.d.ts +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { fetchOutbound } from "../../helpers/outboundGuard.js";
|
|
2
2
|
import { writeFileAtomic } from "../../helpers/atomicFile.js";
|
|
3
3
|
import { isAllowedImageHost } from "./allowlist.js";
|
|
4
|
+
import { IMAGE_WIDTHS, isImageWidth } from "@plitzi/sdk-shared/helpers";
|
|
4
5
|
import { createHash } from "node:crypto";
|
|
5
6
|
import fs from "node:fs/promises";
|
|
6
7
|
import path from "node:path";
|
|
7
|
-
import { IMAGE_WIDTHS, isImageWidth } from "@plitzi/sdk-shared/helpers/images";
|
|
8
8
|
//#region src/modules/images/imageProxy.ts
|
|
9
9
|
/** The formats a picture may arrive in, as the file extension it is kept under. SVG is not one: served from this
|
|
10
10
|
* origin, an SVG is a document that can run script. */
|
|
@@ -54,7 +54,7 @@ var handleRealtimeSocket = async ({ req, res, raw, upgrade, hub, resolveChannels
|
|
|
54
54
|
if (!originAllowed(raw, req, allowedOrigins)) {
|
|
55
55
|
answer(res, {
|
|
56
56
|
status: 403,
|
|
57
|
-
error: "A page
|
|
57
|
+
error: "A page of another origin may not open this",
|
|
58
58
|
reason: "foreign"
|
|
59
59
|
});
|
|
60
60
|
return;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import { PROJECT_DATA_PREFIX } from "@plitzi/sdk-shared/
|
|
3
|
+
import { PROJECT_DATA_PREFIX } from "@plitzi/sdk-shared/project/paths";
|
|
4
4
|
//#region src/modules/rsc/publicFileResolver.ts
|
|
5
5
|
/** Where a provider's `query` is a path: a URL, a protocol-relative one or one with `{{tokens}}` is not. */
|
|
6
6
|
var pathOf = (query) => {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Element, Environment,
|
|
1
|
+
import { Element, Environment, Schema, SSRRequest, SSRRscData, SSRUser } from '@plitzi/sdk-shared';
|
|
2
|
+
import { FlagOverrides } from '@plitzi/sdk-shared/flags';
|
|
2
3
|
/** Everything an element resolver needs to turn one `runtime: 'server'` element into its data slice. */
|
|
3
4
|
export type RscResolveContext = {
|
|
4
5
|
element: Element;
|
|
@@ -2,7 +2,7 @@ import { serverLog } from "../../helpers/serverLog.js";
|
|
|
2
2
|
import onAbort from "../../helpers/onAbort.js";
|
|
3
3
|
import { matchRscPage } from "./matchRscPage.js";
|
|
4
4
|
import { flagUserFromSSR, flagValues, resolveFlags } from "@plitzi/sdk-shared/flags";
|
|
5
|
-
import { collectServerElements } from "@plitzi/sdk-shared/schema
|
|
5
|
+
import { collectServerElements } from "@plitzi/sdk-shared/schema";
|
|
6
6
|
//#region src/modules/rsc/resolveRscData.ts
|
|
7
7
|
var DEFAULT_ELEMENT_TIMEOUT_MS = 5e3;
|
|
8
8
|
/**
|
|
@@ -8,7 +8,7 @@ import { ssrPaintedCookieName } from "../../helpers/paintedCookie.js";
|
|
|
8
8
|
import { readCookie } from "../../helpers/readCookie.js";
|
|
9
9
|
import { buildOfflineDataCacheKey } from "../../helpers/cache/keys.js";
|
|
10
10
|
import { loadPluginComponents } from "./loadPluginComponents.js";
|
|
11
|
-
import "../../core/previewToken.js";
|
|
11
|
+
import { readDraftToken } from "../../core/previewToken.js";
|
|
12
12
|
import { resolveActionEndpoint, resolveRscEndpoint } from "../../core/services/resolve.js";
|
|
13
13
|
import { createOfflineDataLoader } from "../../helpers/offlineDataLoader.js";
|
|
14
14
|
import { hydrationPayload, spaceDocument } from "../../helpers/hydrationPayload.js";
|
|
@@ -21,13 +21,12 @@ import { sdkAssetVersion } from "../../core/sdkAssets.js";
|
|
|
21
21
|
import { buildServerInfo } from "../../helpers/buildServerInfo.js";
|
|
22
22
|
import { resolveDebugMode } from "../../helpers/resolveDebugMode.js";
|
|
23
23
|
import { flagUserFromSSR, flagValues, resolveFlags } from "@plitzi/sdk-shared/flags";
|
|
24
|
-
import { collectServerElements, notFoundProvider, pageNotFound, pageServerContext } from "@plitzi/sdk-shared/schema
|
|
24
|
+
import { collectServerElements, notFoundProvider, pageElementTypes, pageNotFound, pageServerContext } from "@plitzi/sdk-shared/schema";
|
|
25
25
|
import { debugCookieName } from "@plitzi/sdk-shared/devTools";
|
|
26
|
-
import { themeFromCookies } from "@plitzi/sdk-shared/theme";
|
|
27
|
-
import { paintedKeys, paintedStateFor } from "@plitzi/sdk-shared/state
|
|
26
|
+
import { themeFromCookies } from "@plitzi/sdk-shared/theme/cookie";
|
|
27
|
+
import { paintedKeys, paintedStateFor } from "@plitzi/sdk-shared/state";
|
|
28
28
|
import { fontUrlResolver, fontsToHead } from "@plitzi/sdk-shared/style";
|
|
29
|
-
import { pluginDeclarationOf, pluginTypesOf } from "@plitzi/sdk-shared/plugins
|
|
30
|
-
import { pageElementTypes } from "@plitzi/sdk-shared/schema/pageElements";
|
|
29
|
+
import { pluginDeclarationOf, pluginTypesOf } from "@plitzi/sdk-shared/plugins";
|
|
31
30
|
//#region src/modules/ssr/prepareRender.tsx
|
|
32
31
|
/** Last resort only: used for a page that declares no SEO title and a deployment that supplies none either. */
|
|
33
32
|
var DEFAULT_TITLE = "Plitzi App";
|
|
@@ -286,7 +285,9 @@ var prepareRender = async (req, config, spaceId, environment, revision, pluginMa
|
|
|
286
285
|
plugins: templatePlugins,
|
|
287
286
|
debugMode: debugAuthorized,
|
|
288
287
|
ssrOnly: config.ssrOnly === true,
|
|
289
|
-
|
|
288
|
+
livePages: config.livePages === true,
|
|
289
|
+
hotPlugins: config.livePages === true && config.devMode === true,
|
|
290
|
+
...config.livePages === true && offlineDataOverride !== void 0 ? { liveDraft: readDraftToken(req) } : {},
|
|
290
291
|
offlineData: offlineDataStr
|
|
291
292
|
},
|
|
292
293
|
cacheable: actionRuns === void 0 && forcedFlags === void 0,
|
|
@@ -205,11 +205,19 @@
|
|
|
205
205
|
|
|
206
206
|
__plitziParams.offlineData = await response.json();
|
|
207
207
|
}
|
|
208
|
-
<% if (locals.
|
|
209
|
-
const __plitziApp = render('plitzi', __plitziParams, __plitziPlugins, <%= locals.debugMode ? true : false %>, true, { hotPlugins: true });
|
|
208
|
+
<% if (locals.livePages) { %>
|
|
209
|
+
const __plitziApp = render('plitzi', __plitziParams, __plitziPlugins, <%= locals.debugMode ? true : false %>, true, { hotPlugins: <%= locals.hotPlugins ? true : false %> });
|
|
210
|
+
// New documents for the space this page shows: swapped where it stands, its state kept. A page that cannot take
|
|
211
|
+
// them in place (one with elements the server draws) loads again.
|
|
212
|
+
window.__plitziLiveEvents?.addEventListener('space', event => {
|
|
213
|
+
const { documents } = JSON.parse(event.data);
|
|
214
|
+
if (!__plitziApp?.replaceSpace(documents)) {
|
|
215
|
+
location.reload();
|
|
216
|
+
}
|
|
217
|
+
});
|
|
210
218
|
// A plugin the server built again: its new bundle swapped in where it is drawn and its stylesheet pointed at the
|
|
211
219
|
// new one — the rest of the page stays as it is. One that cannot be swapped in place loads the page again.
|
|
212
|
-
window.
|
|
220
|
+
window.__plitziLiveEvents?.addEventListener('plugin', async event => {
|
|
213
221
|
const { key, js, css } = JSON.parse(event.data);
|
|
214
222
|
const sheet = css && [...document.querySelectorAll('link[data-plitzi-plugin]')].find(link => link.dataset.plitziPlugin === key);
|
|
215
223
|
if (sheet) {
|
|
@@ -230,14 +238,15 @@
|
|
|
230
238
|
<% } %>
|
|
231
239
|
</script>
|
|
232
240
|
<% } %>
|
|
233
|
-
<% if (locals.
|
|
234
|
-
<%#
|
|
235
|
-
|
|
241
|
+
<% if (locals.livePages) { %>
|
|
242
|
+
<%# Only with `livePages`: the server says what changed under the page — everything (`reloadPages`), and the page
|
|
243
|
+
loads again, as does a page that reconnects to a server that restarted (a different `boot`): its code changed
|
|
244
|
+
under it. A draft listens for its own changes alone, by its token. %>
|
|
236
245
|
<script>
|
|
237
246
|
(() => {
|
|
238
|
-
const events = new EventSource('/__plitzi/
|
|
239
|
-
// The page's module script listens here too, for a plugin built again (`plugin`).
|
|
240
|
-
window.
|
|
247
|
+
const events = new EventSource(<%- JSON.stringify(locals.liveDraft ? `/__plitzi/live?__pt=${encodeURIComponent(locals.liveDraft)}` : '/__plitzi/live').replace(/</g, '\\u003c') %>);
|
|
248
|
+
// The page's module script listens here too, for its space (`space`) and a plugin built again (`plugin`).
|
|
249
|
+
window.__plitziLiveEvents = events;
|
|
241
250
|
let boot;
|
|
242
251
|
events.addEventListener('hello', event => {
|
|
243
252
|
const next = JSON.parse(event.data).boot;
|
package/dist/plugins/compile.js
CHANGED
|
@@ -3,7 +3,7 @@ import fs from "node:fs/promises";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import esbuild from "esbuild";
|
|
5
5
|
import { pluginAssetLoaders, pluginImportQueries } from "@plitzi/sdk-shared/plugins/bundle";
|
|
6
|
-
import { inPluginLayer } from "@plitzi/sdk-shared/style
|
|
6
|
+
import { inPluginLayer } from "@plitzi/sdk-shared/style";
|
|
7
7
|
//#region src/plugins/compile.ts
|
|
8
8
|
var EXTERNAL = [
|
|
9
9
|
"react",
|
package/dist/plugins/copy.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { copyFileAtomic, writeFileAtomic } from "../helpers/atomicFile.js";
|
|
2
2
|
import fs from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import { inPluginLayer } from "@plitzi/sdk-shared/style
|
|
4
|
+
import { inPluginLayer } from "@plitzi/sdk-shared/style";
|
|
5
5
|
//#region src/plugins/copy.ts
|
|
6
6
|
var copyPlugin = async (src, destDir, filename) => {
|
|
7
7
|
const dest = path.join(destDir, filename);
|
package/dist/plugins/watch.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PluginManager } from './manager';
|
|
2
2
|
/**
|
|
3
3
|
* Calls `onChange(key)` when a file a built plugin was built from changes: what a development server rebuilds and
|
|
4
|
-
* hands to the open pages (`
|
|
4
|
+
* hands to the open pages (`livePages`), without restarting the process that serves them.
|
|
5
5
|
*
|
|
6
6
|
* The FOLDERS are watched, not the files. An editor that saves through a temporary file renames it over the old one,
|
|
7
7
|
* and a watcher on the old file hears nothing after the first save. Which files matter comes from the build itself
|
package/dist/plugins/watch.js
CHANGED
|
@@ -5,7 +5,7 @@ import { watch } from "node:fs";
|
|
|
5
5
|
var SETTLE_MS = 80;
|
|
6
6
|
/**
|
|
7
7
|
* Calls `onChange(key)` when a file a built plugin was built from changes: what a development server rebuilds and
|
|
8
|
-
* hands to the open pages (`
|
|
8
|
+
* hands to the open pages (`livePages`), without restarting the process that serves them.
|
|
9
9
|
*
|
|
10
10
|
* The FOLDERS are watched, not the files. An editor that saves through a temporary file renames it over the old one,
|
|
11
11
|
* and a watcher on the old file hears nothing after the first save. Which files matter comes from the build itself
|
package/dist/project.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The server of a project `@plitzi/cli` writes: its `src/main.ts` hands `serveProject` the space, its actions and its
|
|
3
3
|
* options, and the rest — the port, the plugins, the functions, the runtime, the files, the reloads while developing —
|
|
4
|
-
* comes from where the project keeps each part (`@plitzi/sdk-shared/project
|
|
4
|
+
* comes from where the project keeps each part (`@plitzi/sdk-shared/project`). A fix to it arrives with the
|
|
5
5
|
* package, never as a file to upgrade.
|
|
6
6
|
*/
|
|
7
|
-
export { serveProject } from './
|
|
8
|
-
export type { ProjectServerOptions, ProjectSpace, ServedProject, ServeProjectOptions } from './
|
|
9
|
-
export type { AuthoredDocuments } from './
|
|
7
|
+
export { serveProject } from './hosts/project/serveProject';
|
|
8
|
+
export type { ProjectServerOptions, ProjectSpace, ServedProject, ServeProjectOptions } from './hosts/project/serveProject';
|
|
9
|
+
export type { AuthoredDocuments } from './hosts/project/watchSpace';
|
package/dist/project.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { serveProject };
|
|
1
|
+
export { serveProject } from "./hosts/project/serveProject.js";
|
package/dist/sqlite.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { createSqliteKv };
|
|
1
|
+
export { createSqliteKv } from "./modules/sqlite/kv.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plitzi/sdk-server",
|
|
3
|
-
"version": "0.38.
|
|
3
|
+
"version": "0.38.18",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -11,76 +11,91 @@
|
|
|
11
11
|
"types": "dist/index.d.ts",
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
14
|
+
"@plitzi/source": "./src/index.ts",
|
|
14
15
|
"types": "./dist/index.d.ts",
|
|
15
16
|
"import": "./dist/index.js",
|
|
16
17
|
"default": "./dist/index.js"
|
|
17
18
|
},
|
|
18
19
|
"./auth": {
|
|
20
|
+
"@plitzi/source": "./src/auth.ts",
|
|
19
21
|
"types": "./dist/auth.d.ts",
|
|
20
22
|
"import": "./dist/auth.js",
|
|
21
23
|
"default": "./dist/auth.js"
|
|
22
24
|
},
|
|
23
25
|
"./oauth": {
|
|
26
|
+
"@plitzi/source": "./src/oauth.ts",
|
|
24
27
|
"types": "./dist/oauth.d.ts",
|
|
25
28
|
"import": "./dist/oauth.js",
|
|
26
29
|
"default": "./dist/oauth.js"
|
|
27
30
|
},
|
|
28
31
|
"./kernel": {
|
|
32
|
+
"@plitzi/source": "./src/kernel.ts",
|
|
29
33
|
"types": "./dist/kernel.d.ts",
|
|
30
34
|
"import": "./dist/kernel.js",
|
|
31
35
|
"default": "./dist/kernel.js"
|
|
32
36
|
},
|
|
33
37
|
"./mysql": {
|
|
38
|
+
"@plitzi/source": "./src/mysql.ts",
|
|
34
39
|
"types": "./dist/mysql.d.ts",
|
|
35
40
|
"import": "./dist/mysql.js",
|
|
36
41
|
"default": "./dist/mysql.js"
|
|
37
42
|
},
|
|
38
43
|
"./mongo": {
|
|
44
|
+
"@plitzi/source": "./src/mongo.ts",
|
|
39
45
|
"types": "./dist/mongo.d.ts",
|
|
40
46
|
"import": "./dist/mongo.js",
|
|
41
47
|
"default": "./dist/mongo.js"
|
|
42
48
|
},
|
|
43
49
|
"./sqlite": {
|
|
50
|
+
"@plitzi/source": "./src/sqlite.ts",
|
|
44
51
|
"types": "./dist/sqlite.d.ts",
|
|
45
52
|
"import": "./dist/sqlite.js",
|
|
46
53
|
"default": "./dist/sqlite.js"
|
|
47
54
|
},
|
|
48
55
|
"./handlers": {
|
|
56
|
+
"@plitzi/source": "./src/handlers.ts",
|
|
49
57
|
"types": "./dist/handlers.d.ts",
|
|
50
58
|
"import": "./dist/handlers.js",
|
|
51
59
|
"default": "./dist/handlers.js"
|
|
52
60
|
},
|
|
53
61
|
"./ssr": {
|
|
62
|
+
"@plitzi/source": "./src/ssr.ts",
|
|
54
63
|
"types": "./dist/ssr.d.ts",
|
|
55
64
|
"import": "./dist/ssr.js",
|
|
56
65
|
"default": "./dist/ssr.js"
|
|
57
66
|
},
|
|
58
67
|
"./actions": {
|
|
68
|
+
"@plitzi/source": "./src/actions.ts",
|
|
59
69
|
"types": "./dist/actions.d.ts",
|
|
60
70
|
"import": "./dist/actions.js",
|
|
61
71
|
"default": "./dist/actions.js"
|
|
62
72
|
},
|
|
63
73
|
"./functions": {
|
|
74
|
+
"@plitzi/source": "./src/functions.ts",
|
|
64
75
|
"types": "./dist/functions.d.ts",
|
|
65
76
|
"import": "./dist/functions.js",
|
|
66
77
|
"default": "./dist/functions.js"
|
|
67
78
|
},
|
|
68
79
|
"./functions-runner": {
|
|
80
|
+
"@plitzi/source": "./src/functionsRunner.ts",
|
|
69
81
|
"types": "./dist/functionsRunner.d.ts",
|
|
70
82
|
"import": "./dist/functionsRunner.js",
|
|
71
83
|
"default": "./dist/functionsRunner.js"
|
|
72
84
|
},
|
|
73
85
|
"./runtime": {
|
|
86
|
+
"@plitzi/source": "./src/runtime.ts",
|
|
74
87
|
"types": "./dist/runtime.d.ts",
|
|
75
88
|
"import": "./dist/runtime.js",
|
|
76
89
|
"default": "./dist/runtime.js"
|
|
77
90
|
},
|
|
78
91
|
"./project": {
|
|
92
|
+
"@plitzi/source": "./src/project.ts",
|
|
79
93
|
"types": "./dist/project.d.ts",
|
|
80
94
|
"import": "./dist/project.js",
|
|
81
95
|
"default": "./dist/project.js"
|
|
82
96
|
},
|
|
83
97
|
"./env": {
|
|
98
|
+
"@plitzi/source": "./src/env.ts",
|
|
84
99
|
"types": "./dist/env.d.ts",
|
|
85
100
|
"import": "./dist/env.js",
|
|
86
101
|
"default": "./dist/env.js"
|
|
@@ -96,13 +111,13 @@
|
|
|
96
111
|
"./dist/env.js"
|
|
97
112
|
],
|
|
98
113
|
"dependencies": {
|
|
99
|
-
"@plitzi/plitzi-sdk": "0.38.
|
|
100
|
-
"@plitzi/sdk-shared": "0.38.
|
|
101
|
-
"ejs": "^
|
|
114
|
+
"@plitzi/plitzi-sdk": "0.38.18",
|
|
115
|
+
"@plitzi/sdk-shared": "0.38.18",
|
|
116
|
+
"ejs": "^7.0.1",
|
|
102
117
|
"esbuild": "^0.28.2",
|
|
103
118
|
"jsonwebtoken": "^9.0.3",
|
|
104
|
-
"nodemailer": "^10.
|
|
105
|
-
"undici": "^8.
|
|
119
|
+
"nodemailer": "^10.1.2",
|
|
120
|
+
"undici": "^8.12.2",
|
|
106
121
|
"ws": "^8.22.0"
|
|
107
122
|
},
|
|
108
123
|
"peerDependencies": {
|
|
@@ -132,30 +147,30 @@
|
|
|
132
147
|
}
|
|
133
148
|
},
|
|
134
149
|
"devDependencies": {
|
|
135
|
-
"@microsoft/api-extractor": "^7.59.
|
|
150
|
+
"@microsoft/api-extractor": "^7.59.4",
|
|
136
151
|
"@types/ejs": "^3.1.5",
|
|
137
152
|
"@types/jsonwebtoken": "^9.0.10",
|
|
138
|
-
"@types/node": "^26.6.
|
|
153
|
+
"@types/node": "^26.6.5",
|
|
139
154
|
"@types/nodemailer": "^8.0.2",
|
|
140
155
|
"@types/react": "^19.3.0",
|
|
141
156
|
"@types/ws": "^8.18.2",
|
|
142
|
-
"@vitejs/plugin-react": "^6.1.
|
|
143
|
-
"@vitest/coverage-v8": "^5.0.
|
|
157
|
+
"@vitejs/plugin-react": "^6.1.2",
|
|
158
|
+
"@vitest/coverage-v8": "^5.0.5",
|
|
144
159
|
"core-js": "^3.50.0",
|
|
145
160
|
"eslint": "^9.39.5",
|
|
146
161
|
"eslint-plugin-import": "^2.32.0",
|
|
147
162
|
"ioredis": "^6.0.0",
|
|
148
163
|
"isolated-vm": "^7.0.1",
|
|
149
164
|
"mongodb": "^7.7.0",
|
|
150
|
-
"mysql2": "^3.24.
|
|
151
|
-
"react": "^19.3.
|
|
152
|
-
"react-dom": "^19.3.
|
|
165
|
+
"mysql2": "^3.24.6",
|
|
166
|
+
"react": "^19.3.1",
|
|
167
|
+
"react-dom": "^19.3.1",
|
|
153
168
|
"sharp": "^0.35.5",
|
|
154
169
|
"tsx": "^4.23.15",
|
|
155
170
|
"typescript": "^6.0.3",
|
|
156
|
-
"vite": "^8.3.
|
|
171
|
+
"vite": "^8.3.4",
|
|
157
172
|
"vite-plugin-dts": "^5.1.2",
|
|
158
|
-
"vitest": "^5.0.
|
|
173
|
+
"vitest": "^5.0.5"
|
|
159
174
|
},
|
|
160
175
|
"scripts": {
|
|
161
176
|
"prepack": "node scripts/copy-authoring-skill.mjs",
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Stage } from '../types';
|
|
2
|
-
import { PluginEntry } from '@plitzi/sdk-shared';
|
|
3
|
-
/** Where an open page listens for "the space changed: load again", in development. */
|
|
4
|
-
export declare const DEV_RELOAD_PATH = "/__plitzi/reload";
|
|
5
|
-
/**
|
|
6
|
-
* The page reloading itself when the space it shows changed — the edit loop of a project that authors its space in
|
|
7
|
-
* code, without restarting the server: `serveProject` re-authors in a process of its own, swaps the documents and calls
|
|
8
|
-
* `reloadPages()`, and every page open on this server loads again.
|
|
9
|
-
*
|
|
10
|
-
* Only with `devReload` on: every open page keeps a connection for it, which a server that never calls `reloadPages`
|
|
11
|
-
* — a published one, or a platform's — would pay for and get nothing from. The template listens only then too.
|
|
12
|
-
*
|
|
13
|
-
* Each connection is greeted with this process's `boot`, and a page that reconnects to a different one loads again: the
|
|
14
|
-
* server restarted — `start:dev` saw its code change (`main.ts`, its options, its actions, `src/functions/`) — and
|
|
15
|
-
* what is on screen was built by the one before. Without it the page kept the old plugin until somebody reloaded it,
|
|
16
|
-
* which reads as "my change did nothing".
|
|
17
|
-
*/
|
|
18
|
-
export declare const createDevReload: () => {
|
|
19
|
-
stage: Stage;
|
|
20
|
-
/** Every page open on this server loads again. */
|
|
21
|
-
reload: () => void;
|
|
22
|
-
/**
|
|
23
|
-
* A plugin built again: every open page imports its new bundle and swaps it where it is drawn (`keyName` is what
|
|
24
|
-
* the page registered it as), and points its stylesheet at the new one — without loading again.
|
|
25
|
-
*/
|
|
26
|
-
plugin: ({ keyName, js, css }: PluginEntry) => void;
|
|
27
|
-
/** The streams ended — the server is going away, and each page reconnects to whichever comes up next. */
|
|
28
|
-
close: () => void;
|
|
29
|
-
};
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { openEventStream } from "../sse.js";
|
|
2
|
-
import { randomUUID } from "node:crypto";
|
|
3
|
-
//#region src/core/http/stages/devReload.ts
|
|
4
|
-
/** Where an open page listens for "the space changed: load again", in development. */
|
|
5
|
-
var DEV_RELOAD_PATH = "/__plitzi/reload";
|
|
6
|
-
/**
|
|
7
|
-
* The page reloading itself when the space it shows changed — the edit loop of a project that authors its space in
|
|
8
|
-
* code, without restarting the server: `serveProject` re-authors in a process of its own, swaps the documents and calls
|
|
9
|
-
* `reloadPages()`, and every page open on this server loads again.
|
|
10
|
-
*
|
|
11
|
-
* Only with `devReload` on: every open page keeps a connection for it, which a server that never calls `reloadPages`
|
|
12
|
-
* — a published one, or a platform's — would pay for and get nothing from. The template listens only then too.
|
|
13
|
-
*
|
|
14
|
-
* Each connection is greeted with this process's `boot`, and a page that reconnects to a different one loads again: the
|
|
15
|
-
* server restarted — `start:dev` saw its code change (`main.ts`, its options, its actions, `src/functions/`) — and
|
|
16
|
-
* what is on screen was built by the one before. Without it the page kept the old plugin until somebody reloaded it,
|
|
17
|
-
* which reads as "my change did nothing".
|
|
18
|
-
*/
|
|
19
|
-
var createDevReload = () => {
|
|
20
|
-
const listening = /* @__PURE__ */ new Set();
|
|
21
|
-
const boot = randomUUID();
|
|
22
|
-
const stage = (ctx) => {
|
|
23
|
-
if (!ctx.config.devReload || ctx.req.path !== "/__plitzi/reload") return Promise.resolve(false);
|
|
24
|
-
const stream = openEventStream(ctx.rawRes, {
|
|
25
|
-
onAbort: () => listening.delete(stream),
|
|
26
|
-
retryMs: 1e3
|
|
27
|
-
});
|
|
28
|
-
listening.add(stream);
|
|
29
|
-
stream.send("hello", { boot });
|
|
30
|
-
ctx.raw.once("close", () => {
|
|
31
|
-
listening.delete(stream);
|
|
32
|
-
stream.close();
|
|
33
|
-
});
|
|
34
|
-
return Promise.resolve(true);
|
|
35
|
-
};
|
|
36
|
-
return {
|
|
37
|
-
stage,
|
|
38
|
-
/** Every page open on this server loads again. */
|
|
39
|
-
reload: () => listening.forEach((stream) => stream.send("reload", {})),
|
|
40
|
-
/**
|
|
41
|
-
* A plugin built again: every open page imports its new bundle and swaps it where it is drawn (`keyName` is what
|
|
42
|
-
* the page registered it as), and points its stylesheet at the new one — without loading again.
|
|
43
|
-
*/
|
|
44
|
-
plugin: ({ keyName, js, css }) => listening.forEach((stream) => stream.send("plugin", {
|
|
45
|
-
key: keyName,
|
|
46
|
-
js,
|
|
47
|
-
css
|
|
48
|
-
})),
|
|
49
|
-
/** The streams ended — the server is going away, and each page reconnects to whichever comes up next. */
|
|
50
|
-
close: () => {
|
|
51
|
-
listening.forEach((stream) => stream.close());
|
|
52
|
-
listening.clear();
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
//#endregion
|
|
57
|
-
export { DEV_RELOAD_PATH, createDevReload };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|