kizlo 0.22.1 → 0.24.0
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/dist/cli/daemon/generate.js +12 -1
- package/dist/client.d.ts +30 -7
- package/dist/client.js +3 -0
- package/dist/index.d.ts +2 -2
- package/dist/integrations/astro/kizlo.client.d.ts +2 -3
- package/dist/integrations/astro/kizlo.client.js +4 -7
- package/dist/integrations/nextjs/kizlo.client.d.ts +2 -3
- package/dist/integrations/nextjs/kizlo.client.js +4 -7
- package/dist/integrations/tanstack-start/kizlo.client.d.ts +2 -3
- package/dist/integrations/tanstack-start/kizlo.client.js +4 -7
- package/dist/package.js +1 -1
- package/dist/react.d.ts +56 -0
- package/dist/react.js +54 -0
- package/package.json +7 -1
|
@@ -17,12 +17,23 @@ import fs from "node:fs";
|
|
|
17
17
|
* The generated barrel is also written as a stub by `kizlo init`. It re-exports `introspection`
|
|
18
18
|
* rather than pre-wrapping it: a server entry passes `createKizlo({ introspection })` itself, so the
|
|
19
19
|
* rest of the options stay visible at the call site instead of hiding inside a generated object.
|
|
20
|
+
*
|
|
21
|
+
* `contract` is left with the JSON's own type and the project's `procedures` are registered instead.
|
|
22
|
+
* The old `as unknown as typeof procedures` asserted that the committed JSON and the exported tree
|
|
23
|
+
* agreed rather than establishing it, and left the client type reachable only by holding the value.
|
|
20
24
|
*/
|
|
21
25
|
const CONTRACT_BARREL = [
|
|
22
26
|
`import type { procedures } from ".."`,
|
|
23
27
|
`import contractJson from "./contract.json"`,
|
|
24
28
|
``,
|
|
25
|
-
`export const contract = contractJson
|
|
29
|
+
`export const contract = contractJson`,
|
|
30
|
+
``,
|
|
31
|
+
`declare module "kizlo" {`,
|
|
32
|
+
`\tinterface KizloProcedureRegistry {`,
|
|
33
|
+
`\t\tprocedures: typeof procedures`,
|
|
34
|
+
`\t}`,
|
|
35
|
+
`}`,
|
|
36
|
+
``,
|
|
26
37
|
`export { introspection, type WordPressClient } from "./introspection"`,
|
|
27
38
|
``
|
|
28
39
|
].join("\n");
|
package/dist/client.d.ts
CHANGED
|
@@ -2,23 +2,46 @@ import { AnyProcedureTree, ExtractProcedureByScope } from "./shared/procedure.js
|
|
|
2
2
|
import { ResultClient } from "./shared/result.js";
|
|
3
3
|
|
|
4
4
|
//#region src/client.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Generated code augments this in the project that owns the contract: `kizlo generate` writes a
|
|
8
|
+
* barrel that registers its `procedures` here, which is what gives {@link ActiveKizloClient} that
|
|
9
|
+
* project's own types without a cast.
|
|
10
|
+
*/
|
|
11
|
+
interface KizloProcedureRegistry {}
|
|
12
|
+
/**
|
|
13
|
+
* The browser client this project compiles against. The `any` short-circuit is on the whole client
|
|
14
|
+
* rather than on the procedure tree: passing `any` through `ResultClient` distributes to a union
|
|
15
|
+
* whose second property access fails, so an unregistered project would stop compiling instead of
|
|
16
|
+
* staying loose.
|
|
17
|
+
*/
|
|
18
|
+
type ActiveKizloClient = KizloProcedureRegistry extends {
|
|
19
|
+
procedures: infer TProcedures extends AnyProcedureTree;
|
|
20
|
+
} ? ResultClient<ExtractProcedureByScope<TProcedures, "remote" | "api">> : any;
|
|
21
|
+
/** What {@link createKizloClient} returns: a {@link KizloClient} typed from the registry instead of its argument. */
|
|
22
|
+
interface KizloBrowserClient {
|
|
23
|
+
readonly client: ActiveKizloClient;
|
|
24
|
+
}
|
|
5
25
|
interface KizloClientConfig<T extends AnyProcedureTree> {
|
|
6
26
|
url?: string;
|
|
7
27
|
contract: T;
|
|
8
28
|
fetch?: (request: Request) => Promise<Response>;
|
|
9
29
|
}
|
|
10
|
-
declare class KizloClient<TProcedures extends AnyProcedureTree> {
|
|
11
|
-
readonly client: ResultClient<ExtractProcedureByScope<TProcedures, "remote" | "api">>;
|
|
12
|
-
protected readonly config: KizloClientConfig<TProcedures>;
|
|
13
|
-
constructor(config: KizloClientConfig<TProcedures>);
|
|
30
|
+
declare class KizloClient<TProcedures$1 extends AnyProcedureTree> {
|
|
31
|
+
readonly client: ResultClient<ExtractProcedureByScope<TProcedures$1, "remote" | "api">>;
|
|
32
|
+
protected readonly config: KizloClientConfig<TProcedures$1>;
|
|
33
|
+
constructor(config: KizloClientConfig<TProcedures$1>);
|
|
14
34
|
private getUrl;
|
|
15
35
|
}
|
|
16
36
|
/**
|
|
17
37
|
* Creates a browser client for a generated contract. Defaults the URL to the
|
|
18
38
|
* current origin (`window.location.origin`); framework packages wrap this to resolve it from their env.
|
|
39
|
+
*
|
|
40
|
+
* `contract` is the runtime routing table only. The type comes from {@link KizloProcedureRegistry},
|
|
41
|
+
* which the generated barrel augments, so the client is typed even where the value is not in hand.
|
|
19
42
|
*/
|
|
20
|
-
declare function createKizloClient
|
|
43
|
+
declare function createKizloClient(contract: unknown, options?: {
|
|
21
44
|
url?: string;
|
|
22
|
-
}):
|
|
45
|
+
}): KizloBrowserClient;
|
|
23
46
|
//#endregion
|
|
24
|
-
export { KizloClient, KizloClientConfig, createKizloClient };
|
|
47
|
+
export { ActiveKizloClient, KizloBrowserClient, KizloClient, KizloClientConfig, KizloProcedureRegistry, createKizloClient };
|
package/dist/client.js
CHANGED
|
@@ -43,6 +43,9 @@ var KizloClient = class {
|
|
|
43
43
|
/**
|
|
44
44
|
* Creates a browser client for a generated contract. Defaults the URL to the
|
|
45
45
|
* current origin (`window.location.origin`); framework packages wrap this to resolve it from their env.
|
|
46
|
+
*
|
|
47
|
+
* `contract` is the runtime routing table only. The type comes from {@link KizloProcedureRegistry},
|
|
48
|
+
* which the generated barrel augments, so the client is typed even where the value is not in hand.
|
|
46
49
|
*/
|
|
47
50
|
function createKizloClient(contract, options) {
|
|
48
51
|
return new KizloClient({
|
package/dist/index.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ import { InferProcedureData, InferProcedureError, InferProcedureInput, InferProc
|
|
|
33
33
|
import { AnyKizloConfig, CreateKizloOptions, Kizlo, KizloConfig, RootProcedures, S2SClient, createKizlo, integrationEnv, resolveKizloConfig, resolveWordPressConnection, wordPressConnectionComplete } from "./kizlo.js";
|
|
34
34
|
import { WEB_MANIFEST_ROUTE, WebManifest, buildWebManifest, createManifestRoute } from "./brand/manifest.js";
|
|
35
35
|
import "./brand/index.js";
|
|
36
|
-
import { KizloClient, KizloClientConfig, createKizloClient } from "./client.js";
|
|
36
|
+
import { ActiveKizloClient, KizloBrowserClient, KizloClient, KizloClientConfig, KizloProcedureRegistry, createKizloClient } from "./client.js";
|
|
37
37
|
import { CONTENT_TYPES, ContentType, ListSitemapUrlInput, ListSitemapUrlInputBase, Robots, RobotsRule, Seo, SeoHead, SeoSchema, Sitemap, SitemapIndex, SitemapList, SitemapUrl, SitemapUrlImage, SitemapUrlList } from "./seo/schema.js";
|
|
38
38
|
import { WPK_RobotRule, WPK_Robots, WPK_Seo, WPK_Sitemap, WPK_SitemapUrl, WPK_SitemapUrlImage } from "./seo/types.js";
|
|
39
39
|
import { SitemapIndexEntry, deserializeSeo, parseSitemapSlug, renderJsonLd, renderSitemapIndex, renderUrlSet, sitemapEntryPath, xmlResponse } from "./seo/utils.js";
|
|
@@ -43,4 +43,4 @@ import { ShaAlgorithm, compare, hash, hmac } from "./shared/crypto.js";
|
|
|
43
43
|
import { Identifier, parseIdentifier } from "./shared/identifier.js";
|
|
44
44
|
import { createOrpcRouter } from "./shared/router.js";
|
|
45
45
|
import { deserializeCurrencyFormat, deserializeListMetadata, emptyList, serializeCurrencyFormat } from "./shared/serialize.js";
|
|
46
|
-
export { ActiveWordPressClient, AnyContext, AnyEventSchema, AnyEvents, AnyIntegration, AnyKizloConfig, AnyMiddleware, AnyNestedClient, AnyProcedure, AnyProcedureTree, AuthAdapter, AuthGetSession, AuthUser, AuthorsSettings, AuthorsSettingsInput, BaseHandlerOptions, BrandSettings, BrandSettingsInput, COMMON_ERRORS, CONTENT_TYPES, CORE_PROCEDURES, CaptchaAdapter, type Category, type CategoryCustomFields, CategoryCustomFieldsSchema, CommonErrorCode, CommonErrorLiteral, CommonErrorMap, ConnInfo, ConnInfoFn, ConsoleLogAdapterOptions, ContentType, Context, ContextConfig, Contract, ContractProcedure, CookiesAdapter, CookiesDeleteAll, CookiesGetAll, CookiesSetAll, CookiesStorage, CoreProcedures, CrawlingSettings, CrawlingSettingsInput, CreateKizloOptions, CreateSitemapRouteOptions, CurrencyFormat, DefinedErrorMapLike, DevPluginSource, EnvReader, EnvRecord, EnvSource, ErrorDefinition, EventHandler, EventHandlerFn, ExtractIntegrationProcedures, ExtractMiddlewareContextOutput, ExtractParams, ExtractProcedureByScope, Fixture, FixtureCleanupFn, FixtureSeedFn, FixtureSettleFn, GeoAdapter, GeoGetConnInfo, HTTPMethod, HeadlessSettings, HeadlessSettingsInput, IconDescriptor, Identifier, IdentifierInput, IdentitySettings, IdentitySettingsInput, InferEventUnion, InferIntegrationProcedures, InferMiddlewares, InferProcedureData, InferProcedureError, InferProcedureInput, InferProcedureResult, Integration, IntegrationRequirements, InvocationScope, JsonValue, Kizlo, KizloClient, KizloClientConfig, KizloConfig, KizloEnv, KizloError, KizloErrorOptions, KizloErrorUnion, KizloResult, LIST_ORDER, List, ListMetadata, ListOrder, ListSitemapUrlInput, ListSitemapUrlInputBase, LocalPlugin, LogLevel, LogPayload, Logger, LoggerAdapter, ManifestIcon, MaybeCallerOptions, MaybeOptionalOptions, Middleware, MiddlewareHandler, MiddlewareNextFn, MiddlewareOptions, MiddlewareResult, OpenapiPart, OrganizationFounder, OrganizationSettings, OrganizationSettingsInput, type Page, type PageCustomFields, PageCustomFieldsSchema, PersonSettings, PersonSettingsInput, PluginSource, type Post, type PostCustomFields, PostCustomFieldsSchema, PostStatusDefinition, PostTypeSettings, PostTypeSettingsInput, PreviewTokenData, PreviewTokenPayload, Procedure, ProcedureContext, ProcedureErrors, ProcedureHandler, ProcedureMethod, ProcedureOptions, ProcedureTreeDepthTuple, RedirectInput, RedirectStatus, ResolveParamsPart, ResolvedIcons, ResolvedSchemaInput, ResolvedSchemaOutput, ResultClient, Robots, RobotsRule, RootProcedures, S2SClient, SITEMAP_BASE, SITEMAP_INDEX_SLUG, SchemaIO, SeedContext, Seo, SeoHead, SeoSchema, ServiceAdapters, SessionFn, Settings, SettingsService, SettleContext, ShaAlgorithm, SiteSettings, SiteSettingsInput, Sitemap, SitemapIndex, SitemapIndexEntry, SitemapList, SitemapRouteExtra, SitemapUrl, SitemapUrlImage, SitemapUrlList, SocialProfile, type Tag, type TagCustomFields, TagCustomFieldsSchema, TaxonomySettings, TaxonomySettingsInput, TestAdminUser, TestCredentials, TestUser, ThrowableErrorFn, ThrowableErrorMap, UploadsSettings, UploadsSettingsInput, VerifyCaptchaFn, VerifyPreviewTokenFn, WEB_MANIFEST_ROUTE, WPK_RobotRule, WPK_Robots, WPK_Seo, WPK_Sitemap, WPK_SitemapUrl, WPK_SitemapUrlImage, WP_CallOptions, WP_Client, WP_CommonErrorCode, WP_CurrencyFormat, WP_CustomFields, WP_CustomFieldsPath, WP_Endpoint, WP_EndpointData, WP_EndpointDefinition, WP_EndpointError, WP_EndpointInput, WP_EndpointPath, WP_EndpointResult, WP_Error, WP_ErrorData, WP_Failure, WP_List, WP_ListMetadata, WP_RequestBuild, WP_RequestContentType, WP_RequestInput, WP_RequestMethod, WP_RequestParts, WP_ResponseContentType, WP_Result, WP_Success, WP_TransportFailure, WP_TypedHeaders, WebManifest, WebhookOptions, WebhookSettings, WebhookSettingsInput, WithCommonErrorMap, WordPressClientRegistry, WordPressCredentials, WordPressCustomFieldsRegistry, WordPressEndpointRegistry, WordPressEnv, WordPressTransport, WordPressTransportOptions, WordPressTransportResult, altcha, arkose, assertIntegrationEndpoints, assertIntegrationEnv, authMock, buildProcedure, buildWebManifest, buildWordPressRequest, combineDetailed, compare, consoleLog, createAuthAdapter, createCaptchaAdapter, createCookiesAdapter, createEventHandler, createGeoAdapter, createIntegration, createKizlo, createKizloClient, createLoggerAdapter, createManifestRoute, createMiddleware, createOrpcRouter, createProcedure, createResultClient, createSitemapRedirectRoute, createSitemapRoute, createThrowableErrorMap, createWebhookRouter, createWordPressClient, customFieldsSchema, defineErrorMap, defineFixture, deserializeCurrencyFormat, deserializeListMetadata, deserializeSeo, emptyList, friendlyCaptcha, generateContract, geoMock, geoVercelNext, handleUnexpectedError, hash, hcaptcha, hmac, integrationEnv, isContractProcedure, isKizloError, isLocalPlugin, isWordPressResourceError, mergeServiceAdapters, missingEndpoints, missingEnv, noopAdapter, parseIdentifier, parseSitemapSlug, readEnv, recaptcha, renderJsonLd, renderSitemapIndex, renderUrlSet, resolveIcons, resolveKizloConfig, resolveWordPressConnection, restoreContract, schemaType, serializeCurrencyFormat, sitemapEntryPath, sortIntegrations, toKizloError, turnstile, wordPressConnectionComplete, wpEndpoint, xmlResponse };
|
|
46
|
+
export { ActiveKizloClient, ActiveWordPressClient, AnyContext, AnyEventSchema, AnyEvents, AnyIntegration, AnyKizloConfig, AnyMiddleware, AnyNestedClient, AnyProcedure, AnyProcedureTree, AuthAdapter, AuthGetSession, AuthUser, AuthorsSettings, AuthorsSettingsInput, BaseHandlerOptions, BrandSettings, BrandSettingsInput, COMMON_ERRORS, CONTENT_TYPES, CORE_PROCEDURES, CaptchaAdapter, type Category, type CategoryCustomFields, CategoryCustomFieldsSchema, CommonErrorCode, CommonErrorLiteral, CommonErrorMap, ConnInfo, ConnInfoFn, ConsoleLogAdapterOptions, ContentType, Context, ContextConfig, Contract, ContractProcedure, CookiesAdapter, CookiesDeleteAll, CookiesGetAll, CookiesSetAll, CookiesStorage, CoreProcedures, CrawlingSettings, CrawlingSettingsInput, CreateKizloOptions, CreateSitemapRouteOptions, CurrencyFormat, DefinedErrorMapLike, DevPluginSource, EnvReader, EnvRecord, EnvSource, ErrorDefinition, EventHandler, EventHandlerFn, ExtractIntegrationProcedures, ExtractMiddlewareContextOutput, ExtractParams, ExtractProcedureByScope, Fixture, FixtureCleanupFn, FixtureSeedFn, FixtureSettleFn, GeoAdapter, GeoGetConnInfo, HTTPMethod, HeadlessSettings, HeadlessSettingsInput, IconDescriptor, Identifier, IdentifierInput, IdentitySettings, IdentitySettingsInput, InferEventUnion, InferIntegrationProcedures, InferMiddlewares, InferProcedureData, InferProcedureError, InferProcedureInput, InferProcedureResult, Integration, IntegrationRequirements, InvocationScope, JsonValue, Kizlo, KizloBrowserClient, KizloClient, KizloClientConfig, KizloConfig, KizloEnv, KizloError, KizloErrorOptions, KizloErrorUnion, KizloProcedureRegistry, KizloResult, LIST_ORDER, List, ListMetadata, ListOrder, ListSitemapUrlInput, ListSitemapUrlInputBase, LocalPlugin, LogLevel, LogPayload, Logger, LoggerAdapter, ManifestIcon, MaybeCallerOptions, MaybeOptionalOptions, Middleware, MiddlewareHandler, MiddlewareNextFn, MiddlewareOptions, MiddlewareResult, OpenapiPart, OrganizationFounder, OrganizationSettings, OrganizationSettingsInput, type Page, type PageCustomFields, PageCustomFieldsSchema, PersonSettings, PersonSettingsInput, PluginSource, type Post, type PostCustomFields, PostCustomFieldsSchema, PostStatusDefinition, PostTypeSettings, PostTypeSettingsInput, PreviewTokenData, PreviewTokenPayload, Procedure, ProcedureContext, ProcedureErrors, ProcedureHandler, ProcedureMethod, ProcedureOptions, ProcedureTreeDepthTuple, RedirectInput, RedirectStatus, ResolveParamsPart, ResolvedIcons, ResolvedSchemaInput, ResolvedSchemaOutput, ResultClient, Robots, RobotsRule, RootProcedures, S2SClient, SITEMAP_BASE, SITEMAP_INDEX_SLUG, SchemaIO, SeedContext, Seo, SeoHead, SeoSchema, ServiceAdapters, SessionFn, Settings, SettingsService, SettleContext, ShaAlgorithm, SiteSettings, SiteSettingsInput, Sitemap, SitemapIndex, SitemapIndexEntry, SitemapList, SitemapRouteExtra, SitemapUrl, SitemapUrlImage, SitemapUrlList, SocialProfile, type Tag, type TagCustomFields, TagCustomFieldsSchema, TaxonomySettings, TaxonomySettingsInput, TestAdminUser, TestCredentials, TestUser, ThrowableErrorFn, ThrowableErrorMap, UploadsSettings, UploadsSettingsInput, VerifyCaptchaFn, VerifyPreviewTokenFn, WEB_MANIFEST_ROUTE, WPK_RobotRule, WPK_Robots, WPK_Seo, WPK_Sitemap, WPK_SitemapUrl, WPK_SitemapUrlImage, WP_CallOptions, WP_Client, WP_CommonErrorCode, WP_CurrencyFormat, WP_CustomFields, WP_CustomFieldsPath, WP_Endpoint, WP_EndpointData, WP_EndpointDefinition, WP_EndpointError, WP_EndpointInput, WP_EndpointPath, WP_EndpointResult, WP_Error, WP_ErrorData, WP_Failure, WP_List, WP_ListMetadata, WP_RequestBuild, WP_RequestContentType, WP_RequestInput, WP_RequestMethod, WP_RequestParts, WP_ResponseContentType, WP_Result, WP_Success, WP_TransportFailure, WP_TypedHeaders, WebManifest, WebhookOptions, WebhookSettings, WebhookSettingsInput, WithCommonErrorMap, WordPressClientRegistry, WordPressCredentials, WordPressCustomFieldsRegistry, WordPressEndpointRegistry, WordPressEnv, WordPressTransport, WordPressTransportOptions, WordPressTransportResult, altcha, arkose, assertIntegrationEndpoints, assertIntegrationEnv, authMock, buildProcedure, buildWebManifest, buildWordPressRequest, combineDetailed, compare, consoleLog, createAuthAdapter, createCaptchaAdapter, createCookiesAdapter, createEventHandler, createGeoAdapter, createIntegration, createKizlo, createKizloClient, createLoggerAdapter, createManifestRoute, createMiddleware, createOrpcRouter, createProcedure, createResultClient, createSitemapRedirectRoute, createSitemapRoute, createThrowableErrorMap, createWebhookRouter, createWordPressClient, customFieldsSchema, defineErrorMap, defineFixture, deserializeCurrencyFormat, deserializeListMetadata, deserializeSeo, emptyList, friendlyCaptcha, generateContract, geoMock, geoVercelNext, handleUnexpectedError, hash, hcaptcha, hmac, integrationEnv, isContractProcedure, isKizloError, isLocalPlugin, isWordPressResourceError, mergeServiceAdapters, missingEndpoints, missingEnv, noopAdapter, parseIdentifier, parseSitemapSlug, readEnv, recaptcha, renderJsonLd, renderSitemapIndex, renderUrlSet, resolveIcons, resolveKizloConfig, resolveWordPressConnection, restoreContract, schemaType, serializeCurrencyFormat, sitemapEntryPath, sortIntegrations, toKizloError, turnstile, wordPressConnectionComplete, wpEndpoint, xmlResponse };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { KizloClient } from "../../client.js";
|
|
1
|
+
import { KizloBrowserClient } from "../../client.js";
|
|
3
2
|
|
|
4
3
|
//#region src/integrations/astro/kizlo.client.d.ts
|
|
5
4
|
interface KizloClientOptions {
|
|
@@ -10,6 +9,6 @@ interface KizloClientOptions {
|
|
|
10
9
|
*/
|
|
11
10
|
url?: string;
|
|
12
11
|
}
|
|
13
|
-
declare function createKizloClient
|
|
12
|
+
declare function createKizloClient(contract: unknown, options?: KizloClientOptions): KizloBrowserClient;
|
|
14
13
|
//#endregion
|
|
15
14
|
export { KizloClientOptions, createKizloClient };
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createKizloClient } from "../../client.js";
|
|
2
2
|
import { getServerBaseUrl } from "./utils.js";
|
|
3
3
|
|
|
4
4
|
//#region src/integrations/astro/kizlo.client.ts
|
|
5
|
-
function createKizloClient(contract, options) {
|
|
6
|
-
return
|
|
7
|
-
url: options?.url ?? getServerBaseUrl(),
|
|
8
|
-
contract
|
|
9
|
-
});
|
|
5
|
+
function createKizloClient$1(contract, options) {
|
|
6
|
+
return createKizloClient(contract, { url: options?.url ?? getServerBaseUrl() });
|
|
10
7
|
}
|
|
11
8
|
|
|
12
9
|
//#endregion
|
|
13
|
-
export { createKizloClient };
|
|
10
|
+
export { createKizloClient$1 as createKizloClient };
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { KizloClient } from "../../client.js";
|
|
1
|
+
import { KizloBrowserClient } from "../../client.js";
|
|
3
2
|
|
|
4
3
|
//#region src/integrations/nextjs/kizlo.client.d.ts
|
|
5
4
|
interface KizloClientOptions {
|
|
6
5
|
url?: string;
|
|
7
6
|
}
|
|
8
|
-
declare function createKizloClient
|
|
7
|
+
declare function createKizloClient(contract: unknown, options?: KizloClientOptions): KizloBrowserClient;
|
|
9
8
|
//#endregion
|
|
10
9
|
export { KizloClientOptions, createKizloClient };
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createKizloClient } from "../../client.js";
|
|
2
2
|
import { getServerBaseUrl } from "./utils.js";
|
|
3
3
|
|
|
4
4
|
//#region src/integrations/nextjs/kizlo.client.ts
|
|
5
|
-
function createKizloClient(contract, options) {
|
|
6
|
-
return
|
|
7
|
-
url: options?.url ?? getServerBaseUrl(),
|
|
8
|
-
contract
|
|
9
|
-
});
|
|
5
|
+
function createKizloClient$1(contract, options) {
|
|
6
|
+
return createKizloClient(contract, { url: options?.url ?? getServerBaseUrl() });
|
|
10
7
|
}
|
|
11
8
|
|
|
12
9
|
//#endregion
|
|
13
|
-
export { createKizloClient };
|
|
10
|
+
export { createKizloClient$1 as createKizloClient };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { KizloClient } from "../../client.js";
|
|
1
|
+
import { KizloBrowserClient } from "../../client.js";
|
|
3
2
|
|
|
4
3
|
//#region src/integrations/tanstack-start/kizlo.client.d.ts
|
|
5
4
|
interface KizloClientOptions {
|
|
@@ -15,6 +14,6 @@ interface KizloClientOptions {
|
|
|
15
14
|
* over HTTP, so it runs the same in the browser and during SSR. Server routes and server functions use
|
|
16
15
|
* the server-to-server client from {@link createKizlo} instead.
|
|
17
16
|
*/
|
|
18
|
-
declare function createKizloClient
|
|
17
|
+
declare function createKizloClient(contract: unknown, options?: KizloClientOptions): KizloBrowserClient;
|
|
19
18
|
//#endregion
|
|
20
19
|
export { KizloClientOptions, createKizloClient };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createKizloClient } from "../../client.js";
|
|
2
2
|
import { getServerBaseUrl } from "./utils.js";
|
|
3
3
|
|
|
4
4
|
//#region src/integrations/tanstack-start/kizlo.client.ts
|
|
@@ -7,12 +7,9 @@ import { getServerBaseUrl } from "./utils.js";
|
|
|
7
7
|
* over HTTP, so it runs the same in the browser and during SSR. Server routes and server functions use
|
|
8
8
|
* the server-to-server client from {@link createKizlo} instead.
|
|
9
9
|
*/
|
|
10
|
-
function createKizloClient(contract, options) {
|
|
11
|
-
return
|
|
12
|
-
url: options?.url ?? getServerBaseUrl(),
|
|
13
|
-
contract
|
|
14
|
-
});
|
|
10
|
+
function createKizloClient$1(contract, options) {
|
|
11
|
+
return createKizloClient(contract, { url: options?.url ?? getServerBaseUrl() });
|
|
15
12
|
}
|
|
16
13
|
|
|
17
14
|
//#endregion
|
|
18
|
-
export { createKizloClient };
|
|
15
|
+
export { createKizloClient$1 as createKizloClient };
|
package/dist/package.js
CHANGED
package/dist/react.d.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { ActiveKizloClient } from "./client.js";
|
|
2
|
+
import * as react0 from "react";
|
|
3
|
+
import { ReactNode } from "react";
|
|
4
|
+
|
|
5
|
+
//#region src/react.d.ts
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* What the context carries. One key today, which is why the hook hands back the object rather than the client itself: a
|
|
9
|
+
* locale, a session or app-wide configuration can join it without changing a signature.
|
|
10
|
+
*/
|
|
11
|
+
type KizloContextValue = {
|
|
12
|
+
/** The app's browser Kizlo client, typed from the procedures that app registered. */
|
|
13
|
+
client: ActiveKizloClient;
|
|
14
|
+
};
|
|
15
|
+
type KizloProviderProps = {
|
|
16
|
+
children: ReactNode;
|
|
17
|
+
/** The app's browser Kizlo client, the callable procedure tree. */
|
|
18
|
+
client: ActiveKizloClient;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Holds the app's browser Kizlo client for the client components below it. Mount it once, above anything that reads it.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```tsx
|
|
25
|
+
* // app/providers.tsx
|
|
26
|
+
* "use client"
|
|
27
|
+
* import { KizloProvider } from "kizlo/react"
|
|
28
|
+
* import { client } from "@/lib/kizlo/client"
|
|
29
|
+
*
|
|
30
|
+
* export function Providers({ children }: { children: React.ReactNode }) {
|
|
31
|
+
* return <KizloProvider client={client}>{children}</KizloProvider>
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
declare function KizloProvider({
|
|
36
|
+
children,
|
|
37
|
+
client
|
|
38
|
+
}: KizloProviderProps): react0.JSX.Element;
|
|
39
|
+
/**
|
|
40
|
+
* Reads the context, whose `client` is typed from the procedures the app registered, so a call the contract does not
|
|
41
|
+
* carry is a compile error rather than a runtime surprise.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```tsx
|
|
45
|
+
* "use client"
|
|
46
|
+
* import { useKizloContext } from "kizlo/react"
|
|
47
|
+
*
|
|
48
|
+
* function LatestPosts() {
|
|
49
|
+
* const { client } = useKizloContext()
|
|
50
|
+
* // ...
|
|
51
|
+
* }
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
declare function useKizloContext(): KizloContextValue;
|
|
55
|
+
//#endregion
|
|
56
|
+
export { KizloContextValue, KizloProvider, KizloProviderProps, useKizloContext };
|
package/dist/react.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import { createContext, useContext, useMemo } from "react";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
|
|
7
|
+
//#region src/react.tsx
|
|
8
|
+
const KizloContext = createContext(null);
|
|
9
|
+
/**
|
|
10
|
+
* Holds the app's browser Kizlo client for the client components below it. Mount it once, above anything that reads it.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* // app/providers.tsx
|
|
15
|
+
* "use client"
|
|
16
|
+
* import { KizloProvider } from "kizlo/react"
|
|
17
|
+
* import { client } from "@/lib/kizlo/client"
|
|
18
|
+
*
|
|
19
|
+
* export function Providers({ children }: { children: React.ReactNode }) {
|
|
20
|
+
* return <KizloProvider client={client}>{children}</KizloProvider>
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
function KizloProvider({ children, client }) {
|
|
25
|
+
if (!client) throw new Error("<KizloProvider client={client}> needs the browser client `createKizloClient` returned.");
|
|
26
|
+
const value = useMemo(() => ({ client }), [client]);
|
|
27
|
+
return /* @__PURE__ */ jsx(KizloContext.Provider, {
|
|
28
|
+
value,
|
|
29
|
+
children
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Reads the context, whose `client` is typed from the procedures the app registered, so a call the contract does not
|
|
34
|
+
* carry is a compile error rather than a runtime surprise.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```tsx
|
|
38
|
+
* "use client"
|
|
39
|
+
* import { useKizloContext } from "kizlo/react"
|
|
40
|
+
*
|
|
41
|
+
* function LatestPosts() {
|
|
42
|
+
* const { client } = useKizloContext()
|
|
43
|
+
* // ...
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
function useKizloContext() {
|
|
48
|
+
const value = useContext(KizloContext);
|
|
49
|
+
if (!value) throw new Error("mount <KizloProvider client={client}> from kizlo/react above this component.");
|
|
50
|
+
return value;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
//#endregion
|
|
54
|
+
export { KizloProvider, useKizloContext };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kizlo",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A headless WordPress framework for TypeScript.",
|
|
6
6
|
"keywords": [
|
|
@@ -40,6 +40,12 @@
|
|
|
40
40
|
"default": "./dist/index.js"
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
|
+
"./react": {
|
|
44
|
+
"import": {
|
|
45
|
+
"types": "./dist/react.d.ts",
|
|
46
|
+
"default": "./dist/react.js"
|
|
47
|
+
}
|
|
48
|
+
},
|
|
43
49
|
"./config": {
|
|
44
50
|
"import": {
|
|
45
51
|
"types": "./dist/config.d.ts",
|