Skip to content

Commit

Permalink
Project update. [p][robotic]
Browse files Browse the repository at this point in the history
  • Loading branch information
jaswrks committed Apr 10, 2024
1 parent d48d015 commit 600ab75
Show file tree
Hide file tree
Showing 25 changed files with 94 additions and 94 deletions.
2 changes: 1 addition & 1 deletion .browserslistrc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# Generated data.
# <generated:start>

# Last generated Apr 10, 2024 9:46 AM UTC.
# Last generated Apr 10, 2024 4:12 PM UTC.

[production]
node >= 20.9.0
Expand Down
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# Generated data.
# <generated:start>

# Last generated Apr 10, 2024 9:46 AM UTC.
# Last generated Apr 10, 2024 4:12 PM UTC.

# Locals

Expand Down
8 changes: 4 additions & 4 deletions .env.vault
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ DOTENV_VAULT_MAIN="7GW98NfL4hM4N6HbfeDXCKreVxKvcVPupFRnZ8XJ+pomaQ=="
DOTENV_VAULT_MAIN_VERSION=1

# dev
DOTENV_VAULT_DEV="iMpmkYahchAi8gImK1VPJI2wyOBc9o3kZjAo36ScEbMMxdKwCZ+C2zHWIMSD1U4GcQ3Zea3xMy1d1mmSDVm9zxcvfmn9efB/OW9RL8M+txn4tI34sQBt6CQFxc5j/Sb9b2bkn2Jb4ziojgFAeP2j1jvcNpLvAWtitz4gTWcKMF45dvuMTE742K5p94sI6elcdsSJ1MPUQHJWdPg6vcBJ+aVF3gUGSZ1TD5LxK1eA0IPqjfvtCIoibq3q0ll2DX2i1w=="
DOTENV_VAULT_DEV_VERSION=527
DOTENV_VAULT_DEV="HYPSsg4c0QBF8fdfe0JjQ4OxvNjEc1jA8c1A9S1IZ4p2rH9ttaC7ef0EBDfnTcCO5PnT0wf6RW0kkFfPQRCGc/t+SmgI8t6LZayV7flNLWyHz96VQATPv3Q54qJ05TVDAcTDzCBPTrvYZUTxjeuqaCShbcidKd4QBrIhsXAQ3BgvLofPacuAoK3tjZW9KLFDtJGFinmXJIvRR/9R7ywd96DLgeGAV3bSDeckBAwqWYD7FXnK6lLua4qQJfk+NbM2Jw=="
DOTENV_VAULT_DEV_VERSION=529

# ci
DOTENV_VAULT_CI="3WIzrP5/8dwL17WRDBVa4zfnGecoWjABco/Vxkwtr/olqvp0Zusjz8b+qwCyau3k2g1R28mZUXRbRmzab1oIY6nGCp3kbzYmeQ8SvNzZATD4AKBN89H74Zk5JSliwB08D4f9OyN6OKG0t1cjBTWZkqnDzOpbIMCfJH+Ag2Kubw=="
DOTENV_VAULT_CI_VERSION=527
DOTENV_VAULT_CI="SgaUMIwLktQf9g0uHh7Jf4S8sMnd8EBf0zalGqaDqmfpe6z0HAGw5i7wFYPiWHgkAaikAk9nmGswE4DjjpU9vp5V5xrpb0T2v1AWmj541c75TWxZEnKP5P4Dl8S/fm/WwauPxh23Try2QKfLQLxN4wYHthB90+5bRo9fC9dB1g=="
DOTENV_VAULT_CI_VERSION=529

# stage
DOTENV_VAULT_STAGE="aRP8su2YV4jZu3w1HZ/SLaots0IwJDFw75TCpvXEFeNp7tw="
Expand Down
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# Generated data.
# <generated:start>

# Last generated Apr 10, 2024 9:46 AM UTC.
# Last generated Apr 10, 2024 4:12 PM UTC.

# Default

Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# Generated data.
# <generated:start>

# Last generated Apr 10, 2024 9:46 AM UTC.
# Last generated Apr 10, 2024 4:12 PM UTC.

# Locals

Expand Down
2 changes: 1 addition & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# Generated data.
# <generated:start>

# Last generated Apr 10, 2024 9:46 AM UTC.
# Last generated Apr 10, 2024 4:12 PM UTC.

# Locals

Expand Down
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# Generated data.
# <generated:start>

# Last generated Apr 10, 2024 9:46 AM UTC.
# Last generated Apr 10, 2024 4:12 PM UTC.

# Packages

Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @note This entire file will be updated automatically.
* @note Instead of editing here, please review `./settings.mjs`.
*
* Last generated using `./settings.mjs` Apr 10, 2024 9:46 AM UTC.
* Last generated using `./settings.mjs` Apr 10, 2024 4:12 PM UTC.
*/
{
"editor.formatOnType": false,
Expand Down
2 changes: 1 addition & 1 deletion .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# Generated data.
# <generated:start>

# Last generated Apr 10, 2024 9:46 AM UTC.
# Last generated Apr 10, 2024 4:12 PM UTC.

# Locals

Expand Down
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"publishConfig": {
"access": "public"
},
"version": "1.0.950",
"version": "1.0.951",
"license": "GPL-3.0-or-later",
"name": "@clevercanyon/utilities",
"description": "Utilities for JavaScript apps running in any environment.",
Expand Down
8 changes: 4 additions & 4 deletions src/preact/components/data.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export const namedPropKeys = (): string[] => passableStateKeys as unknown as str
/**
* Defines default global object path.
*
* This is also called upon by our ISO prerenderer.
* This is also called upon by our ISO renderer.
*
* @returns Default global object path string.
*/
Expand All @@ -253,7 +253,7 @@ export const defaultGlobalObp = (): string => {
/**
* Defines default fetcher.
*
* This is also called upon by our ISO prerenderer.
* This is also called upon by our ISO renderer.
*
* @param c9rProps Constructor props.
*
Expand All @@ -266,7 +266,7 @@ export const defaultFetcher = (c9rProps?: FetcherC9rProps): $type.Fetcher => {
/**
* Defines default lazy component promises.
*
* This is also called upon by our ISO prerenderer.
* This is also called upon by our ISO renderer.
*
* @returns {@see LazyComponentPromises} Default lazy CPs.
*/
Expand Down Expand Up @@ -309,7 +309,7 @@ export const globalToScriptCode = (state: State): string => {
*
* We use a replacement code because when rendering server-side, fetcher state can be updated by any component; i.e., as
* rendering occurs throughout a vNode tree. Therefore, it’s not until server-side rendering is completely finished that
* we can inject a fetcher’s global script code. {@see $preact.iso.prerenderSPA()}.
* we can inject a fetcher’s global script code. {@see $preact.iso.renderSPA()}.
*
* @returns Replacement code for `fetcher.globalToScriptCode`.
*/
Expand Down
10 changes: 5 additions & 5 deletions src/preact/components/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ function RouterCore(this: $preact.Component<CoreProps>, _props: CoreProps): $pre
});
// It is possible for this to render with `matchingChildVNode` & `defaultChildVNode` both empty.
// In such a case, there are simply no children to render in the current route. Therefore, it becomes
// important for a top-level prerenderer to look for routes that are entirely empty; treating as a 404 error.
// important for a top-level renderer to look for routes that are entirely empty; treating as a 404 error.
return <RouteContextObject.Provider value={currentRouteContext.current}>{matchingChildVNode || defaultChildVNode}</RouteContextObject.Provider>;
//
}, [parentContext.current, childArray.current.length, locationState.current]);
Expand Down Expand Up @@ -586,8 +586,8 @@ const xPreactAppLoading = $fnꓺmemo((): Element => {
/**
* Previous error handler.
*
* While error boundaries work when prerenderering, error handlers set via options run client-side only; i.e., not when
* prerendering. Instead, thrown values bubble up to our prerenderer, which catches; e.g., thrown promises.
* While error boundaries work when rendering server-side, error handlers set via options run client-side only; i.e.,
* not when rendering server-side. Instead, thrown values bubble up and we catch thrown promises.
*
* @note Inspired by `Suspense` from preact/compat. See: <https://o5p.me/TA863r>.
* @note `__e` = `._catchError`; {@see https://o5p.me/DxqGM3} in `mangle.json`.
Expand All @@ -597,8 +597,8 @@ const prevErrorHandler = (preactꓺoptions as unknown as $type.Object).__e;
/**
* Configures error handler in support of lazy loads.
*
* While error boundaries work when prerenderering, error handlers set via options run client-side only; i.e., not when
* prerendering. Instead, thrown values bubble up to our prerenderer, which catches; e.g., thrown promises.
* While error boundaries work when rendering server-side, error handlers set via options run client-side only; i.e.,
* not when rendering server-side. Instead, thrown values bubble up and we catch thrown promises.
*
* @param args Variadic args passed in by error hook in preact core.
*
Expand Down
48 changes: 24 additions & 24 deletions src/resources/preact/apis/iso.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ import { Route, default as Router, type RoutedProps, type Props as RouterProps }
/**
* Defines types.
*/
export type PrerenderSPAOptions = {
export type RenderSPAOptions = {
request: $type.Request;
appManifest: AppManifest;
App: $preact.AnyComponent<RootProps>;
cfw?: $type.$cfw.RequestContextData;
props?: RootProps;
};
export type PrerenderSPAPromise = Promise<{
export type RenderedSPAPromise = Promise<{
httpState: HTTPState;
docType: string;
html: string;
}>;
export type HydrativelyRenderSPAOptions = {
export type HydrateSPAOptions = {
App: $preact.AnyComponent<RootProps>;
props?: RootProps;
};
Expand Down Expand Up @@ -56,31 +56,31 @@ export type LazyRouterProps = Omit<RouterProps, 'children'>; // Except, no `chil
export type LazyRouterVNode = $preact.VNode<LazyRouterProps>;

// ---
// Prerender utilities.
// Render utilities.

/**
* Prerenders SPA component server-side.
* Renders SPA server-side.
*
* A request-specific {@see HTTPState} must be passed down through props when prerendering, such that it can be
* referenced immediately after; i.e., to determine, potentially modify, and ultimately return HTTP state.
* A request-specific {@see HTTPState} must be passed down through props when rendering, such that it can be referenced
* immediately after; i.e., to determine, potentially modify, and ultimately return HTTP state.
*
* A request-specific {@see $type.Fetcher} instance must also be passed down through props when prerendering, such that
* the same fetcher instance survives potentially multiple prerender passes; e.g., on thrown promises. Otherwise, a new
* fetcher instance would be created each time by `<Data>`, resulting in our fetcher cache resetting each time.
* A request-specific {@see $type.Fetcher} instance must also be passed down through props when rendering, such that the
* same fetcher instance survives potentially multiple render passes; e.g., on thrown promises. Otherwise, a new fetcher
* instance would be created each time by `<Data>`, resulting in our fetcher cache resetting each time.
*
* The same is true for `lazyCPs`, which are {@see $preact.iso.LazyComponentPromises}. They must also persist state
* between prerender passes, such that their state is not lost from one prerender pass to the next.
* between render passes, such that their state is not lost from one render pass to the next.
*
* @param options Options; {@see PrerenderSPAOptions}.
* @param options Options; {@see RenderSPAOptions}.
*
* @returns Prerendered SPA promise; {@see PrerenderSPAPromise}.
* @returns Rendered SPA promise; {@see RenderedSPAPromise}.
*
* @requiredEnv ssr -- This utility must only be used server-side.
*/
export const prerenderSPA = async (options: PrerenderSPAOptions): PrerenderSPAPromise => {
export const renderSPA = async (options: RenderSPAOptions): RenderedSPAPromise => {
if (!$env.isSSR()) throw Error('kTqymmPe');

const opts = $obj.defaults({}, options || {}, { props: {} }) as Required<PrerenderSPAOptions>,
const opts = $obj.defaults({}, options || {}, { props: {} }) as Required<RenderSPAOptions>,
{ request, appManifest, App, cfw, props } = opts,
//
httpState = props.httpState || {},
Expand Down Expand Up @@ -134,13 +134,13 @@ export const prerenderSPA = async (options: PrerenderSPAOptions): PrerenderSPAPr
// Hydration utilities.

/**
* Hydratively renders SPA component on client-side.
* Hydrates SPA client-side.
*
* @param options Options; {@see HydrativelyRenderSPAOptions}.
* @param options Options; {@see HydrateSPAOptions}.
*
* @requiredEnv web -- This utility must only be used client-side.
*/
export const hydrativelyRenderSPA = async (options: HydrativelyRenderSPAOptions): Promise<void> => {
export const hydrateSPA = async (options: HydrateSPAOptions): Promise<void> => {
if (!$env.isWeb()) throw Error('N4WUN2gk');

const appSelectors = 'body > x-preact-app',
Expand All @@ -161,9 +161,9 @@ export const hydrativelyRenderSPA = async (options: HydrativelyRenderSPAOptions)
}

/**
* Regarding `<App>` props from server-side prerender. The thing to keep in mind is that if SSR props were used to
* affect a prerender, then those exact same props should also be given when hydrating on the web. Otherwise, there
* will be many problems. So long as that’s the case, though, everything will be just fine.
* Regarding `<App>` props from server-side render. The thing to keep in mind is that if SSR props were used to
* affect a server-side render, then those exact same props should also be given when hydrating on the web.
* Otherwise, there will be problems. So long as that’s the case, though, everything will be just fine.
*
* `<HTTP>` props.
*
Expand All @@ -176,8 +176,8 @@ export const hydrativelyRenderSPA = async (options: HydrativelyRenderSPAOptions)
* `<Data>` props.
*
* - `cspNonce`: If not already in props, `<Data>` uses global state from script code.
* - `fetcher`: If not already in props, `<Data>` uses the same default as prerender does.
* - `lazyCPs`: If not already in props, `<Data>` uses the same default as prerender does.
* - `fetcher`: If not already in props, `<Data>` uses the same default as renderSPA does.
* - `lazyCPs`: If not already in props, `<Data>` uses the same default as renderSPA does.
* - `head`: If not already in props, `<Data>` uses global state from script code.
*/
};
Expand Down Expand Up @@ -252,7 +252,7 @@ export const lazyComponent = <Props extends $preact.AnyProps>(fn: $preact.AsyncF
throw promise.current;
};
return (props?: Props): LazyRouterVNode => {
const isSSR = $env.isSSR(), // Server-side prerender?
const isSSR = $env.isSSR(), // Server-side render?
{ state: { lazyCPs } } = $preact.useData(); // prettier-ignore

let lazyCPi = 0; // Promise index.
Expand Down
Loading

0 comments on commit 600ab75

Please sign in to comment.