@rainlanguage/ui-components 0.0.1-alpha.226 → 0.0.1-alpha.228
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/__fixtures__/settings.yaml +1 -1
- package/dist/components/deployment/DeploymentSteps.svelte +3 -3
- package/dist/components/deployment/DeploymentTile.svelte +3 -3
- package/dist/components/deployment/InvalidOrdersSection.svelte +1 -1
- package/dist/components/deployment/ValidOrdersSection.svelte +3 -3
- package/dist/components/input/InputRainlangUrl.svelte +40 -0
- package/dist/components/input/InputRainlangUrl.svelte.d.ts +16 -0
- package/dist/index.d.ts +7 -7
- package/dist/index.js +6 -6
- package/dist/providers/dotrainRainlang/DotrainRainlangProvider.svelte +8 -0
- package/dist/providers/dotrainRainlang/DotrainRainlangProvider.svelte.d.ts +24 -0
- package/dist/providers/dotrainRainlang/context.d.ts +9 -0
- package/dist/providers/{dotrainRegistry → dotrainRainlang}/context.js +12 -12
- package/dist/providers/dotrainRainlang/useDotrainRainlang.d.ts +5 -0
- package/dist/providers/dotrainRainlang/useDotrainRainlang.js +35 -0
- package/dist/providers/rainlang/RainlangManager.d.ts +65 -0
- package/dist/providers/rainlang/RainlangManager.js +133 -0
- package/dist/providers/rainlang/RainlangProvider.svelte +6 -0
- package/dist/providers/rainlang/RainlangProvider.svelte.d.ts +21 -0
- package/dist/providers/rainlang/context.d.ts +10 -0
- package/dist/providers/rainlang/context.js +46 -0
- package/dist/providers/rainlang/useRainlang.d.ts +7 -0
- package/dist/providers/rainlang/useRainlang.js +29 -0
- package/dist/services/handleShareChoices.d.ts +1 -1
- package/dist/services/handleShareChoices.js +2 -2
- package/dist/services/index.d.ts +3 -3
- package/dist/services/index.js +2 -2
- package/dist/services/loadRainlangUrl.d.ts +2 -0
- package/dist/services/loadRainlangUrl.js +22 -0
- package/dist/services/{registry.d.ts → rainlang.d.ts} +10 -10
- package/dist/services/{registry.js → rainlang.js} +15 -15
- package/package.json +2 -2
- package/dist/components/input/InputRegistryUrl.svelte +0 -40
- package/dist/components/input/InputRegistryUrl.svelte.d.ts +0 -16
- package/dist/providers/dotrainRegistry/DotrainRegistryProvider.svelte +0 -8
- package/dist/providers/dotrainRegistry/DotrainRegistryProvider.svelte.d.ts +0 -24
- package/dist/providers/dotrainRegistry/context.d.ts +0 -9
- package/dist/providers/dotrainRegistry/useDotrainRegistry.d.ts +0 -5
- package/dist/providers/dotrainRegistry/useDotrainRegistry.js +0 -35
- package/dist/providers/registry/RegistryManager.d.ts +0 -65
- package/dist/providers/registry/RegistryManager.js +0 -133
- package/dist/providers/registry/RegistryProvider.svelte +0 -6
- package/dist/providers/registry/RegistryProvider.svelte.d.ts +0 -21
- package/dist/providers/registry/context.d.ts +0 -10
- package/dist/providers/registry/context.js +0 -46
- package/dist/providers/registry/useRegistry.d.ts +0 -7
- package/dist/providers/registry/useRegistry.js +0 -29
- package/dist/services/loadRegistryUrl.d.ts +0 -2
- package/dist/services/loadRegistryUrl.js +0 -22
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { RegistryManager } from './RegistryManager';
|
|
2
|
-
export declare const REGISTRY_KEY = "registry_key";
|
|
3
|
-
/**
|
|
4
|
-
* Retrieves the registry manager directly from Svelte's context
|
|
5
|
-
*/
|
|
6
|
-
export declare const getRegistryContext: () => RegistryManager;
|
|
7
|
-
/**
|
|
8
|
-
* Sets the registry manager in Svelte's context
|
|
9
|
-
*/
|
|
10
|
-
export declare const setRegistryContext: (registry: RegistryManager) => void;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { getContext, setContext } from 'svelte';
|
|
2
|
-
export const REGISTRY_KEY = 'registry_key';
|
|
3
|
-
/**
|
|
4
|
-
* Retrieves the registry manager directly from Svelte's context
|
|
5
|
-
*/
|
|
6
|
-
export const getRegistryContext = () => {
|
|
7
|
-
const registry = getContext(REGISTRY_KEY);
|
|
8
|
-
if (!registry) {
|
|
9
|
-
throw new Error('No registry manager was found in Svelte context. Did you forget to wrap your component with RegistryProvider?');
|
|
10
|
-
}
|
|
11
|
-
return registry;
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* Sets the registry manager in Svelte's context
|
|
15
|
-
*/
|
|
16
|
-
export const setRegistryContext = (registry) => {
|
|
17
|
-
setContext(REGISTRY_KEY, registry);
|
|
18
|
-
};
|
|
19
|
-
if (import.meta.vitest) {
|
|
20
|
-
const { describe, it, expect, vi, beforeEach } = import.meta.vitest;
|
|
21
|
-
vi.mock('svelte', async (importOriginal) => ({
|
|
22
|
-
...(await importOriginal()),
|
|
23
|
-
getContext: vi.fn()
|
|
24
|
-
}));
|
|
25
|
-
describe('getRegistryContext', () => {
|
|
26
|
-
const mockGetContext = vi.mocked(getContext);
|
|
27
|
-
beforeEach(() => {
|
|
28
|
-
mockGetContext.mockReset();
|
|
29
|
-
});
|
|
30
|
-
it('should return the registry from context when it exists', () => {
|
|
31
|
-
const mockRegistry = {};
|
|
32
|
-
mockGetContext.mockImplementation((key) => {
|
|
33
|
-
if (key === REGISTRY_KEY)
|
|
34
|
-
return mockRegistry;
|
|
35
|
-
return undefined;
|
|
36
|
-
});
|
|
37
|
-
const result = getRegistryContext();
|
|
38
|
-
expect(mockGetContext).toHaveBeenCalledWith(REGISTRY_KEY);
|
|
39
|
-
expect(result).toEqual(mockRegistry);
|
|
40
|
-
});
|
|
41
|
-
it('should throw an error when registry is not in context', () => {
|
|
42
|
-
mockGetContext.mockReturnValue(undefined);
|
|
43
|
-
expect(() => getRegistryContext()).toThrow('No registry manager was found in Svelte context. Did you forget to wrap your component with RegistryProvider?');
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { RegistryManager } from './RegistryManager';
|
|
2
|
-
/**
|
|
3
|
-
* Hook to access registry manager information from context
|
|
4
|
-
* Must be used within a component that is a child of RegistryProvider
|
|
5
|
-
* @returns An object containing the registry manager
|
|
6
|
-
*/
|
|
7
|
-
export declare function useRegistry(): RegistryManager;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { getRegistryContext } from './context';
|
|
2
|
-
/**
|
|
3
|
-
* Hook to access registry manager information from context
|
|
4
|
-
* Must be used within a component that is a child of RegistryProvider
|
|
5
|
-
* @returns An object containing the registry manager
|
|
6
|
-
*/
|
|
7
|
-
export function useRegistry() {
|
|
8
|
-
const registry = getRegistryContext();
|
|
9
|
-
return registry;
|
|
10
|
-
}
|
|
11
|
-
if (import.meta.vitest) {
|
|
12
|
-
const { describe, it, expect, vi, beforeEach } = import.meta.vitest;
|
|
13
|
-
vi.mock('./context', () => ({
|
|
14
|
-
getRegistryContext: vi.fn()
|
|
15
|
-
}));
|
|
16
|
-
describe('useRegistry', () => {
|
|
17
|
-
const mockGetRegistryContext = vi.mocked(getRegistryContext);
|
|
18
|
-
beforeEach(() => {
|
|
19
|
-
mockGetRegistryContext.mockReset();
|
|
20
|
-
});
|
|
21
|
-
it('should return registry', () => {
|
|
22
|
-
const mockRegistry = {};
|
|
23
|
-
mockGetRegistryContext.mockReturnValue(mockRegistry);
|
|
24
|
-
const result = useRegistry();
|
|
25
|
-
expect(mockGetRegistryContext).toHaveBeenCalled();
|
|
26
|
-
expect(result).toEqual(mockRegistry);
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { RegistryManager } from '../providers/registry/RegistryManager';
|
|
2
|
-
import { DotrainRegistry } from '@rainlanguage/orderbook';
|
|
3
|
-
export async function loadRegistryUrl(url, registryManager) {
|
|
4
|
-
if (!url) {
|
|
5
|
-
throw new Error('No URL provided');
|
|
6
|
-
}
|
|
7
|
-
if (!registryManager) {
|
|
8
|
-
throw new Error('Registry manager is required');
|
|
9
|
-
}
|
|
10
|
-
try {
|
|
11
|
-
const validationResult = await DotrainRegistry.validate(url);
|
|
12
|
-
if (validationResult.error) {
|
|
13
|
-
throw new Error(validationResult.error.readableMsg);
|
|
14
|
-
}
|
|
15
|
-
registryManager.setRegistry(url);
|
|
16
|
-
window.location.reload();
|
|
17
|
-
}
|
|
18
|
-
catch (e) {
|
|
19
|
-
const errorMessage = e instanceof Error ? e.message : 'Failed to update registry URL';
|
|
20
|
-
throw new Error(errorMessage);
|
|
21
|
-
}
|
|
22
|
-
}
|