From 93eca757d383898580be7740f6a7a6ac25d06c1d Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Wed, 12 Jan 2022 18:31:55 +0100 Subject: [PATCH 1/2] dont add paths/vite to sdk output, as it does not work --- scripts/sdk/build.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/sdk/build.sh b/scripts/sdk/build.sh index b19f2960..5534601e 100755 --- a/scripts/sdk/build.sh +++ b/scripts/sdk/build.sh @@ -5,7 +5,8 @@ yarn run vite build -c vite.sdk-lib-config.js yarn tsc -p tsconfig-declaration.json ./scripts/sdk/create-manifest.js ./target/package.json mkdir target/paths -./scripts/sdk/transform-paths.js ./src/platform/web/sdk/paths/vite.js ./target/paths/vite.js +# this doesn't work, the ?url imports need to be in the consuming project, so disable for now +# ./scripts/sdk/transform-paths.js ./src/platform/web/sdk/paths/vite.js ./target/paths/vite.js cp doc/SDK.md target/README.md pushd target pushd asset-build/assets From 8c1596d8694e74e8826f5fabec75ba2424dbdd8c Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Wed, 12 Jan 2022 18:32:15 +0100 Subject: [PATCH 2/2] update SDK docs to not use paths/vite anymore --- doc/SDK.md | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/doc/SDK.md b/doc/SDK.md index d92b99c6..8ce0b304 100644 --- a/doc/SDK.md +++ b/doc/SDK.md @@ -33,7 +33,20 @@ import { RoomViewModel, TimelineView } from "hydrogen-view-sdk"; -import assetPaths from "hydrogen-view-sdk/paths/vite"; +import downloadSandboxPath from 'hydrogen-view-sdk/download-sandbox.html?url'; +import workerPath from 'hydrogen-view-sdk/main.js?url'; +import olmWasmPath from '@matrix-org/olm/olm.wasm?url'; +import olmJsPath from '@matrix-org/olm/olm.js?url'; +import olmLegacyJsPath from '@matrix-org/olm/olm_legacy.js?url'; +const assetPaths = { + downloadSandbox: downloadSandboxPath, + worker: workerPath, + olm: { + wasm: olmWasmPath, + legacyBundle: olmLegacyJsPath, + wasmBundle: olmJsPath + } +}; import "hydrogen-view-sdk/style.css"; async function main() { @@ -84,7 +97,13 @@ main(); ## Typescript support -There is partial typescript support while we are still in the process of converting the Hydrogen codebase to typesccript. +Typescript support is not yet available while we're converting the Hydrogen codebase to Typescript. +In your `src` directory, you'll need to add a `.d.ts` (can be called anything, e.g. `deps.d.ts`) +containing this snippet to make Typescript not complain that `hydrogen-view-sdk` doesn't have types: + +```ts +declare module "hydrogen-view-sdk"; +``` ## API Stability