elit 3.6.4 → 3.6.6

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 (52) hide show
  1. package/Cargo.lock +1 -1
  2. package/Cargo.toml +1 -1
  3. package/README.md +14 -1
  4. package/dist/build.d.ts +4 -1
  5. package/dist/cli.cjs +746 -166
  6. package/dist/cli.mjs +746 -166
  7. package/dist/config.d.ts +8 -1
  8. package/dist/coverage.d.ts +4 -1
  9. package/dist/desktop-auto-render.cjs +5 -4
  10. package/dist/desktop-auto-render.d.ts +4 -1
  11. package/dist/desktop-auto-render.js +5 -4
  12. package/dist/desktop-auto-render.mjs +5 -4
  13. package/dist/dom.cjs +5 -4
  14. package/dist/dom.d.ts +2 -0
  15. package/dist/dom.js +5 -4
  16. package/dist/dom.mjs +5 -4
  17. package/dist/el.d.ts +2 -0
  18. package/dist/index.cjs +5 -4
  19. package/dist/index.d.ts +2 -0
  20. package/dist/index.js +5 -4
  21. package/dist/index.mjs +5 -4
  22. package/dist/native.cjs +5 -4
  23. package/dist/native.d.ts +2 -0
  24. package/dist/native.js +5 -4
  25. package/dist/native.mjs +5 -4
  26. package/dist/render-context.d.ts +4 -1
  27. package/dist/router.cjs +5 -4
  28. package/dist/router.d.ts +2 -0
  29. package/dist/router.js +5 -4
  30. package/dist/router.mjs +5 -4
  31. package/dist/{server-CcBFc2F5.d.ts → server-uMQvZAll.d.ts} +9 -0
  32. package/dist/server.cjs +146 -4
  33. package/dist/server.d.ts +4 -1
  34. package/dist/server.js +4494 -285
  35. package/dist/server.mjs +146 -4
  36. package/dist/smtp-server.cjs +115 -0
  37. package/dist/smtp-server.d.ts +41 -0
  38. package/dist/smtp-server.js +4186 -0
  39. package/dist/smtp-server.mjs +87 -0
  40. package/dist/state.cjs +5 -4
  41. package/dist/state.d.ts +2 -0
  42. package/dist/state.js +5 -4
  43. package/dist/state.mjs +5 -4
  44. package/dist/test-runtime.cjs +184 -141
  45. package/dist/test-runtime.js +193 -150
  46. package/dist/test-runtime.mjs +184 -141
  47. package/dist/test.cjs +143 -134
  48. package/dist/test.js +152 -143
  49. package/dist/test.mjs +143 -134
  50. package/dist/types.d.ts +34 -2
  51. package/dist/universal.d.ts +2 -0
  52. package/package.json +9 -1
package/dist/server.mjs CHANGED
@@ -55625,6 +55625,71 @@ function lookup(path) {
55625
55625
  // src/server.ts
55626
55626
  init_runtime();
55627
55627
 
55628
+ // src/smtp-server.ts
55629
+ import { SMTPServer } from "smtp-server";
55630
+ var DEFAULT_SMTP_PORT = 2525;
55631
+ var DEFAULT_SMTP_HOST = "127.0.0.1";
55632
+ function resolveSmtpServerConfig(config = {}) {
55633
+ const { port = DEFAULT_SMTP_PORT, host = DEFAULT_SMTP_HOST, label, ...serverOptions } = config;
55634
+ return {
55635
+ ...serverOptions,
55636
+ port,
55637
+ host,
55638
+ label
55639
+ };
55640
+ }
55641
+ function normalizeSmtpServerConfigs(input) {
55642
+ const configs = Array.isArray(input) ? input : input ? [input] : [];
55643
+ return configs.map((config) => resolveSmtpServerConfig(config));
55644
+ }
55645
+ function closeSmtpServer(server) {
55646
+ return new Promise((resolve2, reject) => {
55647
+ let settled = false;
55648
+ const finish = (error) => {
55649
+ if (settled) {
55650
+ return;
55651
+ }
55652
+ settled = true;
55653
+ if (error) {
55654
+ reject(error);
55655
+ return;
55656
+ }
55657
+ resolve2();
55658
+ };
55659
+ const handleCloseError = (error) => {
55660
+ const errorCode = error.code;
55661
+ if (errorCode === "ERR_SERVER_NOT_RUNNING") {
55662
+ finish();
55663
+ return;
55664
+ }
55665
+ finish(error);
55666
+ };
55667
+ try {
55668
+ server.close(() => finish());
55669
+ } catch (error) {
55670
+ handleCloseError(error);
55671
+ }
55672
+ });
55673
+ }
55674
+ function createSmtpServer(config = {}) {
55675
+ const resolvedConfig = resolveSmtpServerConfig(config);
55676
+ const { port, host, label: _label, ...serverOptions } = resolvedConfig;
55677
+ const server = new SMTPServer(serverOptions);
55678
+ return {
55679
+ server,
55680
+ config: resolvedConfig,
55681
+ listen(callback) {
55682
+ return callback ? server.listen(port, host, callback) : server.listen(port, host);
55683
+ },
55684
+ address() {
55685
+ return server.server.address();
55686
+ },
55687
+ close() {
55688
+ return closeSmtpServer(server);
55689
+ }
55690
+ };
55691
+ }
55692
+
55628
55693
  // src/render-context.ts
55629
55694
  var RUNTIME_TARGET_KEY = "__ELIT_RUNTIME_TARGET__";
55630
55695
  var CAPTURED_RENDER_KEY = "__ELIT_CAPTURED_RENDER__";
@@ -56051,6 +56116,7 @@ var DomNode = class {
56051
56116
  html2 += `</${tagName}>${newLine}`;
56052
56117
  return html2;
56053
56118
  }
56119
+ const isRawText = tagName === "script" || tagName === "style";
56054
56120
  if (children && children.length > 0) {
56055
56121
  const resolvedChildren = children.map((c) => {
56056
56122
  const resolved = this.resolveStateValue(c);
@@ -56066,11 +56132,11 @@ var DomNode = class {
56066
56132
  if (Array.isArray(child)) {
56067
56133
  for (const c of child) {
56068
56134
  if (!shouldSkipChild(c)) {
56069
- html2 += this.renderToString(c, { pretty, indent: indent + 1 });
56135
+ html2 += isRawText && typeof c === "string" ? c : this.renderToString(c, { pretty, indent: indent + 1 });
56070
56136
  }
56071
56137
  }
56072
56138
  } else {
56073
- html2 += this.renderToString(child, { pretty, indent: indent + 1 });
56139
+ html2 += isRawText && typeof child === "string" ? child : this.renderToString(child, { pretty, indent: indent + 1 });
56074
56140
  }
56075
56141
  }
56076
56142
  html2 += indentStr;
@@ -56080,11 +56146,11 @@ var DomNode = class {
56080
56146
  if (Array.isArray(child)) {
56081
56147
  for (const c of child) {
56082
56148
  if (!shouldSkipChild(c)) {
56083
- html2 += this.renderToString(c, { pretty: false, indent: 0 });
56149
+ html2 += isRawText && typeof c === "string" ? c : this.renderToString(c, { pretty: false, indent: 0 });
56084
56150
  }
56085
56151
  }
56086
56152
  } else {
56087
- html2 += this.renderToString(child, { pretty: false, indent: 0 });
56153
+ html2 += isRawText && typeof child === "string" ? child : this.renderToString(child, { pretty: false, indent: 0 });
56088
56154
  }
56089
56155
  }
56090
56156
  }
@@ -57365,6 +57431,56 @@ var defaultOptions = {
57365
57431
  worker: [],
57366
57432
  mode: "dev"
57367
57433
  };
57434
+ function createSmtpBindingKey(config) {
57435
+ return `${config.host}:${config.port}`;
57436
+ }
57437
+ function createSmtpServerLabel(config) {
57438
+ return config.label || createSmtpBindingKey(config);
57439
+ }
57440
+ function formatSmtpServerAddress(address, fallback) {
57441
+ if (typeof address === "string") {
57442
+ return address;
57443
+ }
57444
+ if (address) {
57445
+ return `${address.address}:${address.port}`;
57446
+ }
57447
+ return createSmtpBindingKey(fallback);
57448
+ }
57449
+ function collectSmtpServerConfigs(config, usesClientArray) {
57450
+ const modeLabel = config.mode || "dev";
57451
+ const smtpConfigs = normalizeSmtpServerConfigs(config.smtp).map((smtpConfig, index) => ({
57452
+ ...smtpConfig,
57453
+ label: smtpConfig.label || `${modeLabel}.smtp[${index}]`
57454
+ }));
57455
+ if (!usesClientArray || !config.clients) {
57456
+ return smtpConfigs;
57457
+ }
57458
+ for (let clientIndex = 0; clientIndex < config.clients.length; clientIndex += 1) {
57459
+ const client = config.clients[clientIndex];
57460
+ const clientDescriptor = client.basePath || client.root;
57461
+ const clientPrefix = clientDescriptor ? `${modeLabel}.clients[${clientIndex}] (${clientDescriptor})` : `${modeLabel}.clients[${clientIndex}]`;
57462
+ smtpConfigs.push(...normalizeSmtpServerConfigs(client.smtp).map((smtpConfig, smtpIndex) => ({
57463
+ ...smtpConfig,
57464
+ label: smtpConfig.label || `${clientPrefix}.smtp[${smtpIndex}]`
57465
+ })));
57466
+ }
57467
+ return smtpConfigs;
57468
+ }
57469
+ function assertUniqueSmtpServerBindings(configs) {
57470
+ const seenBindings = /* @__PURE__ */ new Map();
57471
+ for (const smtpConfig of configs) {
57472
+ if (smtpConfig.port === 0) {
57473
+ continue;
57474
+ }
57475
+ const bindingKey = createSmtpBindingKey(smtpConfig);
57476
+ const currentLabel = createSmtpServerLabel(smtpConfig);
57477
+ const previousLabel = seenBindings.get(bindingKey);
57478
+ if (previousLabel) {
57479
+ throw new Error(`Duplicate SMTP server binding "${bindingKey}" configured for ${previousLabel} and ${currentLabel}`);
57480
+ }
57481
+ seenBindings.set(bindingKey, currentLabel);
57482
+ }
57483
+ }
57368
57484
  function shouldUseClientFallbackRoot(primaryRoot, fallbackRoot, indexPath) {
57369
57485
  if (!fallbackRoot) {
57370
57486
  return false;
@@ -57499,6 +57615,7 @@ function createDevServer(options) {
57499
57615
  const globalWebSocketEndpoints = usesClientArray ? normalizeWebSocketEndpoints(config.ws) : [];
57500
57616
  const normalizedWebSocketEndpoints = [...normalizedClients.flatMap((client) => client.ws), ...globalWebSocketEndpoints];
57501
57617
  const seenWebSocketPaths = /* @__PURE__ */ new Set();
57618
+ const smtpServerConfigs = collectSmtpServerConfigs(config, usesClientArray);
57502
57619
  for (const endpoint of normalizedWebSocketEndpoints) {
57503
57620
  if (endpoint.path === ELIT_INTERNAL_WS_PATH) {
57504
57621
  throw new Error(`WebSocket path "${ELIT_INTERNAL_WS_PATH}" is reserved for Elit internals`);
@@ -57508,6 +57625,21 @@ function createDevServer(options) {
57508
57625
  }
57509
57626
  seenWebSocketPaths.add(endpoint.path);
57510
57627
  }
57628
+ assertUniqueSmtpServerBindings(smtpServerConfigs);
57629
+ const smtpServers = smtpServerConfigs.map((smtpConfig) => {
57630
+ const smtpServer = createSmtpServer(smtpConfig);
57631
+ const smtpLabel = createSmtpServerLabel(smtpServer.config);
57632
+ smtpServer.server.on("error", (error) => {
57633
+ console.error(`[SMTP] ${smtpLabel} error:`, error);
57634
+ });
57635
+ if (config.logging) {
57636
+ smtpServer.server.server.once("listening", () => {
57637
+ console.log(`[SMTP] ${smtpLabel} listening on ${formatSmtpServerAddress(smtpServer.address(), smtpServer.config)}`);
57638
+ });
57639
+ }
57640
+ smtpServer.listen();
57641
+ return smtpServer;
57642
+ });
57511
57643
  const globalProxyHandler = config.proxy ? createProxyHandler(config.proxy) : null;
57512
57644
  const server = createServer(async (req, res) => {
57513
57645
  const originalUrl = req.url || "/";
@@ -58048,6 +58180,15 @@ ${elitImportMap}`;
58048
58180
  if (config.logging) console.log("\n[Server] Shutting down...");
58049
58181
  transformCache.clear();
58050
58182
  if (watcher) await watcher.close();
58183
+ if (smtpServers.length > 0) {
58184
+ await Promise.all(smtpServers.map(async (smtpServer) => {
58185
+ try {
58186
+ await smtpServer.close();
58187
+ } catch (error) {
58188
+ console.error(`[SMTP] ${createSmtpServerLabel(smtpServer.config)} close error:`, error);
58189
+ }
58190
+ }));
58191
+ }
58051
58192
  if (webSocketServers.length > 0) {
58052
58193
  webSocketServers.forEach((wsServer) => wsServer.close());
58053
58194
  wsClients.clear();
@@ -58064,6 +58205,7 @@ ${elitImportMap}`;
58064
58205
  return {
58065
58206
  server,
58066
58207
  wss,
58208
+ smtpServers,
58067
58209
  url: primaryUrl,
58068
58210
  state: stateManager,
58069
58211
  close
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/smtp-server.ts
21
+ var smtp_server_exports = {};
22
+ __export(smtp_server_exports, {
23
+ DEFAULT_SMTP_HOST: () => DEFAULT_SMTP_HOST,
24
+ DEFAULT_SMTP_PORT: () => DEFAULT_SMTP_PORT,
25
+ createSmtpServer: () => createSmtpServer,
26
+ default: () => smtp_server_default,
27
+ normalizeSmtpServerConfigs: () => normalizeSmtpServerConfigs,
28
+ resolveSmtpServerConfig: () => resolveSmtpServerConfig,
29
+ startSmtpServer: () => startSmtpServer
30
+ });
31
+ module.exports = __toCommonJS(smtp_server_exports);
32
+ var import_smtp_server = require("smtp-server");
33
+ var DEFAULT_SMTP_PORT = 2525;
34
+ var DEFAULT_SMTP_HOST = "127.0.0.1";
35
+ function resolveSmtpServerConfig(config = {}) {
36
+ const { port = DEFAULT_SMTP_PORT, host = DEFAULT_SMTP_HOST, label, ...serverOptions } = config;
37
+ return {
38
+ ...serverOptions,
39
+ port,
40
+ host,
41
+ label
42
+ };
43
+ }
44
+ function normalizeSmtpServerConfigs(input) {
45
+ const configs = Array.isArray(input) ? input : input ? [input] : [];
46
+ return configs.map((config) => resolveSmtpServerConfig(config));
47
+ }
48
+ function closeSmtpServer(server) {
49
+ return new Promise((resolve, reject) => {
50
+ let settled = false;
51
+ const finish = (error) => {
52
+ if (settled) {
53
+ return;
54
+ }
55
+ settled = true;
56
+ if (error) {
57
+ reject(error);
58
+ return;
59
+ }
60
+ resolve();
61
+ };
62
+ const handleCloseError = (error) => {
63
+ const errorCode = error.code;
64
+ if (errorCode === "ERR_SERVER_NOT_RUNNING") {
65
+ finish();
66
+ return;
67
+ }
68
+ finish(error);
69
+ };
70
+ try {
71
+ server.close(() => finish());
72
+ } catch (error) {
73
+ handleCloseError(error);
74
+ }
75
+ });
76
+ }
77
+ function createSmtpServer(config = {}) {
78
+ const resolvedConfig = resolveSmtpServerConfig(config);
79
+ const { port, host, label: _label, ...serverOptions } = resolvedConfig;
80
+ const server = new import_smtp_server.SMTPServer(serverOptions);
81
+ return {
82
+ server,
83
+ config: resolvedConfig,
84
+ listen(callback) {
85
+ return callback ? server.listen(port, host, callback) : server.listen(port, host);
86
+ },
87
+ address() {
88
+ return server.server.address();
89
+ },
90
+ close() {
91
+ return closeSmtpServer(server);
92
+ }
93
+ };
94
+ }
95
+ function startSmtpServer(config = {}) {
96
+ const handle = createSmtpServer(config);
97
+ handle.listen();
98
+ return handle;
99
+ }
100
+ var smtp_server_default = {
101
+ SMTPServer: import_smtp_server.SMTPServer,
102
+ createSmtpServer,
103
+ startSmtpServer,
104
+ DEFAULT_SMTP_HOST,
105
+ DEFAULT_SMTP_PORT
106
+ };
107
+ // Annotate the CommonJS export names for ESM import in node:
108
+ 0 && (module.exports = {
109
+ DEFAULT_SMTP_HOST,
110
+ DEFAULT_SMTP_PORT,
111
+ createSmtpServer,
112
+ normalizeSmtpServerConfigs,
113
+ resolveSmtpServerConfig,
114
+ startSmtpServer
115
+ });
@@ -0,0 +1,41 @@
1
+ import { Server, AddressInfo } from 'net';
2
+ import { SMTPServerOptions, SMTPServer } from 'smtp-server';
3
+ export { SMTPServerAddress, SMTPServerAuthentication, SMTPServerAuthenticationResponse, SMTPServerDataStream, SMTPServerEnvelope, SMTPServerOptions, SMTPServerSession } from 'smtp-server';
4
+
5
+ /**
6
+ * SMTP server helpers built on top of the smtp-server package.
7
+ */
8
+
9
+ declare const DEFAULT_SMTP_PORT = 2525;
10
+ declare const DEFAULT_SMTP_HOST = "127.0.0.1";
11
+ interface ElitSMTPServerConfig extends SMTPServerOptions {
12
+ port?: number;
13
+ host?: string;
14
+ label?: string;
15
+ }
16
+ type ElitSMTPServerInput = ElitSMTPServerConfig | ElitSMTPServerConfig[] | undefined;
17
+ interface ResolvedElitSMTPServerConfig extends SMTPServerOptions {
18
+ port: number;
19
+ host: string;
20
+ label?: string;
21
+ }
22
+ interface ElitSMTPServerHandle {
23
+ server: SMTPServer;
24
+ config: ResolvedElitSMTPServerConfig;
25
+ listen(callback?: () => void): Server;
26
+ address(): AddressInfo | string | null;
27
+ close(): Promise<void>;
28
+ }
29
+ declare function resolveSmtpServerConfig(config?: ElitSMTPServerConfig): ResolvedElitSMTPServerConfig;
30
+ declare function normalizeSmtpServerConfigs(input: ElitSMTPServerInput): ResolvedElitSMTPServerConfig[];
31
+ declare function createSmtpServer(config?: ElitSMTPServerConfig): ElitSMTPServerHandle;
32
+ declare function startSmtpServer(config?: ElitSMTPServerConfig): ElitSMTPServerHandle;
33
+ declare const _default: {
34
+ SMTPServer: typeof SMTPServer;
35
+ createSmtpServer: typeof createSmtpServer;
36
+ startSmtpServer: typeof startSmtpServer;
37
+ DEFAULT_SMTP_HOST: string;
38
+ DEFAULT_SMTP_PORT: number;
39
+ };
40
+
41
+ export { DEFAULT_SMTP_HOST, DEFAULT_SMTP_PORT, type ElitSMTPServerConfig, type ElitSMTPServerHandle, type ElitSMTPServerInput, type ResolvedElitSMTPServerConfig, createSmtpServer, _default as default, normalizeSmtpServerConfigs, resolveSmtpServerConfig, startSmtpServer };