New:Socket for Asana Is Now Available.Learn more
Get Started

@ultimat3/core

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ultimat3/core - npm Package Compare versions

Comparing version
18.0.0
to
19.0.0
+2
-2
package.json
{
"name": "@ultimat3/core",
"version": "18.0.0",
"version": "19.0.0",
"description": "Ultimate's foundation: errors, context, env, config, clock, ids, logging, telemetry, lifecycle",

@@ -40,4 +40,4 @@ "license": "MIT",

"dependencies": {
"@ultimat3/schema": "18.0.0"
"@ultimat3/schema": "19.0.0"
}
}

@@ -14,5 +14,2 @@ // Single responsibility: the `pwa` block of `app.config.ts` — what an app must say before a

import { describeValue } from './error-render';
// `app.config.ts` CONSUMES the route vocabulary; it does not own it — `config.ts`'s rule, and the
// reason `OfflineStrategy` is imported rather than restated.
import type { OfflineStrategy } from './route-vocabulary';

@@ -24,5 +21,27 @@ /**

*/
/**
* What the service worker needs that no route can say for itself.
*
* `fallback` is the document a navigation gets when the network is gone and the cache has no
* answer — the one thing an offline app cannot do without, and the reason this block replaced a
* bare `offline: OfflineStrategy`. That key was an app-wide DEFAULT for a field `defineRoute`
* makes **required** on every route (`route.ts` refuses a route without one), so it defaulted
* nothing, was read by nobody, and could not be given a reader without inventing a meaning for it
* (#390).
*
* The other three are `@ultimat3/pwa`'s `OfflineConfig` verbatim, and each is read by the emitter
* that builds `sw.js`: a placeholder image, a placeholder font, and the request patterns that must
* never be answered from a cache — auth and payments, where a stale 200 is worse than a failure.
*/
export interface PwaOfflineConfig {
/** Absolute route path of the offline document, e.g. `/offline`. Required once `enabled`. */
readonly fallback: string | null;
readonly image: string | null;
readonly font: string | null;
readonly neverCache: readonly string[];
}
export interface PwaConfig {
readonly enabled: boolean;
readonly offline: OfflineStrategy;
readonly offline: PwaOfflineConfig;
readonly backgroundSync: boolean;

@@ -84,3 +103,3 @@ readonly push: boolean;

export const PWA_FIX =
"in app.config.ts, complete the pwa block: pwa: { enabled: true, offline: 'runtime', name: 'My App', colors: { light: { themeColor: '#1b1f3b', backgroundColor: '#ffffff' }, dark: { themeColor: '#1b1f3b', backgroundColor: '#0b0d1a' } } } — a browser paints the install splash and the address bar from those four values before any stylesheet loads, so there is nothing for the framework to derive them from; or set pwa.enabled: false";
"in app.config.ts, complete the pwa block: pwa: { enabled: true, offline: { fallback: '/offline' }, name: 'My App', colors: { light: { themeColor: '#1b1f3b', backgroundColor: '#ffffff' }, dark: { themeColor: '#1b1f3b', backgroundColor: '#0b0d1a' } } } — a browser paints the install splash and the address bar from those four values before any stylesheet loads, so there is nothing for the framework to derive them from, and offline.fallback is the document the emitted sw.js serves when the network is gone, so add a route at that path too; or set pwa.enabled: false";

@@ -102,2 +121,14 @@ /**

}
// An ABSOLUTE path, screened here rather than at emit for this file's own stated reason: a
// relative one resolves against whatever document registered the worker, so `offline` served
// under `/posts/1` is `/posts/offline` — a 404 cached as the answer to every offline navigation.
// `pwa.enabled` means an installable app, and an installable app that shows the browser's error
// page offline is the failure the whole block exists to prevent, so this is required rather
// than optional: the alternative is two meanings for one switch (axiom 1).
const fallback: unknown = pwa.offline?.fallback;
if (typeof fallback !== 'string' || !fallback.startsWith('/')) {
issues.push(
`pwa.offline.fallback is required when pwa.enabled is true and must be an absolute route path like "/offline", and is ${describeValue(fallback)}`,
);
}
// `typeof !== 'object' || null`, never `=== undefined`: an untyped `app.config.ts` writing

@@ -104,0 +135,0 @@ // `pwa.colors: null` reached `null[scheme]` one line down and took the boot out with a native

@@ -10,3 +10,3 @@ // Single responsibility: `app.config.ts` — the one config file. Deeply optional with real

import { CACHE_TIERS, type CacheTierName } from './cache-vocabulary';
import type { PwaConfig } from './config-pwa';
import type { PwaConfig, PwaOfflineConfig } from './config-pwa';
import { PWA_FIX, pwaIssues } from './config-pwa';

@@ -201,2 +201,13 @@ import { describeValue } from './error-render';

/**
* `offline` is NESTED for `AiConfigInput`'s reason, and here it is load-bearing rather than
* ergonomic: `section` applies a patch ONE level deep, so an app writing
* `offline: { fallback: '/offline' }` under a flat `Input<PwaConfig>` would replace the whole
* default block — leaving `image`, `font` and `neverCache` absent at run time while the type says
* they are there, which is the exact shape of defect this repo keeps re-shipping.
*/
export interface PwaConfigInput extends Omit<Input<PwaConfig>, 'offline'> {
readonly offline?: Input<PwaOfflineConfig> | undefined;
}
export interface AppConfigInput {

@@ -210,3 +221,3 @@ readonly name: string;

readonly auth?: Input<AuthConfig> | undefined;
readonly pwa?: Input<PwaConfig> | undefined;
readonly pwa?: PwaConfigInput | undefined;
readonly roles?: readonly Role[] | undefined;

@@ -266,3 +277,3 @@ readonly database?: Input<DatabaseConfig> | undefined;

enabled: false,
offline: 'network-only',
offline: { fallback: null, image: null, font: null, neverCache: [] },
backgroundSync: false,

@@ -412,3 +423,9 @@ push: false,

auth: section(base.auth, merged.auth),
pwa: section(base.pwa, merged.pwa),
// Two `section` calls, one per level: the outer one may not see `offline` at all, or it would
// drop the nested defaults `PwaConfigInput` exists to keep. Hence the cast — the outer patch is
// this block minus the key the inner call owns.
pwa: {
...section(base.pwa, { ...merged.pwa, offline: undefined } as Input<PwaConfig>),
offline: section(base.pwa.offline, merged.pwa?.offline),
},
roles: merged.roles ?? base.roles,

@@ -415,0 +432,0 @@ database: section(base.database, merged.database),

@@ -8,2 +8,13 @@ // Single responsibility: the public API of @ultimat3/core. Explicit named exports only —

// Anchored on purpose, and NOT by the `sideEffects` array: Bun reads any array as `false` and drops
// the module regardless (oven-sh/bun#40650). This module registers @ultimat3/schema's error TITLES,
// because schema is tier 0 and cannot register its own — and what reads them is `UltimateError`'s
// constructor, which never imports this file. Shaken out, every X_VALIDATION_FAILED renders
// untitled in the browser with nothing to say why. `SIDE_EFFECTS_ANCHORS` carries the argument and
// `bun run side-effects` enforces it. `context.ts`, `lifecycle-errors.ts` and `secrets-errors.ts`
// are declared side-effecting too and are deliberately NOT anchored: each is reached by whatever
// uses it, and anchoring `context.ts` alone measured +3,485 B on a browser chunk for a provider a
// browser can never fire.
import './schema-error-codes';
export type {

@@ -70,2 +81,3 @@ Actor,

NotifyConfig,
PwaConfigInput,
RealtimeConfig,

@@ -77,3 +89,3 @@ RealtimeTransport,

export { defineConfig, INBOX_RETENTION_KEYS } from './config';
export type { PwaColors, PwaConfig, PwaSchemeColors } from './config-pwa';
export type { PwaColors, PwaConfig, PwaOfflineConfig, PwaSchemeColors } from './config-pwa';
export { PWA_COLOR_KEYS, PWA_SCHEMES } from './config-pwa';

@@ -80,0 +92,0 @@ export type { Ctx, CtxFacts, CtxInit, CtxPatch, CtxServices, ServiceBag } from './context';