@orieljs/foundation 0.1.0-alpha.1 → 0.1.0-alpha.10

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/NOTICE CHANGED
@@ -7,3 +7,10 @@ This product includes software developed by the Oriel project
7
7
  Oriel is licensed under the Apache License, Version 2.0 (see LICENSE).
8
8
  The Oriel name and logo are not covered by that license; see TRADEMARKS.md
9
9
  (https://github.com/orieljs/framework/blob/main/TRADEMARKS.md).
10
+
11
+ @orieljs/support (and @orieljs/framework, which bundles it) includes transliteration data from
12
+ voku/portable-ascii (https://github.com/voku/portable-ascii), Copyright (C) 2019 Lars Moelleken, MIT License.
13
+
14
+ @orieljs/notifications (and @orieljs/framework, which bundles it) includes the HTML and CSS of
15
+ Laravel's default notification mail (laravel/framework, https://github.com/laravel/framework),
16
+ Copyright (c) Taylor Otwell, MIT License.
package/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # @orieljs/foundation
2
+
3
+ The Oriel application: the container every app runs in, service providers, the boot lifecycle, request handling and the Vite tags. It is Oriel's counterpart of Laravel's foundation. Foundation is part of `@orieljs/framework`, which every Oriel app already installs, and is re-exported from it. In an app, import it from `@orieljs/framework`, whose `Application.configure()` also registers the framework's providers; `@orieljs/foundation` is also published on its own.
4
+
5
+ ```bash
6
+ npm install @orieljs/framework
7
+ ```
8
+
9
+ ```ts title="bootstrap/app.ts"
10
+ import { dirname } from 'node:path'
11
+ import { Application } from '@orieljs/framework'
12
+ import providers from './providers'
13
+
14
+ export function createApplication(): Promise<Application> {
15
+ return Application.configure({ basePath: dirname(import.meta.dirname) })
16
+ .withRouting({ web: 'routes/web.ts', console: 'routes/console.ts', health: '/up' })
17
+ .withMiddleware((middleware) => middleware.redirectGuestsTo('/login'))
18
+ .withProviders(providers)
19
+ .create()
20
+ }
21
+ ```
22
+
23
+ `Application.configure()` returns an `ApplicationBuilder`, whose `withRouting()`, `withMiddleware()`, `withExceptions()`, `withProviders()`, `booting()` and `booted()` set up the app, and `create()` loads `.env` and `config/` and registers the providers. `await app.boot()` boots the providers once, and `await app.handle(request)` boots the app and turns a web `Request` into a `Response`. `vite()` writes the script and style tags for Vite's entry points.
24
+
25
+ Documentation: https://orieljs.vercel.app/docs/lifecycle
26
+
27
+ Status: early alpha. APIs will change.
28
+
29
+ ## License
30
+
31
+ Oriel is open-source software licensed under the Apache License 2.0 (Apache-2.0; see `LICENSE` and `NOTICE`). The Oriel name and logo are trademarks; see `TRADEMARKS.md`.
32
+
33
+ Website: https://orieljs.vercel.app
package/TRADEMARKS.md ADDED
@@ -0,0 +1,33 @@
1
+ # Oriel trademark policy
2
+
3
+ The Oriel code is open source under the Apache License 2.0. The **Oriel name and logo** are not: the license covers
4
+ the code only (section 6 of the license says so), and the name and logo stay with the project. This page explains
5
+ what you can and can't do with them. The goal is simple: people should always be able to tell what is the real Oriel
6
+ and what isn't.
7
+
8
+ ## You can, without asking
9
+
10
+ - Use, change, ship and sell the code, as the license allows.
11
+ - Say that your app or package is "built with Oriel", "for Oriel" or "compatible with Oriel".
12
+ - Name a package `oriel-<something>` or `<something>-for-oriel` when it works with Oriel, as long as it is clear that
13
+ it is not official (for example, don't publish it under the `@orieljs` npm scope).
14
+ - Use the name and logo to write about Oriel, teach it, or link to it, in articles, talks, videos and courses.
15
+ - Use the unmodified logo to point to the project, as it is (no recolouring, cropping or
16
+ distortion).
17
+
18
+ ## You can't, without written permission
19
+
20
+ - Call a fork, a modified copy or a competing product "Oriel", or anything likely to be confused with it.
21
+ - Use the name or logo as the name, logo or domain of your own product, company or service.
22
+ - Suggest that the Oriel project made, endorses or supports your work when it doesn't.
23
+ - Sell merchandise with the name or logo.
24
+
25
+ ## Forks
26
+
27
+ Forks are welcome. Please give yours a different name and logo, keep the `LICENSE` and `NOTICE` files, and say that
28
+ it is based on Oriel.
29
+
30
+ ## Questions
31
+
32
+ Open an issue at https://github.com/orieljs/framework or email meeeet.dev@gmail.com. If you're unsure whether a use
33
+ is fine, ask; the answer is usually yes.
package/dist/index.d.ts CHANGED
@@ -1,9 +1,10 @@
1
- import { ServiceProvider, ServiceProviderClass, MiddlewareConfigurator, ExceptionsConfigurator, Application as Application$1, HttpKernel } from '@orieljs/contracts';
1
+ import { ServiceProvider, ServiceProviderClass, MiddlewareConfigurator, ExceptionsConfigurator, Application as Application$1, HttpKernel, Htmlable, OrielError } from '@orieljs/contracts';
2
2
  import { Container } from '@orieljs/container';
3
3
 
4
4
  interface RoutingOptions {
5
- web?: string;
6
- api?: string;
5
+ /** One route file or several, loaded in order: web: ['routes/web.ts', 'routes/settings.ts', 'routes/auth.ts']. */
6
+ web?: string | string[];
7
+ api?: string | string[];
7
8
  console?: string;
8
9
  /** A URI such as '/up', not a file. */
9
10
  health?: string;
@@ -29,11 +30,13 @@ declare class ApplicationBuilder {
29
30
  type LifecycleCallback = (app: Application$1) => void | Promise<void>;
30
31
  declare class Application extends Container implements Application$1 {
31
32
  private readonly base;
32
- readonly version = "0.1.0-alpha.1";
33
+ readonly version = "0.1.0-alpha.10";
33
34
  private readonly providers;
34
35
  private readonly bootingCallbacks;
35
36
  private readonly bootedCallbacks;
36
37
  private readonly terminatingCallbacks;
38
+ private readonly shutdownCallbacks;
39
+ private shutdownPromise;
37
40
  private bootPromise;
38
41
  private hasBooted;
39
42
  private inConsole;
@@ -67,6 +70,20 @@ declare class Application extends Container implements Application$1 {
67
70
  terminating(callback: () => void | Promise<void>): void;
68
71
  handle(request: Request): Promise<Response>;
69
72
  terminate(): Promise<void>;
73
+ /**
74
+ * A callback for the end of the process (the CLI after its command, the server on SIGTERM): close DB pools, Redis
75
+ * clients and log files. Not in Laravel, whose PHP processes end with each request.
76
+ */
77
+ onShutdown(callback: () => void | Promise<void>): void;
78
+ /**
79
+ * Runs the shutdown callbacks once (a second call returns the same promise), newest first: an app's own callbacks
80
+ * run before the framework closes what they use, then the framework's in the reverse of its providers' order (the
81
+ * queue, database and cache connections close, then the log is written, then the session store closes). A failing
82
+ * callback is printed with console.error (the log may be closed already) and the others still run; after 10 seconds
83
+ * the rest are given up on, so the process can still exit. Never rejects.
84
+ */
85
+ shutdown(): Promise<void>;
86
+ private runShutdown;
70
87
  private runBoot;
71
88
  private bootProvider;
72
89
  }
@@ -90,4 +107,86 @@ declare class ProviderRegisterError extends Error {
90
107
  constructor(provider: string, cause: unknown);
91
108
  }
92
109
 
93
- export { Application, ApplicationBuilder, ClosureKernel, ProviderBootError, ProviderRegisterError, type RoutingOptions };
110
+ /** One entry of Vite's build manifest (vite's ManifestChunk). */
111
+ interface ManifestChunk {
112
+ file: string;
113
+ src?: string;
114
+ name?: string;
115
+ isEntry?: boolean;
116
+ isDynamicEntry?: boolean;
117
+ imports?: string[];
118
+ dynamicImports?: string[];
119
+ css?: string[];
120
+ assets?: string[];
121
+ [key: string]: unknown;
122
+ }
123
+ type Manifest = Record<string, ManifestChunk>;
124
+ type TagAttributes = Record<string, string | boolean | null | undefined>;
125
+ type AttributesResolver = (src: string, url: string, chunk: ManifestChunk | undefined, manifest: Manifest | undefined) => TagAttributes;
126
+ type PreloadAttributesResolver = (src: string, url: string, chunk: ManifestChunk | undefined, manifest: Manifest | undefined) => TagAttributes | false;
127
+ /** A missing manifest or chunk (Laravel's ViteException / ViteManifestNotFoundException). */
128
+ declare class ViteError extends Error implements OrielError {
129
+ readonly kind: "Server";
130
+ readonly status = 500;
131
+ constructor(message: string);
132
+ }
133
+ /** Markup the view renderer emits unescaped (Htmlable; Foundation can't import View's HtmlString). */
134
+ declare class ViteHtml implements Htmlable {
135
+ private readonly html;
136
+ constructor(html: string);
137
+ toHtml(): string;
138
+ toString(): string;
139
+ }
140
+ /**
141
+ * Laravel's Illuminate\Foundation\Vite: the script, style and preload tags for Vite entry points. While the dev
142
+ * server runs (public/hot holds its URL) it points at the dev server; otherwise it reads public/build/manifest.json.
143
+ */
144
+ declare class Vite {
145
+ #private;
146
+ protected readonly app: Application$1;
147
+ constructor(app: Application$1);
148
+ useCspNonce(nonce?: string): string;
149
+ cspNonce(): string | undefined;
150
+ useIntegrityKey(key: string | false): this;
151
+ withEntryPoints(entryPoints: string[]): this;
152
+ useHotFile(path: string): this;
153
+ useBuildDirectory(path: string): this;
154
+ useManifestFilename(filename: string): this;
155
+ useScriptTagAttributes(attributes: TagAttributes | AttributesResolver): this;
156
+ useStyleTagAttributes(attributes: TagAttributes | AttributesResolver): this;
157
+ /** Extra preload attributes; a resolver returning false drops that preload. */
158
+ usePreloadTagAttributes(attributes: TagAttributes | PreloadAttributesResolver | false): this;
159
+ createAssetPathsUsing(resolver: (path: string) => string): this;
160
+ hotFile(): string;
161
+ isRunningHot(): boolean;
162
+ /** The dev server URL written by @orieljs/vite, or undefined when it isn't running. */
163
+ devServerUrl(): string | undefined;
164
+ /** Laravel's @vite([...]): preloads (styles first), then stylesheets, then scripts. */
165
+ tags(entryPoints: string | string[], buildDirectory?: string): ViteHtml;
166
+ /** Laravel's @viteReactRefresh: the React Refresh preamble while the dev server runs; nothing otherwise. */
167
+ reactRefresh(): ViteHtml | undefined;
168
+ /** The URL of a processed asset (Vite::asset('resources/images/logo.svg')). */
169
+ asset(path: string, buildDirectory?: string): string;
170
+ /** The built file's contents (Vite::content()). */
171
+ content(path: string, buildDirectory?: string): string;
172
+ /** md5 of the manifest (a cache-busting asset version); undefined while hot or without a build. */
173
+ manifestHash(buildDirectory?: string): string | undefined;
174
+ manifestPath(buildDirectory?: string): string;
175
+ manifest(buildDirectory?: string): Manifest;
176
+ /** URL → the attributes of the preload tags rendered so far (without href), for Link headers. */
177
+ preloadedAssets(): Record<string, string[]>;
178
+ /** Renders withEntryPoints() (Vite is Htmlable, like Laravel's). */
179
+ toHtml(): string;
180
+ }
181
+ /**
182
+ * The Vite instance for the current context: the request's own (scoped, so a CSP nonce stays in its request),
183
+ * else a fresh one for the application (a mail view rendered by a queue worker).
184
+ */
185
+ declare function currentVite(): Vite;
186
+ /** vite(['resources/js/app.tsx']) → the tags (Laravel's @vite); vite() → the Vite instance. */
187
+ declare function vite(): Vite;
188
+ declare function vite(entryPoints: string | string[], buildDirectory?: string): ViteHtml;
189
+ /** Laravel's @viteReactRefresh: put it before vite([...]) in the root view of a React app. */
190
+ declare function viteReactRefresh(): ViteHtml | undefined;
191
+
192
+ export { Application, ApplicationBuilder, type AttributesResolver, ClosureKernel, type Manifest, type ManifestChunk, type PreloadAttributesResolver, ProviderBootError, ProviderRegisterError, type RoutingOptions, type TagAttributes, Vite, ViteError, ViteHtml, currentVite, vite, viteReactRefresh };
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  // Application.ts
2
- import { join as join2 } from "path";
2
+ import { join as join3 } from "path";
3
3
  import {
4
- Application as ApplicationToken,
4
+ Application as ApplicationToken2,
5
5
  ClassRegistry as ClassRegistryToken,
6
- ConfigRepository as ConfigRepository2,
6
+ ConfigRepository as ConfigRepository3,
7
7
  HttpKernel
8
8
  } from "@orieljs/contracts";
9
9
  import { Container } from "@orieljs/container";
@@ -32,10 +32,11 @@ var ApplicationBuilder = class {
32
32
  return this;
33
33
  }
34
34
  withRouting(options) {
35
- const abs = (p) => p === void 0 ? void 0 : isAbsolute(p) ? p : join(this.app.basePath(), p);
35
+ const abs = (p) => isAbsolute(p) ? p : join(this.app.basePath(), p);
36
+ const each = (p) => Array.isArray(p) ? p.map(abs) : abs(p);
36
37
  const paths = { apiPrefix: options.apiPrefix ?? "api" };
37
- if (options.web !== void 0) paths.web = abs(options.web);
38
- if (options.api !== void 0) paths.api = abs(options.api);
38
+ if (options.web !== void 0) paths.web = each(options.web);
39
+ if (options.api !== void 0) paths.api = each(options.api);
39
40
  if (options.console !== void 0) paths.console = abs(options.console);
40
41
  if (options.health !== void 0) paths.health = options.health;
41
42
  this.routing = paths;
@@ -86,22 +87,308 @@ var ProviderRegisterError = class extends Error {
86
87
  name = "ProviderRegisterError";
87
88
  };
88
89
 
90
+ // Vite.ts
91
+ import { existsSync, readFileSync, statSync } from "fs";
92
+ import { createHash, randomBytes } from "crypto";
93
+ import { join as join2 } from "path";
94
+ import { Application as ApplicationToken, ConfigRepository as ConfigRepository2, HttpRequest, UrlGenerator } from "@orieljs/contracts";
95
+ import { ContainerNotAvailableError, currentContainer } from "@orieljs/container";
96
+ var ViteError = class extends Error {
97
+ kind = "Server";
98
+ status = 500;
99
+ constructor(message) {
100
+ super(message);
101
+ this.name = "ViteError";
102
+ }
103
+ };
104
+ var ViteHtml = class {
105
+ constructor(html) {
106
+ this.html = html;
107
+ }
108
+ html;
109
+ toHtml() {
110
+ return this.html;
111
+ }
112
+ toString() {
113
+ return this.html;
114
+ }
115
+ };
116
+ var TRACKED = { "data-navigate-track": true };
117
+ var CSS_PATH = /\.(css|less|sass|scss|styl|stylus|pcss|postcss)(\?[^.]*)?$/;
118
+ var manifests = /* @__PURE__ */ new Map();
119
+ var escapeAttribute = (value) => value.replace(/&/g, "&amp;").replace(/"/g, "&quot;");
120
+ var Vite = class {
121
+ constructor(app) {
122
+ this.app = app;
123
+ }
124
+ app;
125
+ #hotFile;
126
+ #buildDirectory = "build";
127
+ #manifestFilename = "manifest.json";
128
+ #nonce;
129
+ #integrityKey = "integrity";
130
+ #entryPoints = [];
131
+ #scriptResolvers = [];
132
+ #styleResolvers = [];
133
+ #preloadResolvers = [];
134
+ #assetPathResolver;
135
+ #preloaded = {};
136
+ // Configuration --------------------------------------------------------------------------------------------
137
+ useCspNonce(nonce) {
138
+ this.#nonce = nonce ?? randomBytes(30).toString("base64url").slice(0, 40);
139
+ return this.#nonce;
140
+ }
141
+ cspNonce() {
142
+ return this.#nonce;
143
+ }
144
+ useIntegrityKey(key) {
145
+ this.#integrityKey = key;
146
+ return this;
147
+ }
148
+ withEntryPoints(entryPoints) {
149
+ this.#entryPoints = entryPoints;
150
+ return this;
151
+ }
152
+ useHotFile(path) {
153
+ this.#hotFile = path;
154
+ return this;
155
+ }
156
+ useBuildDirectory(path) {
157
+ this.#buildDirectory = path;
158
+ return this;
159
+ }
160
+ useManifestFilename(filename) {
161
+ this.#manifestFilename = filename;
162
+ return this;
163
+ }
164
+ useScriptTagAttributes(attributes) {
165
+ this.#scriptResolvers.push(typeof attributes === "function" ? attributes : () => attributes);
166
+ return this;
167
+ }
168
+ useStyleTagAttributes(attributes) {
169
+ this.#styleResolvers.push(typeof attributes === "function" ? attributes : () => attributes);
170
+ return this;
171
+ }
172
+ /** Extra preload attributes; a resolver returning false drops that preload. */
173
+ usePreloadTagAttributes(attributes) {
174
+ this.#preloadResolvers.push(typeof attributes === "function" ? attributes : () => attributes);
175
+ return this;
176
+ }
177
+ createAssetPathsUsing(resolver) {
178
+ this.#assetPathResolver = resolver;
179
+ return this;
180
+ }
181
+ // Dev server -----------------------------------------------------------------------------------------------
182
+ hotFile() {
183
+ return this.#hotFile ?? this.app.publicPath("hot");
184
+ }
185
+ isRunningHot() {
186
+ return existsSync(this.hotFile());
187
+ }
188
+ /** The dev server URL written by @orieljs/vite, or undefined when it isn't running. */
189
+ devServerUrl() {
190
+ return this.isRunningHot() ? readFileSync(this.hotFile(), "utf8").trimEnd() : void 0;
191
+ }
192
+ // Tags -----------------------------------------------------------------------------------------------------
193
+ /** Laravel's @vite([...]): preloads (styles first), then stylesheets, then scripts. */
194
+ tags(entryPoints, buildDirectory = this.#buildDirectory) {
195
+ const entries = [entryPoints].flat();
196
+ if (this.isRunningHot()) {
197
+ return new ViteHtml(["@vite/client", ...entries].map((entry) => this.#tagForChunk(entry, this.#hotAsset(entry), void 0, void 0)).join(""));
198
+ }
199
+ const manifest = this.manifest(buildDirectory);
200
+ const tags = [];
201
+ const preloads = [];
202
+ const cssChunk = (css) => {
203
+ const found = Object.entries(manifest).find(([, chunk]) => chunk.file === css);
204
+ return found === void 0 ? [css, void 0] : [found[0], found[1]];
205
+ };
206
+ for (const entry of entries) {
207
+ const chunk = this.#chunk(manifest, entry);
208
+ preloads.push([chunk.src ?? entry, this.#assetPath(`${buildDirectory}/${chunk.file}`), chunk]);
209
+ for (const name of this.#resolveImports(manifest, chunk)) {
210
+ const imported = manifest[name];
211
+ preloads.push([name, this.#assetPath(`${buildDirectory}/${imported.file}`), imported]);
212
+ for (const css of imported.css ?? []) {
213
+ const [key, partial] = cssChunk(css);
214
+ preloads.push([key, this.#assetPath(`${buildDirectory}/${css}`), partial]);
215
+ tags.push(this.#tagForChunk(key, this.#assetPath(`${buildDirectory}/${css}`), partial, manifest));
216
+ }
217
+ }
218
+ tags.push(this.#tagForChunk(entry, this.#assetPath(`${buildDirectory}/${chunk.file}`), chunk, manifest));
219
+ for (const css of chunk.css ?? []) {
220
+ const [key, partial] = cssChunk(css);
221
+ preloads.push([key, this.#assetPath(`${buildDirectory}/${css}`), partial]);
222
+ tags.push(this.#tagForChunk(key, this.#assetPath(`${buildDirectory}/${css}`), partial, manifest));
223
+ }
224
+ }
225
+ const uniqueTags = [...new Set(tags)];
226
+ const stylesheets = uniqueTags.filter((tag) => tag.startsWith("<link"));
227
+ const scripts = uniqueTags.filter((tag) => !tag.startsWith("<link"));
228
+ const seen = /* @__PURE__ */ new Set();
229
+ const uniquePreloads = preloads.filter(([, url]) => seen.has(url) ? false : (seen.add(url), true));
230
+ const sorted = [...uniquePreloads.filter(([, url]) => CSS_PATH.test(url)), ...uniquePreloads.filter(([, url]) => !CSS_PATH.test(url))];
231
+ const preloadTags = sorted.map(([src, url, chunk]) => this.#preloadTag(src, url, chunk, manifest));
232
+ return new ViteHtml(preloadTags.join("") + stylesheets.join("") + scripts.join(""));
233
+ }
234
+ /** Laravel's @viteReactRefresh: the React Refresh preamble while the dev server runs; nothing otherwise. */
235
+ reactRefresh() {
236
+ if (!this.isRunningHot()) return void 0;
237
+ const attributes = this.#parseAttributes({ nonce: this.#nonce ?? false });
238
+ return new ViteHtml(
239
+ [
240
+ `<script type="module" ${attributes.join(" ")}>`,
241
+ ` import RefreshRuntime from '${this.#hotAsset("@react-refresh")}'`,
242
+ " RefreshRuntime.injectIntoGlobalHook(window)",
243
+ " window.$RefreshReg$ = () => {}",
244
+ " window.$RefreshSig$ = () => (type) => type",
245
+ " window.__vite_plugin_react_preamble_installed__ = true",
246
+ "</script>"
247
+ ].join("\n")
248
+ );
249
+ }
250
+ /** The URL of a processed asset (Vite::asset('resources/images/logo.svg')). */
251
+ asset(path, buildDirectory = this.#buildDirectory) {
252
+ if (this.isRunningHot()) return this.#hotAsset(path);
253
+ return this.#assetPath(`${buildDirectory}/${this.#chunk(this.manifest(buildDirectory), path).file}`);
254
+ }
255
+ /** The built file's contents (Vite::content()). */
256
+ content(path, buildDirectory = this.#buildDirectory) {
257
+ const chunk = this.#chunk(this.manifest(buildDirectory), path);
258
+ const file = this.app.publicPath(join2(buildDirectory, chunk.file));
259
+ if (!existsSync(file)) throw new ViteError(`Unable to locate file from Vite manifest: ${file}.`);
260
+ return readFileSync(file, "utf8");
261
+ }
262
+ /** md5 of the manifest (a cache-busting asset version); undefined while hot or without a build. */
263
+ manifestHash(buildDirectory = this.#buildDirectory) {
264
+ if (this.isRunningHot()) return void 0;
265
+ const path = this.manifestPath(buildDirectory);
266
+ return existsSync(path) ? createHash("md5").update(readFileSync(path)).digest("hex") : void 0;
267
+ }
268
+ manifestPath(buildDirectory = this.#buildDirectory) {
269
+ return this.app.publicPath(join2(buildDirectory, this.#manifestFilename));
270
+ }
271
+ manifest(buildDirectory = this.#buildDirectory) {
272
+ const path = this.manifestPath(buildDirectory);
273
+ if (!existsSync(path)) throw new ViteError(`Vite manifest not found at: ${path}`);
274
+ const { mtimeMs } = statSync(path);
275
+ const cached = manifests.get(path);
276
+ if (cached !== void 0 && cached.mtimeMs === mtimeMs) return cached.manifest;
277
+ const manifest = JSON.parse(readFileSync(path, "utf8"));
278
+ manifests.set(path, { mtimeMs, manifest });
279
+ return manifest;
280
+ }
281
+ /** URL → the attributes of the preload tags rendered so far (without href), for Link headers. */
282
+ preloadedAssets() {
283
+ return { ...this.#preloaded };
284
+ }
285
+ /** Renders withEntryPoints() (Vite is Htmlable, like Laravel's). */
286
+ toHtml() {
287
+ return this.tags(this.#entryPoints).toHtml();
288
+ }
289
+ // Internals ------------------------------------------------------------------------------------------------
290
+ #hotAsset(path) {
291
+ return `${this.devServerUrl() ?? ""}/${path}`;
292
+ }
293
+ #assetPath(path) {
294
+ if (this.#assetPathResolver !== void 0) return this.#assetPathResolver(path);
295
+ if (this.app.bound(UrlGenerator)) return this.app.make(UrlGenerator).asset(path);
296
+ const base = this.app.bound(ConfigRepository2) ? this.app.make(ConfigRepository2).get("app.asset_url", null) : null;
297
+ return `${(base ?? "").replace(/\/+$/, "")}/${path.replace(/^\/+/, "")}`;
298
+ }
299
+ #chunk(manifest, file) {
300
+ const chunk = manifest[file];
301
+ if (chunk === void 0) throw new ViteError(`Unable to locate file in Vite manifest: ${file}.`);
302
+ return chunk;
303
+ }
304
+ /** Every static import, depth first, each once. */
305
+ #resolveImports(manifest, chunk, seen = /* @__PURE__ */ new Set()) {
306
+ const imports = [];
307
+ for (const name of chunk.imports ?? []) {
308
+ if (seen.has(name)) continue;
309
+ seen.add(name);
310
+ imports.push(name);
311
+ const imported = manifest[name];
312
+ if (imported !== void 0) imports.push(...this.#resolveImports(manifest, imported, seen));
313
+ }
314
+ return imports;
315
+ }
316
+ #tagForChunk(src, url, chunk, manifest) {
317
+ if (CSS_PATH.test(url)) {
318
+ const attributes2 = this.#parseAttributes({ rel: "stylesheet", href: url, nonce: this.#nonce ?? false, ...TRACKED, ...this.#styleAttributes(src, url, chunk, manifest) });
319
+ return `<link ${attributes2.join(" ")} />`;
320
+ }
321
+ const attributes = this.#parseAttributes({ type: "module", src: url, nonce: this.#nonce ?? false, ...TRACKED, ...this.#scriptAttributes(src, url, chunk, manifest) });
322
+ return `<script ${attributes.join(" ")}></script>`;
323
+ }
324
+ #preloadTag(src, url, chunk, manifest) {
325
+ const css = CSS_PATH.test(url);
326
+ let attributes = {
327
+ rel: css ? "preload" : "modulepreload",
328
+ as: css ? "style" : "script",
329
+ href: url,
330
+ nonce: this.#nonce ?? false,
331
+ crossorigin: (css ? this.#styleAttributes(src, url, chunk, manifest) : this.#scriptAttributes(src, url, chunk, manifest)).crossorigin ?? false
332
+ };
333
+ if (this.#integrityKey !== false) attributes.integrity = chunk?.[this.#integrityKey] ?? false;
334
+ for (const resolver of this.#preloadResolvers) {
335
+ const resolved = resolver(src, url, chunk, manifest);
336
+ if (resolved === false) return "";
337
+ attributes = { ...attributes, ...resolved };
338
+ }
339
+ const { href: _href, ...rest } = attributes;
340
+ this.#preloaded[url] = this.#parseAttributes(rest);
341
+ return `<link ${this.#parseAttributes(attributes).join(" ")} />`;
342
+ }
343
+ #scriptAttributes(src, url, chunk, manifest) {
344
+ let attributes = this.#integrityKey !== false ? { integrity: chunk?.[this.#integrityKey] ?? false } : {};
345
+ for (const resolver of this.#scriptResolvers) attributes = { ...attributes, ...resolver(src, url, chunk, manifest) };
346
+ return attributes;
347
+ }
348
+ #styleAttributes(src, url, chunk, manifest) {
349
+ let attributes = this.#integrityKey !== false ? { integrity: chunk?.[this.#integrityKey] ?? false } : {};
350
+ for (const resolver of this.#styleResolvers) attributes = { ...attributes, ...resolver(src, url, chunk, manifest) };
351
+ return attributes;
352
+ }
353
+ /** false/null/undefined are dropped, true is a bare attribute, anything else name="value". */
354
+ #parseAttributes(attributes) {
355
+ return Object.entries(attributes).filter(([, value]) => value !== false && value !== null && value !== void 0).map(([name, value]) => value === true ? name : `${name}="${escapeAttribute(String(value))}"`);
356
+ }
357
+ };
358
+ function currentVite() {
359
+ const container = currentContainer();
360
+ if (container === void 0) throw new ContainerNotAvailableError("Vite");
361
+ if (container.bound(HttpRequest)) return container.make(Vite);
362
+ return new Vite(container.make(ApplicationToken));
363
+ }
364
+ function vite(entryPoints, buildDirectory) {
365
+ const instance = currentVite();
366
+ return entryPoints === void 0 ? instance : instance.tags(entryPoints, buildDirectory);
367
+ }
368
+ function viteReactRefresh() {
369
+ return currentVite().reactRefresh();
370
+ }
371
+
89
372
  // Application.ts
373
+ var SHUTDOWN_TIMEOUT_MS = 1e4;
90
374
  var Application = class _Application extends Container {
91
375
  constructor(base) {
92
376
  super();
93
377
  this.base = base;
94
378
  Container.setInstance(this);
95
- this.instance(ApplicationToken, this);
379
+ this.instance(ApplicationToken2, this);
96
380
  this.instance(_Application, this);
97
381
  this.singleton(ClassRegistryToken, ClassRegistry);
382
+ this.scoped(Vite, () => new Vite(this));
98
383
  }
99
384
  base;
100
- version = "0.1.0-alpha.1";
385
+ version = "0.1.0-alpha.10";
101
386
  providers = [];
102
387
  bootingCallbacks = [];
103
388
  bootedCallbacks = [];
104
389
  terminatingCallbacks = [];
390
+ shutdownCallbacks = [];
391
+ shutdownPromise;
105
392
  bootPromise;
106
393
  hasBooted = false;
107
394
  inConsole = false;
@@ -110,32 +397,32 @@ var Application = class _Application extends Container {
110
397
  return new ApplicationBuilder(new _Application(options.basePath));
111
398
  }
112
399
  basePath(path = "") {
113
- return join2(this.base, path);
400
+ return join3(this.base, path);
114
401
  }
115
402
  appPath(path = "") {
116
- return this.basePath(join2("app", path));
403
+ return this.basePath(join3("app", path));
117
404
  }
118
405
  bootstrapPath(path = "") {
119
- return this.basePath(join2("bootstrap", path));
406
+ return this.basePath(join3("bootstrap", path));
120
407
  }
121
408
  configPath(path = "") {
122
- return this.basePath(join2("config", path));
409
+ return this.basePath(join3("config", path));
123
410
  }
124
411
  databasePath(path = "") {
125
- return this.basePath(join2("database", path));
412
+ return this.basePath(join3("database", path));
126
413
  }
127
414
  publicPath(path = "") {
128
- return this.basePath(join2("public", path));
415
+ return this.basePath(join3("public", path));
129
416
  }
130
417
  resourcePath(path = "") {
131
- return this.basePath(join2("resources", path));
418
+ return this.basePath(join3("resources", path));
132
419
  }
133
420
  storagePath(path = "") {
134
- return this.basePath(join2("storage", path));
421
+ return this.basePath(join3("storage", path));
135
422
  }
136
423
  environment(...environments) {
137
424
  const fallback = process.env.APP_ENV ?? "production";
138
- const current = this.bound(ConfigRepository2) ? String(this.make(ConfigRepository2).get("app.env", fallback)) : fallback;
425
+ const current = this.bound(ConfigRepository3) ? String(this.make(ConfigRepository3).get("app.env", fallback)) : fallback;
139
426
  return environments.length === 0 ? current : environments.some((pattern) => Str.is(pattern, current));
140
427
  }
141
428
  isProduction() {
@@ -195,6 +482,44 @@ var Application = class _Application extends Container {
195
482
  async terminate() {
196
483
  for (const callback of this.terminatingCallbacks) await callback();
197
484
  }
485
+ /**
486
+ * A callback for the end of the process (the CLI after its command, the server on SIGTERM): close DB pools, Redis
487
+ * clients and log files. Not in Laravel, whose PHP processes end with each request.
488
+ */
489
+ onShutdown(callback) {
490
+ this.shutdownCallbacks.push(callback);
491
+ }
492
+ /**
493
+ * Runs the shutdown callbacks once (a second call returns the same promise), newest first: an app's own callbacks
494
+ * run before the framework closes what they use, then the framework's in the reverse of its providers' order (the
495
+ * queue, database and cache connections close, then the log is written, then the session store closes). A failing
496
+ * callback is printed with console.error (the log may be closed already) and the others still run; after 10 seconds
497
+ * the rest are given up on, so the process can still exit. Never rejects.
498
+ */
499
+ shutdown() {
500
+ return this.shutdownPromise ??= this.runShutdown();
501
+ }
502
+ async runShutdown() {
503
+ if (this.shutdownCallbacks.length === 0) return;
504
+ const callbacks = [...this.shutdownCallbacks].reverse();
505
+ const run = (async () => {
506
+ for (const callback of callbacks) {
507
+ try {
508
+ await callback();
509
+ } catch (error) {
510
+ console.error(error);
511
+ }
512
+ }
513
+ return "done";
514
+ })();
515
+ let timer;
516
+ const deadline = new Promise((resolve) => timer = setTimeout(() => resolve("timeout"), SHUTDOWN_TIMEOUT_MS));
517
+ const outcome = await Promise.race([run, deadline]);
518
+ clearTimeout(timer);
519
+ if (outcome === "timeout") {
520
+ console.error(`The shutdown callbacks did not finish within ${SHUTDOWN_TIMEOUT_MS / 1e3} seconds; carrying on with the exit.`);
521
+ }
522
+ }
198
523
  async runBoot() {
199
524
  for (const callback of this.bootingCallbacks) await callback(this);
200
525
  for (let i = 0; i < this.providers.length; i++) await this.bootProvider(this.providers[i]);
@@ -234,6 +559,12 @@ export {
234
559
  ApplicationBuilder,
235
560
  ClosureKernel,
236
561
  ProviderBootError,
237
- ProviderRegisterError
562
+ ProviderRegisterError,
563
+ Vite,
564
+ ViteError,
565
+ ViteHtml,
566
+ currentVite,
567
+ vite,
568
+ viteReactRefresh
238
569
  };
239
570
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../Application.ts","../ApplicationBuilder.ts","../errors.ts","../Http/ClosureKernel.ts"],"sourcesContent":["import { join } from 'node:path'\nimport {\n Application as ApplicationToken,\n ClassRegistry as ClassRegistryToken,\n ConfigRepository,\n HttpKernel,\n type Application as ApplicationContract,\n type ServiceProvider,\n type ServiceProviderClass,\n} from '@orieljs/contracts'\nimport { Container } from '@orieljs/container'\nimport { ClassRegistry, Str } from '@orieljs/support'\nimport { ApplicationBuilder } from './ApplicationBuilder'\nimport { ProviderBootError, ProviderRegisterError } from './errors'\n\ntype LifecycleCallback = (app: ApplicationContract) => void | Promise<void>\n\nexport class Application extends Container implements ApplicationContract {\n readonly version = '0.1.0-alpha.1'\n\n private readonly providers: ServiceProvider[] = []\n private readonly bootingCallbacks: LifecycleCallback[] = []\n private readonly bootedCallbacks: LifecycleCallback[] = []\n private readonly terminatingCallbacks: Array<() => void | Promise<void>> = []\n private bootPromise: Promise<void> | undefined\n private hasBooted = false\n private inConsole = false\n\n constructor(private readonly base: string) {\n super()\n Container.setInstance(this)\n this.instance(ApplicationToken, this)\n // The class too: otherwise inject(Application) would build a second app and hijack the global instance.\n this.instance(Application, this)\n this.singleton(ClassRegistryToken, ClassRegistry)\n }\n\n /** Entry point used by bootstrap/app.ts. */\n static configure(options: { basePath: string }): ApplicationBuilder {\n return new ApplicationBuilder(new Application(options.basePath))\n }\n\n basePath(path = ''): string { return join(this.base, path) }\n appPath(path = ''): string { return this.basePath(join('app', path)) }\n bootstrapPath(path = ''): string { return this.basePath(join('bootstrap', path)) }\n configPath(path = ''): string { return this.basePath(join('config', path)) }\n databasePath(path = ''): string { return this.basePath(join('database', path)) }\n publicPath(path = ''): string { return this.basePath(join('public', path)) }\n resourcePath(path = ''): string { return this.basePath(join('resources', path)) }\n storagePath(path = ''): string { return this.basePath(join('storage', path)) }\n\n environment(): string\n environment(...environments: string[]): boolean\n environment(...environments: string[]): string | boolean {\n const fallback = process.env.APP_ENV ?? 'production'\n const current = this.bound(ConfigRepository)\n ? String(this.make(ConfigRepository).get('app.env', fallback))\n : fallback\n return environments.length === 0 ? current : environments.some((pattern) => Str.is(pattern, current))\n }\n\n isProduction(): boolean { return this.environment('production') }\n isLocal(): boolean { return this.environment('local') }\n runningUnitTests(): boolean { return this.environment('testing') }\n runningInConsole(): boolean { return this.inConsole }\n setRunningInConsole(value = true): void { this.inConsole = value }\n\n async register(provider: ServiceProvider | ServiceProviderClass): Promise<ServiceProvider> {\n const cls = typeof provider === 'function' ? provider : provider.constructor\n const existing = this.providers.find((p) => p.constructor === cls)\n if (existing) return existing\n\n const instance = typeof provider === 'function' ? new provider(this) : provider\n try {\n instance.register?.()\n } catch (error) {\n throw new ProviderRegisterError(instance.constructor.name, error)\n }\n this.providers.push(instance)\n if (this.hasBooted) await this.bootProvider(instance)\n return instance\n }\n\n getProviders(): ServiceProvider[] {\n return [...this.providers]\n }\n\n boot(): Promise<void> {\n return (this.bootPromise ??= this.runBoot())\n }\n\n isBooted(): boolean {\n return this.hasBooted\n }\n\n booting(callback: LifecycleCallback): void {\n this.bootingCallbacks.push(callback)\n }\n\n /** If already booted, the callback runs immediately (a rejection surfaces as an unhandled rejection). */\n booted(callback: LifecycleCallback): void {\n this.bootedCallbacks.push(callback)\n if (this.hasBooted) void callback(this)\n }\n\n terminating(callback: () => void | Promise<void>): void {\n this.terminatingCallbacks.push(callback)\n }\n\n async handle(request: Request): Promise<Response> {\n await this.boot()\n const scope = this.createScope()\n return scope.run(() => scope.make(HttpKernel).handle(request))\n }\n\n async terminate(): Promise<void> {\n for (const callback of this.terminatingCallbacks) await callback()\n }\n\n private async runBoot(): Promise<void> {\n for (const callback of this.bootingCallbacks) await callback(this)\n // Index loop on purpose: providers registered during boot are appended and booted in this pass.\n for (let i = 0; i < this.providers.length; i++) await this.bootProvider(this.providers[i]!)\n this.hasBooted = true\n for (const callback of this.bootedCallbacks) await callback(this)\n }\n\n private async bootProvider(provider: ServiceProvider): Promise<void> {\n try {\n await provider.boot?.()\n } catch (error) {\n throw new ProviderBootError(provider.constructor.name, error)\n }\n }\n}\n","import { isAbsolute, join } from 'node:path'\nimport {\n ConfigRepository,\n ExceptionCallbacks,\n MiddlewareCallbacks,\n RoutingPaths,\n type Application as ApplicationContract,\n type ExceptionsConfigurator,\n type MiddlewareConfigurator,\n type ServiceProvider,\n type ServiceProviderClass,\n} from '@orieljs/contracts'\nimport { loadConfiguration, loadEnvironment, Repository } from '@orieljs/config'\nimport type { Application } from './Application'\n\nexport interface RoutingOptions {\n web?: string\n api?: string\n console?: string\n /** A URI such as '/up', not a file. */\n health?: string\n apiPrefix?: string\n}\n\ntype Lifecycle = (app: ApplicationContract) => void | Promise<void>\n\nexport class ApplicationBuilder {\n private readonly providers: Array<ServiceProvider | ServiceProviderClass> = []\n private readonly middleware: Array<(middleware: MiddlewareConfigurator) => void> = []\n private readonly exceptions: Array<(exceptions: ExceptionsConfigurator) => void> = []\n private routing: RoutingPaths | undefined\n\n constructor(private readonly app: Application) {}\n\n withProviders(providers: Array<ServiceProvider | ServiceProviderClass> = []): this {\n this.providers.push(...providers)\n return this\n }\n\n withRouting(options: RoutingOptions): this {\n const abs = (p?: string) => (p === undefined ? undefined : isAbsolute(p) ? p : join(this.app.basePath(), p))\n const paths: RoutingPaths = { apiPrefix: options.apiPrefix ?? 'api' }\n if (options.web !== undefined) paths.web = abs(options.web)\n if (options.api !== undefined) paths.api = abs(options.api)\n if (options.console !== undefined) paths.console = abs(options.console)\n if (options.health !== undefined) paths.health = options.health\n this.routing = paths\n return this\n }\n\n withMiddleware(callback: (middleware: MiddlewareConfigurator) => void): this {\n this.middleware.push(callback)\n return this\n }\n\n withExceptions(callback: (exceptions: ExceptionsConfigurator) => void): this {\n this.exceptions.push(callback)\n return this\n }\n\n booting(callback: Lifecycle): this {\n this.app.booting(callback)\n return this\n }\n\n booted(callback: Lifecycle): this {\n this.app.booted(callback)\n return this\n }\n\n async create(): Promise<Application> {\n loadEnvironment(this.app.basePath())\n this.app.instance(ConfigRepository, new Repository(await loadConfiguration(this.app.configPath())))\n if (this.routing) this.app.instance(RoutingPaths, this.routing)\n this.app.instance(MiddlewareCallbacks, this.middleware as Array<(configurator: unknown) => void>)\n this.app.instance(ExceptionCallbacks, this.exceptions)\n for (const provider of this.providers) await this.app.register(provider)\n return this.app\n }\n}\n","export class ProviderBootError extends Error {\n override readonly name = 'ProviderBootError'\n constructor(readonly provider: string, cause: unknown) {\n super(`Service provider [${provider}] failed to boot: ${cause instanceof Error ? cause.message : String(cause)}`, { cause })\n }\n}\n\nexport class ProviderRegisterError extends Error {\n override readonly name = 'ProviderRegisterError'\n constructor(readonly provider: string, cause: unknown) {\n super(`Service provider [${provider}] failed to register: ${cause instanceof Error ? cause.message : String(cause)}`, { cause })\n }\n}\n","import type { HttpKernel } from '@orieljs/contracts'\n\ntype Handler = (request: Request) => unknown\n\n/** Wave 0 stand-in for the Http kernel: exact \"METHOD /path\" matching only. Replaced by Wave 1's router. */\nexport class ClosureKernel implements HttpKernel {\n private readonly routes = new Map<string, Handler>()\n\n on(method: string, path: string, handler: Handler): this {\n this.routes.set(`${method.toUpperCase()} ${path}`, handler)\n return this\n }\n\n async handle(request: Request): Promise<Response> {\n const handler = this.routes.get(`${request.method} ${new URL(request.url).pathname}`)\n if (!handler) return new Response('Not Found', { status: 404, headers: { 'content-type': 'text/plain; charset=utf-8' } })\n return toResponse(await handler(request))\n }\n}\n\nfunction toResponse(output: unknown): Response {\n if (output instanceof Response) return output\n if (output === undefined || output === null) return new Response(null, { status: 204 })\n if (typeof output === 'string') return new Response(output, { headers: { 'content-type': 'text/html; charset=utf-8' } })\n return Response.json(output)\n}\n"],"mappings":";AAAA,SAAS,QAAAA,aAAY;AACrB;AAAA,EACE,eAAe;AAA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M,QAAO,IAAI,SAAS,MAAM,EAAE,QAAQ,IAAI,CAAC;AACtF,MAAI,OAAO,WAAW,SAAU,QAAO,IAAI,SAAS,QAAQ,EAAE,SAAS,EAAE,gBAAgB,2BAA2B,EAAE,CAAC;AACvH,SAAO,SAAS,KAAK,MAAM;AAC7B;","names":["join","ConfigRepository","join","ConfigRepository"]}
1
+ {"version":3,"sources":["../Application.ts","../ApplicationBuilder.ts","../errors.ts","../Vite.ts","../Http/ClosureKernel.ts"],"sourcesContent":["import { join } from 'node:path'\nimport {\n Application as ApplicationToken,\n ClassRegistry as ClassRegistryToken,\n ConfigRepository,\n HttpKernel,\n type Application as ApplicationContract,\n type ServiceProvider,\n type ServiceProviderClass,\n} from '@orieljs/contracts'\nimport { Container } from '@orieljs/container'\nimport { ClassRegistry, Str } from '@orieljs/support'\nimport { ApplicationBuilder } from './ApplicationBuilder'\nimport { ProviderBootError, ProviderRegisterError } from './errors'\nimport { Vite } from './Vite'\n\ntype LifecycleCallback = (app: ApplicationContract) => void | Promise<void>\n\n/** How long shutdown() waits for its callbacks before giving up, so a hung close never keeps the process alive. */\nconst SHUTDOWN_TIMEOUT_MS = 10_000\n\nexport class Application extends Container implements ApplicationContract {\n readonly version = '0.1.0-alpha.10'\n\n private readonly providers: ServiceProvider[] = []\n private readonly bootingCallbacks: LifecycleCallback[] = []\n private readonly bootedCallbacks: LifecycleCallback[] = []\n private readonly terminatingCallbacks: Array<() => void | Promise<void>> = []\n private readonly shutdownCallbacks: Array<() => void | Promise<void>> = []\n private shutdownPromise: Promise<void> | undefined\n private bootPromise: Promise<void> | undefined\n private hasBooted = false\n private inConsole = false\n\n constructor(private readonly base: string) {\n super()\n Container.setInstance(this)\n this.instance(ApplicationToken, this)\n // The class too: otherwise inject(Application) would build a second app and hijack the global instance.\n this.instance(Application, this)\n this.singleton(ClassRegistryToken, ClassRegistry)\n // One per request: a CSP nonce set with vite().useCspNonce() must not leak into other requests.\n this.scoped(Vite, () => new Vite(this))\n }\n\n /** Entry point used by bootstrap/app.ts. */\n static configure(options: { basePath: string }): ApplicationBuilder {\n return new ApplicationBuilder(new Application(options.basePath))\n }\n\n basePath(path = ''): string { return join(this.base, path) }\n appPath(path = ''): string { return this.basePath(join('app', path)) }\n bootstrapPath(path = ''): string { return this.basePath(join('bootstrap', path)) }\n configPath(path = ''): string { return this.basePath(join('config', path)) }\n databasePath(path = ''): string { return this.basePath(join('database', path)) }\n publicPath(path = ''): string { return this.basePath(join('public', path)) }\n resourcePath(path = ''): string { return this.basePath(join('resources', path)) }\n storagePath(path = ''): string { return this.basePath(join('storage', path)) }\n\n environment(): string\n environment(...environments: string[]): boolean\n environment(...environments: string[]): string | boolean {\n const fallback = process.env.APP_ENV ?? 'production'\n const current = this.bound(ConfigRepository)\n ? String(this.make(ConfigRepository).get('app.env', fallback))\n : fallback\n return environments.length === 0 ? current : environments.some((pattern) => Str.is(pattern, current))\n }\n\n isProduction(): boolean { return this.environment('production') }\n isLocal(): boolean { return this.environment('local') }\n runningUnitTests(): boolean { return this.environment('testing') }\n runningInConsole(): boolean { return this.inConsole }\n setRunningInConsole(value = true): void { this.inConsole = value }\n\n async register(provider: ServiceProvider | ServiceProviderClass): Promise<ServiceProvider> {\n const cls = typeof provider === 'function' ? provider : provider.constructor\n const existing = this.providers.find((p) => p.constructor === cls)\n if (existing) return existing\n\n const instance = typeof provider === 'function' ? new provider(this) : provider\n try {\n instance.register?.()\n } catch (error) {\n throw new ProviderRegisterError(instance.constructor.name, error)\n }\n this.providers.push(instance)\n if (this.hasBooted) await this.bootProvider(instance)\n return instance\n }\n\n getProviders(): ServiceProvider[] {\n return [...this.providers]\n }\n\n boot(): Promise<void> {\n return (this.bootPromise ??= this.runBoot())\n }\n\n isBooted(): boolean {\n return this.hasBooted\n }\n\n booting(callback: LifecycleCallback): void {\n this.bootingCallbacks.push(callback)\n }\n\n /** If already booted, the callback runs immediately (a rejection surfaces as an unhandled rejection). */\n booted(callback: LifecycleCallback): void {\n this.bootedCallbacks.push(callback)\n if (this.hasBooted) void callback(this)\n }\n\n terminating(callback: () => void | Promise<void>): void {\n this.terminatingCallbacks.push(callback)\n }\n\n async handle(request: Request): Promise<Response> {\n await this.boot()\n const scope = this.createScope()\n return scope.run(() => scope.make(HttpKernel).handle(request))\n }\n\n async terminate(): Promise<void> {\n for (const callback of this.terminatingCallbacks) await callback()\n }\n\n /**\n * A callback for the end of the process (the CLI after its command, the server on SIGTERM): close DB pools, Redis\n * clients and log files. Not in Laravel, whose PHP processes end with each request.\n */\n onShutdown(callback: () => void | Promise<void>): void {\n this.shutdownCallbacks.push(callback)\n }\n\n /**\n * Runs the shutdown callbacks once (a second call returns the same promise), newest first: an app's own callbacks\n * run before the framework closes what they use, then the framework's in the reverse of its providers' order (the\n * queue, database and cache connections close, then the log is written, then the session store closes). A failing\n * callback is printed with console.error (the log may be closed already) and the others still run; after 10 seconds\n * the rest are given up on, so the process can still exit. Never rejects.\n */\n shutdown(): Promise<void> {\n return (this.shutdownPromise ??= this.runShutdown())\n }\n\n private async runShutdown(): Promise<void> {\n if (this.shutdownCallbacks.length === 0) return\n const callbacks = [...this.shutdownCallbacks].reverse()\n const run = (async () => {\n for (const callback of callbacks) {\n try {\n await callback()\n } catch (error) {\n console.error(error)\n }\n }\n return 'done' as const\n })()\n let timer: ReturnType<typeof setTimeout> | undefined\n // Not unref'd: if a callback hangs on a promise and nothing else is left, the process must still reach its exit.\n const deadline = new Promise<'timeout'>((resolve) => (timer = setTimeout(() => resolve('timeout'), SHUTDOWN_TIMEOUT_MS)))\n const outcome = await Promise.race([run, deadline])\n clearTimeout(timer)\n if (outcome === 'timeout') {\n console.error(`The shutdown callbacks did not finish within ${SHUTDOWN_TIMEOUT_MS / 1000} seconds; carrying on with the exit.`)\n }\n }\n\n private async runBoot(): Promise<void> {\n for (const callback of this.bootingCallbacks) await callback(this)\n // Index loop on purpose: providers registered during boot are appended and booted in this pass.\n for (let i = 0; i < this.providers.length; i++) await this.bootProvider(this.providers[i]!)\n this.hasBooted = true\n for (const callback of this.bootedCallbacks) await callback(this)\n }\n\n private async bootProvider(provider: ServiceProvider): Promise<void> {\n try {\n await provider.boot?.()\n } catch (error) {\n throw new ProviderBootError(provider.constructor.name, error)\n }\n }\n}\n","import { isAbsolute, join } from 'node:path'\nimport {\n ConfigRepository,\n ExceptionCallbacks,\n MiddlewareCallbacks,\n RoutingPaths,\n type Application as ApplicationContract,\n type ExceptionsConfigurator,\n type MiddlewareConfigurator,\n type ServiceProvider,\n type ServiceProviderClass,\n} from '@orieljs/contracts'\nimport { loadConfiguration, loadEnvironment, Repository } from '@orieljs/config'\nimport type { Application } from './Application'\n\nexport interface RoutingOptions {\n /** One route file or several, loaded in order: web: ['routes/web.ts', 'routes/settings.ts', 'routes/auth.ts']. */\n web?: string | string[]\n api?: string | string[]\n console?: string\n /** A URI such as '/up', not a file. */\n health?: string\n apiPrefix?: string\n}\n\ntype Lifecycle = (app: ApplicationContract) => void | Promise<void>\n\nexport class ApplicationBuilder {\n private readonly providers: Array<ServiceProvider | ServiceProviderClass> = []\n private readonly middleware: Array<(middleware: MiddlewareConfigurator) => void> = []\n private readonly exceptions: Array<(exceptions: ExceptionsConfigurator) => void> = []\n private routing: RoutingPaths | undefined\n\n constructor(private readonly app: Application) {}\n\n withProviders(providers: Array<ServiceProvider | ServiceProviderClass> = []): this {\n this.providers.push(...providers)\n return this\n }\n\n withRouting(options: RoutingOptions): this {\n const abs = (p: string) => (isAbsolute(p) ? p : join(this.app.basePath(), p))\n const each = (p: string | string[]) => (Array.isArray(p) ? p.map(abs) : abs(p))\n const paths: RoutingPaths = { apiPrefix: options.apiPrefix ?? 'api' }\n if (options.web !== undefined) paths.web = each(options.web)\n if (options.api !== undefined) paths.api = each(options.api)\n if (options.console !== undefined) paths.console = abs(options.console)\n if (options.health !== undefined) paths.health = options.health\n this.routing = paths\n return this\n }\n\n withMiddleware(callback: (middleware: MiddlewareConfigurator) => void): this {\n this.middleware.push(callback)\n return this\n }\n\n withExceptions(callback: (exceptions: ExceptionsConfigurator) => void): this {\n this.exceptions.push(callback)\n return this\n }\n\n booting(callback: Lifecycle): this {\n this.app.booting(callback)\n return this\n }\n\n booted(callback: Lifecycle): this {\n this.app.booted(callback)\n return this\n }\n\n async create(): Promise<Application> {\n loadEnvironment(this.app.basePath())\n this.app.instance(ConfigRepository, new Repository(await loadConfiguration(this.app.configPath())))\n if (this.routing) this.app.instance(RoutingPaths, this.routing)\n this.app.instance(MiddlewareCallbacks, this.middleware as Array<(configurator: unknown) => void>)\n this.app.instance(ExceptionCallbacks, this.exceptions)\n for (const provider of this.providers) await this.app.register(provider)\n return this.app\n }\n}\n","export class ProviderBootError extends Error {\n override readonly name = 'ProviderBootError'\n constructor(readonly provider: string, cause: unknown) {\n super(`Service provider [${provider}] failed to boot: ${cause instanceof Error ? cause.message : String(cause)}`, { cause })\n }\n}\n\nexport class ProviderRegisterError extends Error {\n override readonly name = 'ProviderRegisterError'\n constructor(readonly provider: string, cause: unknown) {\n super(`Service provider [${provider}] failed to register: ${cause instanceof Error ? cause.message : String(cause)}`, { cause })\n }\n}\n","import { existsSync, readFileSync, statSync } from 'node:fs'\nimport { createHash, randomBytes } from 'node:crypto'\nimport { join } from 'node:path'\nimport { Application as ApplicationToken, ConfigRepository, HttpRequest, UrlGenerator, type Application, type Htmlable, type OrielError } from '@orieljs/contracts'\nimport { ContainerNotAvailableError, currentContainer } from '@orieljs/container'\n\n/** One entry of Vite's build manifest (vite's ManifestChunk). */\nexport interface ManifestChunk {\n file: string\n src?: string\n name?: string\n isEntry?: boolean\n isDynamicEntry?: boolean\n imports?: string[]\n dynamicImports?: string[]\n css?: string[]\n assets?: string[]\n [key: string]: unknown\n}\nexport type Manifest = Record<string, ManifestChunk>\n\nexport type TagAttributes = Record<string, string | boolean | null | undefined>\nexport type AttributesResolver = (src: string, url: string, chunk: ManifestChunk | undefined, manifest: Manifest | undefined) => TagAttributes\nexport type PreloadAttributesResolver = (src: string, url: string, chunk: ManifestChunk | undefined, manifest: Manifest | undefined) => TagAttributes | false\n\n/** A missing manifest or chunk (Laravel's ViteException / ViteManifestNotFoundException). */\nexport class ViteError extends Error implements OrielError {\n readonly kind = 'Server' as const\n readonly status = 500\n\n constructor(message: string) {\n super(message)\n this.name = 'ViteError'\n }\n}\n\n/** Markup the view renderer emits unescaped (Htmlable; Foundation can't import View's HtmlString). */\nexport class ViteHtml implements Htmlable {\n constructor(private readonly html: string) {}\n\n toHtml(): string {\n return this.html\n }\n\n toString(): string {\n return this.html\n }\n}\n\n/**\n * Marks the tags as tracked assets: when o:navigate reaches a page whose tracked URLs changed (a new build), it loads\n * the page in full rather than run the new bundle beside the old one. A tag attribute of `false` takes it off.\n */\nconst TRACKED: TagAttributes = { 'data-navigate-track': true }\nconst CSS_PATH = /\\.(css|less|sass|scss|styl|stylus|pcss|postcss)(\\?[^.]*)?$/\n\n/** Parsed manifests by path, reloaded when the file changes (a long-running server outlives a `vite build`). */\nconst manifests = new Map<string, { mtimeMs: number; manifest: Manifest }>()\n\nconst escapeAttribute = (value: string): string => value.replace(/&/g, '&amp;').replace(/\"/g, '&quot;')\n\n/**\n * Laravel's Illuminate\\Foundation\\Vite: the script, style and preload tags for Vite entry points. While the dev\n * server runs (public/hot holds its URL) it points at the dev server; otherwise it reads public/build/manifest.json.\n */\nexport class Vite {\n #hotFile: string | undefined\n #buildDirectory = 'build'\n #manifestFilename = 'manifest.json'\n #nonce: string | undefined\n #integrityKey: string | false = 'integrity'\n #entryPoints: string[] = []\n readonly #scriptResolvers: AttributesResolver[] = []\n readonly #styleResolvers: AttributesResolver[] = []\n readonly #preloadResolvers: PreloadAttributesResolver[] = []\n #assetPathResolver: ((path: string) => string) | undefined\n readonly #preloaded: Record<string, string[]> = {}\n\n constructor(protected readonly app: Application) {}\n\n // Configuration --------------------------------------------------------------------------------------------\n\n useCspNonce(nonce?: string): string {\n this.#nonce = nonce ?? randomBytes(30).toString('base64url').slice(0, 40)\n return this.#nonce\n }\n\n cspNonce(): string | undefined {\n return this.#nonce\n }\n\n useIntegrityKey(key: string | false): this {\n this.#integrityKey = key\n return this\n }\n\n withEntryPoints(entryPoints: string[]): this {\n this.#entryPoints = entryPoints\n return this\n }\n\n useHotFile(path: string): this {\n this.#hotFile = path\n return this\n }\n\n useBuildDirectory(path: string): this {\n this.#buildDirectory = path\n return this\n }\n\n useManifestFilename(filename: string): this {\n this.#manifestFilename = filename\n return this\n }\n\n useScriptTagAttributes(attributes: TagAttributes | AttributesResolver): this {\n this.#scriptResolvers.push(typeof attributes === 'function' ? attributes : () => attributes)\n return this\n }\n\n useStyleTagAttributes(attributes: TagAttributes | AttributesResolver): this {\n this.#styleResolvers.push(typeof attributes === 'function' ? attributes : () => attributes)\n return this\n }\n\n /** Extra preload attributes; a resolver returning false drops that preload. */\n usePreloadTagAttributes(attributes: TagAttributes | PreloadAttributesResolver | false): this {\n this.#preloadResolvers.push(typeof attributes === 'function' ? attributes : () => attributes)\n return this\n }\n\n createAssetPathsUsing(resolver: (path: string) => string): this {\n this.#assetPathResolver = resolver\n return this\n }\n\n // Dev server -----------------------------------------------------------------------------------------------\n\n hotFile(): string {\n return this.#hotFile ?? this.app.publicPath('hot')\n }\n\n isRunningHot(): boolean {\n return existsSync(this.hotFile())\n }\n\n /** The dev server URL written by @orieljs/vite, or undefined when it isn't running. */\n devServerUrl(): string | undefined {\n return this.isRunningHot() ? readFileSync(this.hotFile(), 'utf8').trimEnd() : undefined\n }\n\n // Tags -----------------------------------------------------------------------------------------------------\n\n /** Laravel's @vite([...]): preloads (styles first), then stylesheets, then scripts. */\n tags(entryPoints: string | string[], buildDirectory = this.#buildDirectory): ViteHtml {\n const entries = [entryPoints].flat()\n if (this.isRunningHot()) {\n return new ViteHtml(['@vite/client', ...entries].map((entry) => this.#tagForChunk(entry, this.#hotAsset(entry), undefined, undefined)).join(''))\n }\n const manifest = this.manifest(buildDirectory)\n const tags: string[] = []\n const preloads: Array<[string, string, ManifestChunk | undefined]> = []\n const cssChunk = (css: string): [string, ManifestChunk | undefined] => {\n const found = Object.entries(manifest).find(([, chunk]) => chunk.file === css)\n return found === undefined ? [css, undefined] : [found[0], found[1]]\n }\n for (const entry of entries) {\n const chunk = this.#chunk(manifest, entry)\n preloads.push([chunk.src ?? entry, this.#assetPath(`${buildDirectory}/${chunk.file}`), chunk])\n for (const name of this.#resolveImports(manifest, chunk)) {\n const imported = manifest[name]!\n preloads.push([name, this.#assetPath(`${buildDirectory}/${imported.file}`), imported])\n for (const css of imported.css ?? []) {\n const [key, partial] = cssChunk(css)\n preloads.push([key, this.#assetPath(`${buildDirectory}/${css}`), partial])\n tags.push(this.#tagForChunk(key, this.#assetPath(`${buildDirectory}/${css}`), partial, manifest))\n }\n }\n tags.push(this.#tagForChunk(entry, this.#assetPath(`${buildDirectory}/${chunk.file}`), chunk, manifest))\n for (const css of chunk.css ?? []) {\n const [key, partial] = cssChunk(css)\n preloads.push([key, this.#assetPath(`${buildDirectory}/${css}`), partial])\n tags.push(this.#tagForChunk(key, this.#assetPath(`${buildDirectory}/${css}`), partial, manifest))\n }\n }\n const uniqueTags = [...new Set(tags)]\n const stylesheets = uniqueTags.filter((tag) => tag.startsWith('<link'))\n const scripts = uniqueTags.filter((tag) => !tag.startsWith('<link'))\n const seen = new Set<string>()\n const uniquePreloads = preloads.filter(([, url]) => (seen.has(url) ? false : (seen.add(url), true)))\n const sorted = [...uniquePreloads.filter(([, url]) => CSS_PATH.test(url)), ...uniquePreloads.filter(([, url]) => !CSS_PATH.test(url))]\n const preloadTags = sorted.map(([src, url, chunk]) => this.#preloadTag(src, url, chunk, manifest))\n return new ViteHtml(preloadTags.join('') + stylesheets.join('') + scripts.join(''))\n }\n\n /** Laravel's @viteReactRefresh: the React Refresh preamble while the dev server runs; nothing otherwise. */\n reactRefresh(): ViteHtml | undefined {\n if (!this.isRunningHot()) return undefined\n const attributes = this.#parseAttributes({ nonce: this.#nonce ?? false })\n return new ViteHtml(\n [\n `<script type=\"module\" ${attributes.join(' ')}>`,\n ` import RefreshRuntime from '${this.#hotAsset('@react-refresh')}'`,\n ' RefreshRuntime.injectIntoGlobalHook(window)',\n ' window.$RefreshReg$ = () => {}',\n ' window.$RefreshSig$ = () => (type) => type',\n ' window.__vite_plugin_react_preamble_installed__ = true',\n '</script>',\n ].join('\\n'),\n )\n }\n\n /** The URL of a processed asset (Vite::asset('resources/images/logo.svg')). */\n asset(path: string, buildDirectory = this.#buildDirectory): string {\n if (this.isRunningHot()) return this.#hotAsset(path)\n return this.#assetPath(`${buildDirectory}/${this.#chunk(this.manifest(buildDirectory), path).file}`)\n }\n\n /** The built file's contents (Vite::content()). */\n content(path: string, buildDirectory = this.#buildDirectory): string {\n const chunk = this.#chunk(this.manifest(buildDirectory), path)\n const file = this.app.publicPath(join(buildDirectory, chunk.file))\n if (!existsSync(file)) throw new ViteError(`Unable to locate file from Vite manifest: ${file}.`)\n return readFileSync(file, 'utf8')\n }\n\n /** md5 of the manifest (a cache-busting asset version); undefined while hot or without a build. */\n manifestHash(buildDirectory = this.#buildDirectory): string | undefined {\n if (this.isRunningHot()) return undefined\n const path = this.manifestPath(buildDirectory)\n return existsSync(path) ? createHash('md5').update(readFileSync(path)).digest('hex') : undefined\n }\n\n manifestPath(buildDirectory = this.#buildDirectory): string {\n return this.app.publicPath(join(buildDirectory, this.#manifestFilename))\n }\n\n manifest(buildDirectory = this.#buildDirectory): Manifest {\n const path = this.manifestPath(buildDirectory)\n if (!existsSync(path)) throw new ViteError(`Vite manifest not found at: ${path}`)\n const { mtimeMs } = statSync(path)\n const cached = manifests.get(path)\n if (cached !== undefined && cached.mtimeMs === mtimeMs) return cached.manifest\n const manifest = JSON.parse(readFileSync(path, 'utf8')) as Manifest\n manifests.set(path, { mtimeMs, manifest })\n return manifest\n }\n\n /** URL → the attributes of the preload tags rendered so far (without href), for Link headers. */\n preloadedAssets(): Record<string, string[]> {\n return { ...this.#preloaded }\n }\n\n /** Renders withEntryPoints() (Vite is Htmlable, like Laravel's). */\n toHtml(): string {\n return this.tags(this.#entryPoints).toHtml()\n }\n\n // Internals ------------------------------------------------------------------------------------------------\n\n #hotAsset(path: string): string {\n return `${this.devServerUrl() ?? ''}/${path}`\n }\n\n #assetPath(path: string): string {\n if (this.#assetPathResolver !== undefined) return this.#assetPathResolver(path)\n if (this.app.bound(UrlGenerator)) return this.app.make(UrlGenerator).asset(path)\n const base = this.app.bound(ConfigRepository) ? this.app.make(ConfigRepository).get<string | null>('app.asset_url', null) : null\n return `${(base ?? '').replace(/\\/+$/, '')}/${path.replace(/^\\/+/, '')}`\n }\n\n #chunk(manifest: Manifest, file: string): ManifestChunk {\n const chunk = manifest[file]\n if (chunk === undefined) throw new ViteError(`Unable to locate file in Vite manifest: ${file}.`)\n return chunk\n }\n\n /** Every static import, depth first, each once. */\n #resolveImports(manifest: Manifest, chunk: ManifestChunk, seen = new Set<string>()): string[] {\n const imports: string[] = []\n for (const name of chunk.imports ?? []) {\n if (seen.has(name)) continue\n seen.add(name)\n imports.push(name)\n const imported = manifest[name]\n if (imported !== undefined) imports.push(...this.#resolveImports(manifest, imported, seen))\n }\n return imports\n }\n\n #tagForChunk(src: string, url: string, chunk: ManifestChunk | undefined, manifest: Manifest | undefined): string {\n if (CSS_PATH.test(url)) {\n const attributes = this.#parseAttributes({ rel: 'stylesheet', href: url, nonce: this.#nonce ?? false, ...TRACKED, ...this.#styleAttributes(src, url, chunk, manifest) })\n return `<link ${attributes.join(' ')} />`\n }\n const attributes = this.#parseAttributes({ type: 'module', src: url, nonce: this.#nonce ?? false, ...TRACKED, ...this.#scriptAttributes(src, url, chunk, manifest) })\n return `<script ${attributes.join(' ')}></script>`\n }\n\n #preloadTag(src: string, url: string, chunk: ManifestChunk | undefined, manifest: Manifest): string {\n const css = CSS_PATH.test(url)\n let attributes: TagAttributes = {\n rel: css ? 'preload' : 'modulepreload',\n as: css ? 'style' : 'script',\n href: url,\n nonce: this.#nonce ?? false,\n crossorigin: (css ? this.#styleAttributes(src, url, chunk, manifest) : this.#scriptAttributes(src, url, chunk, manifest)).crossorigin ?? false,\n }\n if (this.#integrityKey !== false) attributes.integrity = (chunk?.[this.#integrityKey] as string | undefined) ?? false\n for (const resolver of this.#preloadResolvers) {\n const resolved = resolver(src, url, chunk, manifest)\n if (resolved === false) return ''\n attributes = { ...attributes, ...resolved }\n }\n const { href: _href, ...rest } = attributes\n this.#preloaded[url] = this.#parseAttributes(rest)\n return `<link ${this.#parseAttributes(attributes).join(' ')} />`\n }\n\n #scriptAttributes(src: string, url: string, chunk: ManifestChunk | undefined, manifest: Manifest | undefined): TagAttributes {\n let attributes: TagAttributes = this.#integrityKey !== false ? { integrity: (chunk?.[this.#integrityKey] as string | undefined) ?? false } : {}\n for (const resolver of this.#scriptResolvers) attributes = { ...attributes, ...resolver(src, url, chunk, manifest) }\n return attributes\n }\n\n #styleAttributes(src: string, url: string, chunk: ManifestChunk | undefined, manifest: Manifest | undefined): TagAttributes {\n let attributes: TagAttributes = this.#integrityKey !== false ? { integrity: (chunk?.[this.#integrityKey] as string | undefined) ?? false } : {}\n for (const resolver of this.#styleResolvers) attributes = { ...attributes, ...resolver(src, url, chunk, manifest) }\n return attributes\n }\n\n /** false/null/undefined are dropped, true is a bare attribute, anything else name=\"value\". */\n #parseAttributes(attributes: TagAttributes): string[] {\n return Object.entries(attributes)\n .filter(([, value]) => value !== false && value !== null && value !== undefined)\n .map(([name, value]) => (value === true ? name : `${name}=\"${escapeAttribute(String(value))}\"`))\n }\n}\n\n/**\n * The Vite instance for the current context: the request's own (scoped, so a CSP nonce stays in its request),\n * else a fresh one for the application (a mail view rendered by a queue worker).\n */\nexport function currentVite(): Vite {\n const container = currentContainer()\n if (container === undefined) throw new ContainerNotAvailableError('Vite')\n if (container.bound(HttpRequest)) return container.make(Vite)\n return new Vite(container.make(ApplicationToken))\n}\n\n/** vite(['resources/js/app.tsx']) → the tags (Laravel's @vite); vite() → the Vite instance. */\nexport function vite(): Vite\nexport function vite(entryPoints: string | string[], buildDirectory?: string): ViteHtml\nexport function vite(entryPoints?: string | string[], buildDirectory?: string): Vite | ViteHtml {\n const instance = currentVite()\n return entryPoints === undefined ? instance : instance.tags(entryPoints, buildDirectory)\n}\n\n/** Laravel's @viteReactRefresh: put it before vite([...]) in the root view of a React app. */\nexport function viteReactRefresh(): ViteHtml | undefined {\n return currentVite().reactRefresh()\n}\n","import type { HttpKernel } from '@orieljs/contracts'\n\ntype Handler = (request: Request) => unknown\n\n/** Wave 0 stand-in for the Http kernel: exact \"METHOD /path\" matching only. Replaced by Wave 1's router. */\nexport class ClosureKernel implements HttpKernel {\n private readonly routes = new Map<string, Handler>()\n\n on(method: string, path: string, handler: Handler): this {\n this.routes.set(`${method.toUpperCase()} ${path}`, handler)\n return this\n }\n\n async handle(request: Request): Promise<Response> {\n const handler = this.routes.get(`${request.method} ${new URL(request.url).pathname}`)\n if (!handler) return new Response('Not Found', { status: 404, headers: { 'content-type': 'text/plain; charset=utf-8' } })\n return toResponse(await handler(request))\n }\n}\n\nfunction toResponse(output: unknown): Response {\n if (output instanceof Response) return output\n if (output === undefined || output === null) return new Response(null, { status: 204 })\n if (typeof output === 'string') return new Response(output, { headers: { 'content-type': 'text/html; charset=utf-8' } })\n return Response.json(output)\n}\n"],"mappings":";AAAA,SAAS,QAAAA,aAAY;AACrB;AAAA,EACE,eAAeC;AAAA,EACf,iBAAiB;AAAA,EACjB,oBAAAC;AAAA,EACA;AAAA,OAIK;AACP,SAAS,iBAAiB;AAC1B,SAAS,eAAe,WAAW;;;ACXnC,SAAS,YAAY,YAAY;AACjC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAMK;AACP,SAAS,mBAAmB,iBAAiB,kBAAkB;AAexD,IAAM,qBAAN,MAAyB;AAAA,EAM9B,YAA6B,KAAkB;AAAlB;AAAA,EAAmB;AAAA,EAAnB;AAAA,EALZ,YAA2D,CAAC;AAAA,EAC5D,aAAkE,CAAC;AAAA,EACnE,aAAkE,CAAC;AAAA,EAC5E;AAAA,EAIR,cAAc,YAA2D,C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;AAAA,IACxB,SAAS,OAAO;AACd,YAAM,IAAI,kBAAkB,SAAS,YAAY,MAAM,KAAK;AAAA,IAC9D;AAAA,EACF;AACF;;;AInLO,IAAM,gBAAN,MAA0C;AAAA,EAC9B,SAAS,oBAAI,IAAqB;AAAA,EAEnD,GAAG,QAAgB,MAAc,SAAwB;AACvD,SAAK,OAAO,IAAI,GAAG,OAAO,YAAY,CAAC,IAAI,IAAI,IAAI,OAAO;AAC1D,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,OAAO,SAAqC;AAChD,UAAM,UAAU,KAAK,OAAO,IAAI,GAAG,QAAQ,MAAM,IAAI,IAAI,IAAI,QAAQ,GAAG,EAAE,QAAQ,EAAE;AACpF,QAAI,CAAC,QAAS,QAAO,IAAI,SAAS,aAAa,EAAE,QAAQ,KAAK,SAAS,EAAE,gBAAgB,4BAA4B,EAAE,CAAC;AACxH,WAAO,WAAW,MAAM,QAAQ,OAAO,CAAC;AAAA,EAC1C;AACF;AAEA,SAAS,WAAW,QAA2B;AAC7C,MAAI,kBAAkB,SAAU,QAAO;AACvC,MAAI,WAAW,UAAa,WAAW,KAAM,QAAO,IAAI,SAAS,MAAM,EAAE,QAAQ,IAAI,CAAC;AACtF,MAAI,OAAO,WAAW,SAAU,QAAO,IAAI,SAAS,QAAQ,EAAE,SAAS,EAAE,gBAAgB,2BAA2B,EAAE,CAAC;AACvH,SAAO,SAAS,KAAK,MAAM;AAC7B;","names":["join","ApplicationToken","ConfigRepository","join","ConfigRepository","attributes","ApplicationToken","join","ConfigRepository"]}
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@orieljs/foundation",
3
- "version": "0.1.0-alpha.1",
3
+ "version": "0.1.0-alpha.10",
4
4
  "description": "The Oriel application: service providers, lifecycle and request handling.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
7
+ "homepage": "https://orieljs.vercel.app",
7
8
  "sideEffects": false,
8
9
  "repository": {
9
10
  "type": "git",
@@ -26,13 +27,14 @@
26
27
  "files": [
27
28
  "dist",
28
29
  "LICENSE",
29
- "NOTICE"
30
+ "NOTICE",
31
+ "TRADEMARKS.md"
30
32
  ],
31
33
  "dependencies": {
32
- "@orieljs/config": "0.1.0-alpha.1",
33
- "@orieljs/contracts": "0.1.0-alpha.1",
34
- "@orieljs/container": "0.1.0-alpha.1",
35
- "@orieljs/support": "0.1.0-alpha.1"
34
+ "@orieljs/container": "0.1.0-alpha.10",
35
+ "@orieljs/support": "0.1.0-alpha.10",
36
+ "@orieljs/config": "0.1.0-alpha.10",
37
+ "@orieljs/contracts": "0.1.0-alpha.10"
36
38
  },
37
39
  "scripts": {
38
40
  "build": "tsup && node ../../../scripts/copy-license.mjs"