Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions contacts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
"build:pwa": "pwa-asset-generator ../assets/logo.png ./www/icons --index ./www/index.html --manifest ./www/manifest.json"
},
"dependencies": {
"@pod-os/core": "^0.24.0",
"@pod-os/elements": "^0.35.0",
"@pod-os/core": "^0.25.0-next.0",
"@pod-os/elements": "0.36.0-next.0",
"@solid-data-modules/contacts-rdflib": "^0.7.1",
"@stencil/core": "^4.40.1",
"pollen-css": "^5.0.2",
Expand Down
2 changes: 1 addition & 1 deletion contacts/src/components/router/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class ContactsRouter {

async componentWillLoad() {
const os = await usePodOS(this.el);
this.contactsModule = await os.loadContactsModule();
this.contactsModule = await os.loadModule('contacts');
this.updateUri();
Router.onChange('url', () => {
this.updateUri();
Expand Down
7 changes: 7 additions & 0 deletions contacts/src/index.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
<!doctype html>
<html dir="ltr" lang="en">
<head>
<script type="importmap">
{
"imports": {
"contacts": "https://esm.sh/@solid-data-modules/contacts-rdflib"
}
}
</script>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>PodOS Contacts</title>
Expand Down
11 changes: 11 additions & 0 deletions core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.25.0

### Breaking Changes

- `PodOS.loadContactsModule` got removed, use [`PodOS.loadModule`](https://pod-os.org/reference/core/classes/PodOS/#loadmodule) instead
- `@solid-data-modules/contacts-rdflib` is no longer part of core. If you need it, you must install it yourself and load it using [`PodOS.loadModule`](https://pod-os.org/reference/core/classes/PodOS/#loadmodule)

### Added

- [`PodOS.loadModule`](https://pod-os.org/reference/core/classes/PodOS/#loadmodule): Dynamically loads a module by its name

## 0.24.0

### Added
Expand Down
20 changes: 20 additions & 0 deletions core/examples/modules.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { PodOS, AnonymousSession } from "@pod-os/core";

// Create a new PodOS instance
const os = new PodOS({
session: new AnonymousSession(),
});

// load a module, e.g. the contacts Solid Data Module
const contactsModule = await os.loadModule(
"@solid-data-modules/contacts-rdflib",
);

// use the module regularly
const addressBook = await contactsModule.readAddressBook(
"https://solidos.solidcommunity.net/Contacts/index.ttl#this",
);

// all data fetched via module is also available via PodOS
const someone = os.store.get(addressBook.contacts[0].uri);
console.log(someone.label());
1 change: 0 additions & 1 deletion core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
"typescript-eslint": "^8.50.1"
},
"dependencies": {
"@solid-data-modules/contacts-rdflib": "^0.7.1",
"@solid-data-modules/rdflib-utils": "^0.6.0",
"@types/lunr": "^2.3.7",
"buffer": "^6.0.3",
Expand Down
11 changes: 7 additions & 4 deletions core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { ContactsModule } from "@solid-data-modules/contacts-rdflib";
import { BehaviorSubject, tap } from "rxjs";
import { PodOsSession, SessionInfo } from "./authentication";
import { FileFetcher, FileGateway, SolidFile } from "./files";
import { loadContactsModule } from "./modules/contacts";
import { AttachmentGateway } from "./attachments";
import { PictureGateway } from "./picture";
import { ProfileGateway, WebIdProfile } from "./profile";
Expand All @@ -20,6 +18,7 @@ import {
import { IndexedFormula } from "rdflib";
import { ResultAsync } from "neverthrow";
import { HttpProblem, NetworkProblem } from "./problems";
import { loadModule } from "./modules";

export * from "./authentication";
export * from "./files";
Expand Down Expand Up @@ -175,8 +174,12 @@ export class PodOS {
return this.session.login(oidcIssuer);
}

loadContactsModule(): Promise<ContactsModule> {
return loadContactsModule(this.store);
/**
* Dynamically loads a module by its name and returns an instance of the module
* @param moduleName
*/
loadModule<T>(moduleName: string): Promise<T> {
return loadModule(moduleName, this.store);
}

/**
Expand Down
9 changes: 0 additions & 9 deletions core/src/modules/contacts.ts

This file was deleted.

14 changes: 14 additions & 0 deletions core/src/modules/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Store } from "../Store";

/**
* Dynamically loads a module by its name and returns an instance of the module
* @param moduleName
* @param store
*/
export async function loadModule<T>(
moduleName: string,
store: Store,
): Promise<T> {
const module = await import(moduleName);
return store.loadModule(module);
}
6 changes: 6 additions & 0 deletions elements/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.36.0

### Changed

- The `pod-os:module` can now trigger loading any Solid Data module that is installed / configured via importmap.

## 0.35.0

## Added
Expand Down
20 changes: 3 additions & 17 deletions elements/src/components/pos-app/pos-app.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,40 +92,26 @@ describe('pos-app', () => {

it('loads the contacts module', async () => {
// given
const loadContactsModule = jest.fn().mockResolvedValue('fake contacts module');
const loadModule = jest.fn().mockResolvedValue('fake contacts module');
const receiver = jest.fn();
const page = await newSpecPage({
components: [PosApp],
html: `<pos-app>item body</pos-app>`,
supportsShadowDom: false,
});
page.rootInstance.os = {
loadContactsModule,
loadModule,
};

// when
fireEvent(page.root, new CustomEvent('pod-os:module', { detail: { module: 'contacts', receiver } }));
await page.waitForChanges();

// then
expect(loadContactsModule).toHaveBeenCalled();
expect(loadModule).toHaveBeenCalled();
expect(receiver).toHaveBeenCalledWith('fake contacts module');
page.rootInstance.disconnectedCallback();
});

it('throws an error if module is unknown', async () => {
const app = new PosApp();
await expect(() =>
app.loadModule(
new CustomEvent('pod-os:module', {
detail: {
module: 'unknown-module-name',
receiver: () => {},
},
}),
),
).rejects.toEqual(new Error('Unknown module "unknown-module-name"'));
});
});

describe('handle incoming redirect', () => {
Expand Down
8 changes: 2 additions & 6 deletions elements/src/components/pos-app/pos-app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,8 @@ export class PosApp {
@Listen('pod-os:module')
async loadModule(event: RequestModuleEvent) {
event.stopPropagation();
if (event.detail.module === 'contacts') {
const module = await this.os.loadContactsModule();
event.detail.receiver(module);
} else {
throw Error(`Unknown module "${event.detail.module}"`);
}
const module = await this.os.loadModule(event.detail.module);
event.detail.receiver(module);
}

render() {
Expand Down
10 changes: 5 additions & 5 deletions homepage/docs/reference/core/classes/AnonymousSession.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# Class: AnonymousSession

Defined in: [authentication/index.ts:20](https://github.com/pod-os/PodOS/blob/a5ceb94d91186b3cf4ceb28910e3f6d4c89dae68/core/src/authentication/index.ts#L20)
Defined in: [authentication/index.ts:20](https://github.com/pod-os/PodOS/blob/e80e47e090ea2a3c5a790a9e1634789ca61341b8/core/src/authentication/index.ts#L20)

## Implements

Expand All @@ -30,7 +30,7 @@ Defined in: [authentication/index.ts:20](https://github.com/pod-os/PodOS/blob/a5

> **get** **authenticatedFetch**(): (`url`, `init?`) => `Promise`\<`Response`\>

Defined in: [authentication/index.ts:27](https://github.com/pod-os/PodOS/blob/a5ceb94d91186b3cf4ceb28910e3f6d4c89dae68/core/src/authentication/index.ts#L27)
Defined in: [authentication/index.ts:27](https://github.com/pod-os/PodOS/blob/e80e47e090ea2a3c5a790a9e1634789ca61341b8/core/src/authentication/index.ts#L27)

##### Returns

Expand Down Expand Up @@ -60,7 +60,7 @@ Defined in: [authentication/index.ts:27](https://github.com/pod-os/PodOS/blob/a5

> **login**(): `Promise`\<`void`\>

Defined in: [authentication/index.ts:38](https://github.com/pod-os/PodOS/blob/a5ceb94d91186b3cf4ceb28910e3f6d4c89dae68/core/src/authentication/index.ts#L38)
Defined in: [authentication/index.ts:38](https://github.com/pod-os/PodOS/blob/e80e47e090ea2a3c5a790a9e1634789ca61341b8/core/src/authentication/index.ts#L38)

#### Returns

Expand All @@ -76,7 +76,7 @@ Defined in: [authentication/index.ts:38](https://github.com/pod-os/PodOS/blob/a5

> **logout**(): `Promise`\<`void`\>

Defined in: [authentication/index.ts:42](https://github.com/pod-os/PodOS/blob/a5ceb94d91186b3cf4ceb28910e3f6d4c89dae68/core/src/authentication/index.ts#L42)
Defined in: [authentication/index.ts:42](https://github.com/pod-os/PodOS/blob/e80e47e090ea2a3c5a790a9e1634789ca61341b8/core/src/authentication/index.ts#L42)

#### Returns

Expand All @@ -92,7 +92,7 @@ Defined in: [authentication/index.ts:42](https://github.com/pod-os/PodOS/blob/a5

> **observeSession**(): `BehaviorSubject`\<[`SessionInfo`](../type-aliases/SessionInfo.md)\>

Defined in: [authentication/index.ts:34](https://github.com/pod-os/PodOS/blob/a5ceb94d91186b3cf4ceb28910e3f6d4c89dae68/core/src/authentication/index.ts#L34)
Defined in: [authentication/index.ts:34](https://github.com/pod-os/PodOS/blob/e80e47e090ea2a3c5a790a9e1634789ca61341b8/core/src/authentication/index.ts#L34)

#### Returns

Expand Down
4 changes: 2 additions & 2 deletions homepage/docs/reference/core/classes/AssumeAlwaysOnline.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# Class: AssumeAlwaysOnline

Defined in: [offline-cache/OnlineStatus.ts:5](https://github.com/pod-os/PodOS/blob/a5ceb94d91186b3cf4ceb28910e3f6d4c89dae68/core/src/offline-cache/OnlineStatus.ts#L5)
Defined in: [offline-cache/OnlineStatus.ts:5](https://github.com/pod-os/PodOS/blob/e80e47e090ea2a3c5a790a9e1634789ca61341b8/core/src/offline-cache/OnlineStatus.ts#L5)

## Implements

Expand All @@ -28,7 +28,7 @@ Defined in: [offline-cache/OnlineStatus.ts:5](https://github.com/pod-os/PodOS/bl

> **isOnline**(): `boolean`

Defined in: [offline-cache/OnlineStatus.ts:6](https://github.com/pod-os/PodOS/blob/a5ceb94d91186b3cf4ceb28910e3f6d4c89dae68/core/src/offline-cache/OnlineStatus.ts#L6)
Defined in: [offline-cache/OnlineStatus.ts:6](https://github.com/pod-os/PodOS/blob/e80e47e090ea2a3c5a790a9e1634789ca61341b8/core/src/offline-cache/OnlineStatus.ts#L6)

#### Returns

Expand Down
6 changes: 3 additions & 3 deletions homepage/docs/reference/core/classes/AttachmentGateway.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# Class: AttachmentGateway

Defined in: [attachments/AttachmentGateway.ts:11](https://github.com/pod-os/PodOS/blob/a5ceb94d91186b3cf4ceb28910e3f6d4c89dae68/core/src/attachments/AttachmentGateway.ts#L11)
Defined in: [attachments/AttachmentGateway.ts:11](https://github.com/pod-os/PodOS/blob/e80e47e090ea2a3c5a790a9e1634789ca61341b8/core/src/attachments/AttachmentGateway.ts#L11)

Gateway for attachment-related operations on Solid Pods and the store.

Expand All @@ -20,7 +20,7 @@ Gateway for attachment-related operations on Solid Pods and the store.

> **new AttachmentGateway**(`fileGateway`): `AttachmentGateway`

Defined in: [attachments/AttachmentGateway.ts:12](https://github.com/pod-os/PodOS/blob/a5ceb94d91186b3cf4ceb28910e3f6d4c89dae68/core/src/attachments/AttachmentGateway.ts#L12)
Defined in: [attachments/AttachmentGateway.ts:12](https://github.com/pod-os/PodOS/blob/e80e47e090ea2a3c5a790a9e1634789ca61341b8/core/src/attachments/AttachmentGateway.ts#L12)

#### Parameters

Expand All @@ -38,7 +38,7 @@ Defined in: [attachments/AttachmentGateway.ts:12](https://github.com/pod-os/PodO

> **uploadAndAddAttachment**(`thing`, `attachmentFile`): `ResultAsync`\<[`NewFile`](../interfaces/NewFile.md), [`NetworkProblem`](../interfaces/NetworkProblem.md) \| [`HttpProblem`](../interfaces/HttpProblem.md)\>

Defined in: [attachments/AttachmentGateway.ts:23](https://github.com/pod-os/PodOS/blob/a5ceb94d91186b3cf4ceb28910e3f6d4c89dae68/core/src/attachments/AttachmentGateway.ts#L23)
Defined in: [attachments/AttachmentGateway.ts:23](https://github.com/pod-os/PodOS/blob/e80e47e090ea2a3c5a790a9e1634789ca61341b8/core/src/attachments/AttachmentGateway.ts#L23)

Uploads an attachment file and associates it with a thing.
The container is automatically derived from the thing's URI.
Expand Down
8 changes: 4 additions & 4 deletions homepage/docs/reference/core/classes/BinaryFile.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# Class: BinaryFile

Defined in: [files/BinaryFile.ts:3](https://github.com/pod-os/PodOS/blob/a5ceb94d91186b3cf4ceb28910e3f6d4c89dae68/core/src/files/BinaryFile.ts#L3)
Defined in: [files/BinaryFile.ts:3](https://github.com/pod-os/PodOS/blob/e80e47e090ea2a3c5a790a9e1634789ca61341b8/core/src/files/BinaryFile.ts#L3)

## Implements

Expand All @@ -18,7 +18,7 @@ Defined in: [files/BinaryFile.ts:3](https://github.com/pod-os/PodOS/blob/a5ceb94

> **new BinaryFile**(`url`, `data`): `BinaryFile`

Defined in: [files/BinaryFile.ts:4](https://github.com/pod-os/PodOS/blob/a5ceb94d91186b3cf4ceb28910e3f6d4c89dae68/core/src/files/BinaryFile.ts#L4)
Defined in: [files/BinaryFile.ts:4](https://github.com/pod-os/PodOS/blob/e80e47e090ea2a3c5a790a9e1634789ca61341b8/core/src/files/BinaryFile.ts#L4)

#### Parameters

Expand All @@ -40,7 +40,7 @@ Defined in: [files/BinaryFile.ts:4](https://github.com/pod-os/PodOS/blob/a5ceb94

> `readonly` **url**: `string`

Defined in: [files/BinaryFile.ts:5](https://github.com/pod-os/PodOS/blob/a5ceb94d91186b3cf4ceb28910e3f6d4c89dae68/core/src/files/BinaryFile.ts#L5)
Defined in: [files/BinaryFile.ts:5](https://github.com/pod-os/PodOS/blob/e80e47e090ea2a3c5a790a9e1634789ca61341b8/core/src/files/BinaryFile.ts#L5)

#### Implementation of

Expand All @@ -52,7 +52,7 @@ Defined in: [files/BinaryFile.ts:5](https://github.com/pod-os/PodOS/blob/a5ceb94

> **blob**(): `Blob`

Defined in: [files/BinaryFile.ts:9](https://github.com/pod-os/PodOS/blob/a5ceb94d91186b3cf4ceb28910e3f6d4c89dae68/core/src/files/BinaryFile.ts#L9)
Defined in: [files/BinaryFile.ts:9](https://github.com/pod-os/PodOS/blob/e80e47e090ea2a3c5a790a9e1634789ca61341b8/core/src/files/BinaryFile.ts#L9)

#### Returns

Expand Down
12 changes: 6 additions & 6 deletions homepage/docs/reference/core/classes/BrokenFile.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# Class: BrokenFile

Defined in: [files/BrokenFile.ts:4](https://github.com/pod-os/PodOS/blob/a5ceb94d91186b3cf4ceb28910e3f6d4c89dae68/core/src/files/BrokenFile.ts#L4)
Defined in: [files/BrokenFile.ts:4](https://github.com/pod-os/PodOS/blob/e80e47e090ea2a3c5a790a9e1634789ca61341b8/core/src/files/BrokenFile.ts#L4)

## Implements

Expand All @@ -18,7 +18,7 @@ Defined in: [files/BrokenFile.ts:4](https://github.com/pod-os/PodOS/blob/a5ceb94

> **new BrokenFile**(`url`, `status`): `BrokenFile`

Defined in: [files/BrokenFile.ts:5](https://github.com/pod-os/PodOS/blob/a5ceb94d91186b3cf4ceb28910e3f6d4c89dae68/core/src/files/BrokenFile.ts#L5)
Defined in: [files/BrokenFile.ts:5](https://github.com/pod-os/PodOS/blob/e80e47e090ea2a3c5a790a9e1634789ca61341b8/core/src/files/BrokenFile.ts#L5)

#### Parameters

Expand All @@ -40,15 +40,15 @@ Defined in: [files/BrokenFile.ts:5](https://github.com/pod-os/PodOS/blob/a5ceb94

> `readonly` **status**: [`HttpStatus`](HttpStatus.md)

Defined in: [files/BrokenFile.ts:7](https://github.com/pod-os/PodOS/blob/a5ceb94d91186b3cf4ceb28910e3f6d4c89dae68/core/src/files/BrokenFile.ts#L7)
Defined in: [files/BrokenFile.ts:7](https://github.com/pod-os/PodOS/blob/e80e47e090ea2a3c5a790a9e1634789ca61341b8/core/src/files/BrokenFile.ts#L7)

***

### url

> `readonly` **url**: `string`

Defined in: [files/BrokenFile.ts:6](https://github.com/pod-os/PodOS/blob/a5ceb94d91186b3cf4ceb28910e3f6d4c89dae68/core/src/files/BrokenFile.ts#L6)
Defined in: [files/BrokenFile.ts:6](https://github.com/pod-os/PodOS/blob/e80e47e090ea2a3c5a790a9e1634789ca61341b8/core/src/files/BrokenFile.ts#L6)

#### Implementation of

Expand All @@ -60,7 +60,7 @@ Defined in: [files/BrokenFile.ts:6](https://github.com/pod-os/PodOS/blob/a5ceb94

> **blob**(): `Blob` \| `null`

Defined in: [files/BrokenFile.ts:14](https://github.com/pod-os/PodOS/blob/a5ceb94d91186b3cf4ceb28910e3f6d4c89dae68/core/src/files/BrokenFile.ts#L14)
Defined in: [files/BrokenFile.ts:14](https://github.com/pod-os/PodOS/blob/e80e47e090ea2a3c5a790a9e1634789ca61341b8/core/src/files/BrokenFile.ts#L14)

#### Returns

Expand All @@ -76,7 +76,7 @@ Defined in: [files/BrokenFile.ts:14](https://github.com/pod-os/PodOS/blob/a5ceb9

> **toString**(): `string`

Defined in: [files/BrokenFile.ts:10](https://github.com/pod-os/PodOS/blob/a5ceb94d91186b3cf4ceb28910e3f6d4c89dae68/core/src/files/BrokenFile.ts#L10)
Defined in: [files/BrokenFile.ts:10](https://github.com/pod-os/PodOS/blob/e80e47e090ea2a3c5a790a9e1634789ca61341b8/core/src/files/BrokenFile.ts#L10)

Returns a string representation of an object.

Expand Down
Loading