@iota-uz/sdk 0.6.0 → 0.7.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.
Files changed (45) hide show
  1. package/README.md +4 -1
  2. package/dist/client-host/bootstrap.d.ts +41 -0
  3. package/dist/client-host/bootstrap.d.ts.map +1 -0
  4. package/dist/client-host/bootstrap.js +63 -0
  5. package/dist/client-host/draft.d.ts +22 -0
  6. package/dist/client-host/draft.d.ts.map +1 -0
  7. package/dist/client-host/draft.js +73 -0
  8. package/dist/client-host/errors.d.ts.map +1 -1
  9. package/dist/client-host/errors.js +10 -6
  10. package/dist/client-host/identity.d.ts +4 -4
  11. package/dist/client-host/identity.js +2 -2
  12. package/dist/client-host/index.d.ts +3 -0
  13. package/dist/client-host/index.d.ts.map +1 -1
  14. package/dist/client-host/index.js +3 -0
  15. package/dist/client-host/navigation.d.ts +16 -0
  16. package/dist/client-host/navigation.d.ts.map +1 -0
  17. package/dist/client-host/navigation.js +41 -0
  18. package/dist/client-host/route.d.ts +2 -14
  19. package/dist/client-host/route.d.ts.map +1 -1
  20. package/dist/client-host/route.js +11 -24
  21. package/dist/client-host/rpc-core.d.ts +37 -0
  22. package/dist/client-host/rpc-core.d.ts.map +1 -0
  23. package/dist/client-host/rpc-core.js +79 -0
  24. package/dist/client-host/rpc.d.ts +3 -34
  25. package/dist/client-host/rpc.d.ts.map +1 -1
  26. package/dist/client-host/rpc.js +3 -65
  27. package/dist/client-host/services.d.ts +23 -0
  28. package/dist/client-host/services.d.ts.map +1 -0
  29. package/dist/client-host/services.js +57 -0
  30. package/dist/client-host/solid-index.d.ts +13 -0
  31. package/dist/client-host/solid-index.d.ts.map +1 -0
  32. package/dist/client-host/solid-index.js +12 -0
  33. package/dist/client-host/solid-rpc.d.ts +25 -0
  34. package/dist/client-host/solid-rpc.d.ts.map +1 -0
  35. package/dist/client-host/solid-rpc.js +52 -0
  36. package/dist/client-host/solid.d.ts +17 -0
  37. package/dist/client-host/solid.d.ts.map +1 -0
  38. package/dist/client-host/solid.js +77 -0
  39. package/dist/client-host/transport.d.ts +2 -1
  40. package/dist/client-host/transport.d.ts.map +1 -1
  41. package/dist/sdk-identity.cjs +3 -3
  42. package/dist/sdk-identity.js +3 -3
  43. package/dist/sdk-identity.json +2 -2
  44. package/dist/styles.css +1436 -0
  45. package/package.json +19 -2
@@ -1 +1 @@
1
- {"version":3,"file":"rpc.d.ts","sourceRoot":"","sources":["../src/rpc.ts"],"names":[],"mappings":"AACA,OAAO,EAA8B,KAAK,UAAU,EAAE,KAAK,QAAQ,EAAE,MAAM,SAAS,CAAA;AACpF,OAAO,EAAkC,SAAS,EAAE,KAAK,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAE5F,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,OAAO,GAAG,UAAU,CAAA;IAC1B,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAChC;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,SAAS,CAAC,CAAA;CACtG;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,CAAC,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,QAAQ,CAAC;QAAC,KAAK,EAAE,OAAO,GAAG,SAAS,GAAG,OAAO,GAAG,WAAW,CAAC;QAAC,KAAK,CAAC,EAAE,SAAS,CAAA;KAAE,GAAG,IAAI,CAAA;CAC9H;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,EAAE,UAAU,CAAA;IAClB,MAAM,CAAC,E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AAS,EAAE,KAAK,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAE9D,cAAc,YAAY,CAAA;AAE1B,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI;IAAE,MAAM,EAAE,SAAS,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,CAAC,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAAE,CAAA;AAE1H,wBAAgB,WAAW,CAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,iBAAiB,EAAE,OAAO,EAAE,QAAQ,GAAG,UAAU,CAAC,SAAS,CAAC,CAezI;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,iBAAiB,aAG7D,QAAQ,KAAG,OAAO,CAAC,SAAS,CAAC,CAKjE"}
@@ -1,69 +1,7 @@
1
1
  import { useCallback, useEffect, useRef, useState } from 'react';
2
- import { MemoryQueryCache, queryKey } from './cache';
3
- import { asHostError, dispatchHostError, HostError } from './errors';
4
- export class RPCClient {
5
- transport;
6
- options;
7
- cache;
8
- constructor(transport, options = {}) {
9
- this.transport = transport;
10
- this.options = options;
11
- this.cache = options.cache ?? new MemoryQueryCache();
12
- }
13
- async query(contract, request, signal) {
14
- if (contract.kind !== 'query')
15
- throw new HostError('protocol', `${contract.method} is not a query`);
16
- const key = queryKey(contract.namespace, contract.method, request);
17
- if (contract.cacheable !== false) {
18
- const cached = this.cache.get(key);
19
- if (cached !== undefined)
20
- return cached;
21
- }
22
- let attempt = 0;
23
- const maxRetries = Math.max(0, Math.min(3, contract.maxRetries ?? 2));
24
- for (;;) {
25
- this.options.diagnostics?.call?.({ method: contract.method, key, state: 'start' });
26
- try {
27
- const response = await this.transport.call(contract.method, request, signal);
28
- if (contract.cacheable !== false)
29
- this.cache.set(key, response);
30
- this.options.diagnostics?.call?.({ method: contract.method, key, state: 'success' });
31
- return response;
32
- }
33
- catch (cause) {
34
- if (signal.aborted) {
35
- this.options.diagnostics?.call?.({ method: contract.method, key, state: 'cancelled' });
36
- throw cause;
37
- }
38
- const error = asHostError(cause);
39
- if (!error.retryable || attempt >= maxRetries) {
40
- dispatchHostError(error, this.options.errors);
41
- this.options.diagnostics?.call?.({ method: contract.method, key, state: 'error', error });
42
- throw error;
43
- }
44
- attempt += 1;
45
- }
46
- }
47
- }
48
- async mutate(contract, request, signal) {
49
- if (contract.kind !== 'mutation')
50
- throw new HostError('protocol', `${contract.method} is not a mutation`);
51
- this.options.diagnostics?.call?.({ method: contract.method, state: 'start' });
52
- try {
53
- const response = await this.transport.call(contract.method, request, signal);
54
- this.cache.invalidate(contract.namespace, contract.invalidates ?? []);
55
- this.options.diagnostics?.call?.({ method: contract.method, state: 'success' });
56
- return response;
57
- }
58
- catch (cause) {
59
- const error = asHostError(cause);
60
- if (!signal.aborted)
61
- dispatchHostError(error, this.options.errors);
62
- this.options.diagnostics?.call?.({ method: contract.method, state: signal.aborted ? 'cancelled' : 'error', error });
63
- throw error;
64
- }
65
- }
66
- }
2
+ import { queryKey } from './cache';
3
+ import { asHostError } from './errors';
4
+ export * from './rpc-core';
67
5
  export function useRPCQuery(client, contract, request) {
68
6
  const [state, setState] = useState({ status: 'loading' });
69
7
  const generation = useRef(0);
@@ -0,0 +1,23 @@
1
+ import type { ClientRouteContext } from './bootstrap';
2
+ import { type NavigationService } from './navigation';
3
+ import { type SessionService } from './transport';
4
+ export interface ThemeService {
5
+ current(): 'light' | 'dark';
6
+ set(theme: 'light' | 'dark'): void;
7
+ subscribe(listener: (theme: 'light' | 'dark') => void): () => void;
8
+ }
9
+ export interface ClientHostServices {
10
+ session: SessionService;
11
+ navigation: NavigationService;
12
+ theme: ThemeService;
13
+ locale: {
14
+ language: string;
15
+ t(key: string): string;
16
+ };
17
+ telemetry: {
18
+ emit(name: string, data?: unknown): void;
19
+ };
20
+ dispose(): void;
21
+ }
22
+ export declare function createClientHostServices(context: ClientRouteContext, owner?: Window): ClientHostServices;
23
+ //# sourceMappingURL=services.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"services.d.ts","sourceRoot":"","sources":["../src/services.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,EAA4B,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAE/E,OAAO,EAAkB,KAAK,cAAc,EAAqB,MAAM,aAAa,CAAA;AAEpF,MAAM,WAAW,YAAY;IAC3B,OAAO,IAAI,OAAO,GAAG,MAAM,CAAA;IAC3B,GAAG,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAAA;IAClC,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,KAAK,IAAI,GAAG,MAAM,IAAI,CAAA;CACnE;AAsBD,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,cAAc,CAAA;IACvB,UAAU,EAAE,iBAAiB,CAAA;IAC7B,KAAK,EAAE,YAAY,CAAA;IACnB,MAAM,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,CAAC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAA;IACpD,SAAS,EAAE;QAAE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,CAAA;KAAE,CAAA;IACvD,OAAO,IAAI,IAAI,CAAA;CAChB;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,kBAAkB,EAAE,KAAK,GAAE,MAAe,GAAG,kBAAkB,CA2BhH"}
@@ -0,0 +1,57 @@
1
+ import { BrowserNavigationService } from './navigation';
2
+ import { HostError } from './errors';
3
+ import { ManagedSession } from './transport';
4
+ class HostThemeService {
5
+ root;
6
+ theme;
7
+ listeners = new Set();
8
+ constructor(theme, root) {
9
+ this.root = root;
10
+ this.theme = theme;
11
+ this.root.dataset.theme = theme;
12
+ }
13
+ current() { return this.theme; }
14
+ set(theme) {
15
+ if (theme === this.theme)
16
+ return;
17
+ this.theme = theme;
18
+ this.root.dataset.theme = theme;
19
+ for (const listener of this.listeners)
20
+ listener(theme);
21
+ }
22
+ subscribe(listener) {
23
+ this.listeners.add(listener);
24
+ return () => this.listeners.delete(listener);
25
+ }
26
+ }
27
+ export function createClientHostServices(context, owner = window) {
28
+ const navigation = new BrowserNavigationService(owner);
29
+ const initialSession = {
30
+ ...(context.session?.csrf || context.csrf ? { csrf: context.session?.csrf ?? context.csrf } : {}),
31
+ ...(context.session?.expiresAt ? { expiresAt: context.session.expiresAt } : {}),
32
+ };
33
+ const session = new ManagedSession(initialSession, async (signal) => {
34
+ const endpoint = context.session?.refreshEndpoint;
35
+ if (!endpoint)
36
+ throw new HostError('unauthenticated', 'Session expired', { reauthUrl: context.session?.reauthUrl, returnUrl: owner.location.href });
37
+ const response = await owner.fetch(endpoint, { method: 'POST', credentials: 'same-origin', signal });
38
+ if (!response.ok)
39
+ throw new HostError('unauthenticated', 'Session expired', { reauthUrl: context.session?.reauthUrl, returnUrl: owner.location.href });
40
+ return await response.json();
41
+ });
42
+ const messages = context.locale?.messages ?? {};
43
+ return {
44
+ session,
45
+ navigation,
46
+ theme: new HostThemeService(context.theme, owner.document.documentElement),
47
+ locale: { language: context.locale?.language ?? 'en', t: (key) => messages[key] ?? key },
48
+ telemetry: {
49
+ emit(name, data) {
50
+ if (!context.services?.telemetry)
51
+ return;
52
+ owner.dispatchEvent(new CustomEvent('iota:telemetry', { detail: { endpoint: context.services.telemetry, name, data } }));
53
+ },
54
+ },
55
+ dispose: () => navigation.dispose(),
56
+ };
57
+ }
@@ -0,0 +1,13 @@
1
+ export * from './bootstrap';
2
+ export * from './cache';
3
+ export * from './draft';
4
+ export * from './errors';
5
+ export * from './identity';
6
+ export * from './navigation';
7
+ export * from './protocol';
8
+ export * from './rpc-core';
9
+ export * from './services';
10
+ export * from './solid';
11
+ export * from './solid-rpc';
12
+ export * from './transport';
13
+ //# sourceMappingURL=solid-index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"solid-index.d.ts","sourceRoot":"","sources":["../src/solid-index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAC1B,cAAc,SAAS,CAAA;AACvB,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA"}
@@ -0,0 +1,12 @@
1
+ export * from './bootstrap';
2
+ export * from './cache';
3
+ export * from './draft';
4
+ export * from './errors';
5
+ export * from './identity';
6
+ export * from './navigation';
7
+ export * from './protocol';
8
+ export * from './rpc-core';
9
+ export * from './services';
10
+ export * from './solid';
11
+ export * from './solid-rpc';
12
+ export * from './transport';
@@ -0,0 +1,25 @@
1
+ import { type Accessor } from 'solid-js';
2
+ import { type HostError } from './errors';
3
+ import { RPCClient, type RPCMethodContract } from './rpc-core';
4
+ export type SolidQueryState<T> = {
5
+ status: 'loading';
6
+ } | {
7
+ status: 'success';
8
+ data: T;
9
+ } | {
10
+ status: 'error';
11
+ error: HostError;
12
+ };
13
+ export declare function createRPCQuery<TRequest, TResponse>(client: RPCClient, contract: RPCMethodContract, request: Accessor<TRequest>): {
14
+ state: Accessor<SolidQueryState<TResponse>>;
15
+ refetch: () => void;
16
+ cancel: () => void | undefined;
17
+ };
18
+ export declare function createRPCAction<TRequest, TResponse>(client: RPCClient, contract: RPCMethodContract): {
19
+ execute: (request: TRequest) => Promise<TResponse>;
20
+ pending: Accessor<boolean>;
21
+ error: Accessor<HostError | undefined>;
22
+ fieldErrors: () => Readonly<Record<string, string>>;
23
+ cancel: () => void | undefined;
24
+ };
25
+ //# sourceMappingURL=solid-rpc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"solid-rpc.d.ts","sourceRoot":"","sources":["../src/solid-rpc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyC,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAA;AAE/E,OAAO,EAAe,KAAK,SAAS,EAAE,MAAM,UAAU,CAAA;AACtD,OAAO,EAAE,SAAS,EAAE,KAAK,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAE9D,MAAM,MAAM,eAAe,CAAC,CAAC,IACzB;IAAE,MAAM,EAAE,SAAS,CAAA;CAAE,GACrB;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,CAAC,CAAA;CAAE,GAC9B;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAAE,CAAA;AAEzC,wBAAgB,cAAc,CAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,iBAAiB,EAAE,OAAO,EAAE,QAAQ,CAAC,QAAQ,CAAC;;;;EAqB9H;AAED,wBAAgB,eAAe,CAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,iBAAiB;uBAKjE,QAAQ,KAAG,OAAO,CAAC,SAAS,CAAC;;;;;EAkB9D"}
@@ -0,0 +1,52 @@
1
+ import { createEffect, createSignal, onCleanup } from 'solid-js';
2
+ import { queryKey } from './cache';
3
+ import { asHostError } from './errors';
4
+ export function createRPCQuery(client, contract, request) {
5
+ const [state, setState] = createSignal({ status: 'loading' });
6
+ let generation = 0;
7
+ let controller;
8
+ const run = (input) => {
9
+ const current = ++generation;
10
+ controller?.abort();
11
+ controller = new AbortController();
12
+ setState({ status: 'loading' });
13
+ void client.query(contract, input, controller.signal).then((data) => { if (generation === current && !controller?.signal.aborted)
14
+ setState({ status: 'success', data }); }, (cause) => { if (generation === current && !controller?.signal.aborted)
15
+ setState({ status: 'error', error: asHostError(cause) }); });
16
+ };
17
+ createEffect(() => {
18
+ const input = request();
19
+ queryKey(contract.namespace, contract.method, input);
20
+ run(input);
21
+ });
22
+ onCleanup(() => controller?.abort());
23
+ return { state, refetch: () => run(request()), cancel: () => controller?.abort() };
24
+ }
25
+ export function createRPCAction(client, contract) {
26
+ const [pending, setPending] = createSignal(false);
27
+ const [error, setError] = createSignal();
28
+ let generation = 0;
29
+ let controller;
30
+ const execute = async (request) => {
31
+ const current = ++generation;
32
+ controller?.abort();
33
+ controller = new AbortController();
34
+ setPending(true);
35
+ setError(undefined);
36
+ try {
37
+ return await client.mutate(contract, request, controller.signal);
38
+ }
39
+ catch (cause) {
40
+ const hostError = asHostError(cause);
41
+ if (generation === current && !controller.signal.aborted)
42
+ setError(hostError);
43
+ throw hostError;
44
+ }
45
+ finally {
46
+ if (generation === current)
47
+ setPending(false);
48
+ }
49
+ };
50
+ onCleanup(() => controller?.abort());
51
+ return { execute, pending, error, fieldErrors: () => error()?.fieldErrors ?? {}, cancel: () => controller?.abort() };
52
+ }
@@ -0,0 +1,17 @@
1
+ import { type Component } from 'solid-js';
2
+ import { type ClientRouteContext } from './bootstrap';
3
+ import { type ClientHostServices } from './services';
4
+ export declare function useClientHost(): ClientHostServices;
5
+ export interface SolidRouteProps<TInitial = unknown> {
6
+ route: ClientRouteContext<TInitial>;
7
+ }
8
+ export interface MountSolidClientRouteOptions<TInitial, TProps extends object> {
9
+ root: HTMLElement;
10
+ component: Component<TProps & SolidRouteProps<TInitial>>;
11
+ props: TProps;
12
+ context: ClientRouteContext<TInitial>;
13
+ services?: ClientHostServices;
14
+ }
15
+ export declare function mountSolidClientRoute<TInitial, TProps extends object>(options: MountSolidClientRouteOptions<TInitial, TProps>): () => void;
16
+ export declare function mountSolidClientRouteFromDocument<TInitial, TProps extends object>(component: Component<TProps & SolidRouteProps<TInitial>>, props: TProps, owner?: Document): () => void;
17
+ //# sourceMappingURL=solid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"solid.d.ts","sourceRoot":"","sources":["../src/solid.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8C,KAAK,SAAS,EAAE,MAAM,UAAU,CAAA;AAErF,OAAO,EAA8C,KAAK,kBAAkB,EAAE,MAAM,aAAa,CAAA;AACjG,OAAO,EAA4B,KAAK,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAI9E,wBAAgB,aAAa,IAAI,kBAAkB,CAIlD;AAED,MAAM,WAAW,eAAe,CAAC,QAAQ,GAAG,OAAO;IACjD,KAAK,EAAE,kBAAkB,CAAC,QAAQ,CAAC,CAAA;CACpC;AAED,MAAM,WAAW,4BAA4B,CAAC,QAAQ,EAAE,MAAM,SAAS,MAAM;IAC3E,IAAI,EAAE,WAAW,CAAA;IACjB,SAAS,EAAE,SAAS,CAAC,MAAM,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAA;IACxD,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,kBAAkB,CAAC,QAAQ,CAAC,CAAA;IACrC,QAAQ,CAAC,EAAE,kBAAkB,CAAA;CAC9B;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,SAAS,MAAM,EAAE,OAAO,EAAE,4BAA4B,CAAC,QAAQ,EAAE,MAAM,CAAC,GAAG,MAAM,IAAI,CAmD1I;AAED,wBAAgB,iCAAiC,CAAC,QAAQ,EAAE,MAAM,SAAS,MAAM,EAC/E,SAAS,EAAE,SAAS,CAAC,MAAM,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC,EACxD,KAAK,EAAE,MAAM,EACb,KAAK,GAAE,QAAmB,GACzB,MAAM,IAAI,CAIZ"}
@@ -0,0 +1,77 @@
1
+ import { createComponent, createContext, useContext } from 'solid-js';
2
+ import { render } from 'solid-js/web';
3
+ import { assertClientBootstrap, readClientBootstrap } from './bootstrap';
4
+ import { createClientHostServices } from './services';
5
+ const ClientHostContext = createContext();
6
+ export function useClientHost() {
7
+ const services = useContext(ClientHostContext);
8
+ if (!services)
9
+ throw new Error('Solid client route is not mounted by the iota client host');
10
+ return services;
11
+ }
12
+ export function mountSolidClientRoute(options) {
13
+ assertClientBootstrap(options.context);
14
+ const currentOwner = options.root.dataset.iotaClientOwner;
15
+ if (currentOwner)
16
+ throw new Error(`Client route root is already owned by ${currentOwner}`);
17
+ options.root.dataset.iotaClientOwner = 'solid';
18
+ let services;
19
+ try {
20
+ const owner = options.root.ownerDocument.defaultView;
21
+ if (!options.services && !owner)
22
+ throw new Error('Client route root is not attached to a browser realm');
23
+ services = options.services ?? createClientHostServices(options.context, owner);
24
+ const mountedServices = services;
25
+ const Component = options.component;
26
+ const dispose = render(() => createComponent(ClientHostContext.Provider, {
27
+ value: mountedServices,
28
+ get children() { return createComponent(Component, { ...options.props, route: options.context }); },
29
+ }), options.root);
30
+ let mounted = true;
31
+ return () => {
32
+ if (!mounted)
33
+ return;
34
+ mounted = false;
35
+ let disposeError;
36
+ let disposeFailed = false;
37
+ try {
38
+ dispose();
39
+ }
40
+ catch (cause) {
41
+ disposeFailed = true;
42
+ disposeError = cause;
43
+ }
44
+ try {
45
+ mountedServices.dispose();
46
+ }
47
+ catch (cause) {
48
+ if (disposeFailed)
49
+ throw new AggregateError([disposeError, cause], 'Client route cleanup failed', { cause: disposeError });
50
+ throw cause;
51
+ }
52
+ finally {
53
+ delete options.root.dataset.iotaClientOwner;
54
+ }
55
+ if (disposeFailed)
56
+ throw disposeError;
57
+ };
58
+ }
59
+ catch (cause) {
60
+ try {
61
+ services?.dispose();
62
+ }
63
+ catch (cleanupCause) {
64
+ throw new AggregateError([cause, cleanupCause], 'Client route mount and cleanup failed', { cause });
65
+ }
66
+ finally {
67
+ delete options.root.dataset.iotaClientOwner;
68
+ }
69
+ throw cause;
70
+ }
71
+ }
72
+ export function mountSolidClientRouteFromDocument(component, props, owner = document) {
73
+ const root = owner.getElementById('iota-client-route-mount');
74
+ if (!root)
75
+ throw new Error('Client route mount element is missing');
76
+ return mountSolidClientRoute({ root, component, props, context: readClientBootstrap(owner) });
77
+ }
@@ -1,6 +1,7 @@
1
- import type { RPCTransport } from './rpc';
1
+ import type { RPCTransport } from './rpc-core';
2
2
  export interface SessionState {
3
3
  csrf?: string;
4
+ expiresAt?: string;
4
5
  headers?: Readonly<Record<string, string>>;
5
6
  }
6
7
  export interface SessionService {
@@ -1 +1 @@
1
- {"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAEzC,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;CAC3C;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,IAAI,YAAY,CAAA;IACxB,OAAO,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC,CAAA;CACpD;AAED,qBAAa,cAAe,YAAW,cAAc;IAGhB,OAAO,CAAC,QAAQ,CAAC,KAAK;IAFzD,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,UAAU,CAAmC;gBACzC,OAAO,EAAE,YAAY,EAAmB,KAAK,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,YAAY,CAAC;IACzG,QAAQ,IAAI,YAAY;IACxB,OAAO,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;CAIpD;AAED,qBAAa,iBAAkB,YAAW,YAAY;IAExC,QAAQ,CAAC,QAAQ,EAAE,MAAM;IAAE,QAAQ,CAAC,OAAO,EAAE,cAAc;IADvE,OAAO,CAAC,SAAS,CAAI;gBACA,QAAQ,EAAE,MAAM,EAAW,OAAO,GAAE,cAAyD;IAE5G,IAAI,CAAC,QAAQ,EAAE,S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AAC;YAI7F,OAAO;CAsBtB"}
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
- const SDK_RELEASE_VERSION = "0.6.0"
3
- const SDK_SOURCE_COMMIT = "6b7490fb17af61fd3d13d6009578b4a8997d80d0"
2
+ const SDK_RELEASE_VERSION = "0.7.0"
3
+ const SDK_SOURCE_COMMIT = "40d8d87255b723420b70c3db5226a5fbbd6c5b8c"
4
4
  const SDK_PROTOCOL_VERSION = "1.0.0"
5
- const SDK_IDENTITY = Object.freeze({"releaseVersion":"0.6.0","sourceCommit":"6b7490fb17af61fd3d13d6009578b4a8997d80d0","protocolVersion":"1.0.0"})
5
+ const SDK_IDENTITY = Object.freeze({"releaseVersion":"0.7.0","sourceCommit":"40d8d87255b723420b70c3db5226a5fbbd6c5b8c","protocolVersion":"1.0.0"})
6
6
  module.exports = { SDK_RELEASE_VERSION, SDK_SOURCE_COMMIT, SDK_PROTOCOL_VERSION, SDK_IDENTITY }
@@ -1,4 +1,4 @@
1
- export const SDK_RELEASE_VERSION = "0.6.0"
2
- export const SDK_SOURCE_COMMIT = "6b7490fb17af61fd3d13d6009578b4a8997d80d0"
1
+ export const SDK_RELEASE_VERSION = "0.7.0"
2
+ export const SDK_SOURCE_COMMIT = "40d8d87255b723420b70c3db5226a5fbbd6c5b8c"
3
3
  export const SDK_PROTOCOL_VERSION = "1.0.0"
4
- export const SDK_IDENTITY = Object.freeze({"releaseVersion":"0.6.0","sourceCommit":"6b7490fb17af61fd3d13d6009578b4a8997d80d0","protocolVersion":"1.0.0"})
4
+ export const SDK_IDENTITY = Object.freeze({"releaseVersion":"0.7.0","sourceCommit":"40d8d87255b723420b70c3db5226a5fbbd6c5b8c","protocolVersion":"1.0.0"})
@@ -1,5 +1,5 @@
1
1
  {
2
- "releaseVersion": "0.6.0",
3
- "sourceCommit": "6b7490fb17af61fd3d13d6009578b4a8997d80d0",
2
+ "releaseVersion": "0.7.0",
3
+ "sourceCommit": "40d8d87255b723420b70c3db5226a5fbbd6c5b8c",
4
4
  "protocolVersion": "1.0.0"
5
5
  }