Compare commits

...
Author SHA1 Message Date
Johannes Marbach 09e69f8fda Merge pull request #4545 from element-hq/johannes/backport-maven
[backport] build: skip publishing on maven for RC
2026-12-02 12:27:32 +01:00
Johannes Marbach 98d244c205 Merge pull request #4544 from element-hq/toger5/backport-4539-js-sdk-entry-point-guard
[backport] Skip "two js-sdk guard" for the component build
2026-12-02 12:26:26 +01:00
Valere Fedronic b38b0f8383 [backport] build: skip publishing on maven for RC 2026-12-02 11:45:57 +01:00
Timo 1374ca86fa Merge pull request #4539 from element-hq/toger5/fix-js-sdk-entry-point-guard
Skip "two js-sdk guard" for the component build

(cherry picked from commit 32e35fdfc8)
2026-12-02 11:18:43 +01:00
5 changed files with 73 additions and 28 deletions
@@ -156,7 +156,9 @@ jobs:
publish_android:
needs: [build_element_call, versioning]
if: always()
# Release candidates are not published to Maven Central: the organisation's Central account
# has a monthly release quota, and Element X Android (the only consumer) ships final releases.
if: always() && needs.versioning.outputs.TAG != 'rc'
name: Publish Android AAR
runs-on: ubuntu-24.04
outputs:
@@ -188,8 +190,6 @@ jobs:
run: |
if [[ "${NEEDS_VERSIONING_OUTPUTS_TAG}" == "latest" ]]; then
echo "ARTIFACT_VERSION=${NEEDS_VERSIONING_OUTPUTS_UNPREFIXED_VERSION}" >> "$GITHUB_ENV"
elif [[ "${NEEDS_VERSIONING_OUTPUTS_TAG}" == "rc" ]]; then
echo "ARTIFACT_VERSION=${NEEDS_VERSIONING_OUTPUTS_UNPREFIXED_VERSION}" >> "$GITHUB_ENV"
else
echo "ARTIFACT_VERSION=${NEEDS_VERSIONING_OUTPUTS_UNPREFIXED_VERSION}-SNAPSHOT" >> "$GITHUB_ENV"
fi
@@ -338,11 +338,7 @@ jobs:
### Android AAR
```
dependencies {
implementation 'io.element.android:element-call-embedded:${{ needs.publish_android.outputs.ARTIFACT_VERSION }}'
}
```
${{ needs.publish_android.outputs.ARTIFACT_VERSION && format('`implementation ''io.element.android:element-call-embedded:{0}''`', needs.publish_android.outputs.ARTIFACT_VERSION) || 'Not published: release candidates do not go to Maven Central.' }}
### SwiftPM
+41
View File
@@ -0,0 +1,41 @@
/*
Copyright 2026 Element Creations Ltd.
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE in the repository root for full details.
*/
/**
* The js-sdk for the component: the package's own entry points
* (`lib/index.js`, `lib/browser-index.js`) throw when the host's copy has
* already loaded one, and `browser-index` also writes the host's globals.
* `lib/matrix` is the same API without either. The client this exports
* refuses the few calls that would collide with the host's js-sdk: a sync
* loop, crypto, and the IndexedDB stores both would open by the same name.
*/
import { IndexedDBStore, MatrixClient } from "matrix-js-sdk/lib/matrix";
function refuse<C extends { prototype: object }>(
cls: C,
name: string,
methods: (keyof C["prototype"] & string)[],
): void {
for (const method of methods)
Object.defineProperty(cls.prototype, method, {
value() {
throw new Error(
`${name}.${method} is not available in the Element Call component: the host's client does this`,
);
},
});
}
refuse(MatrixClient, "MatrixClient", [
"startClient",
"initRustCrypto",
"clearStores",
]);
refuse(IndexedDBStore, "IndexedDBStore", ["startup"]);
export * from "matrix-js-sdk/lib/matrix";
+2 -1
View File
@@ -34,7 +34,8 @@
"./style.css": "./dist/element-call.css"
},
"sideEffects": [
"*.css"
"*.css",
"./guestJsSdk.ts"
],
"scripts": {
"prepare": "cd .. && pnpm install --frozen-lockfile && pnpm build:component"
+11 -11
View File
@@ -6,18 +6,18 @@ Please see LICENSE in the repository root for full details.
*/
/**
* Checks the component build's output for what a host must not be handed.
* Checks the component build's output for things we do not want to end up in the
* component target.
*
* A library build inlines every asset it meets as a data URL unless the import
* says otherwise, and does so silently: one import without `no-inline` and the
* module grows by the asset, encoded a third larger, that every host then
* downloads and parses before the first call. MediaPipe's runtime alone is
* 11 MB. A reference to a file by an absolute path is just as silent and
* breaks at runtime instead, since a host serves the module from wherever it
* likes. And the standalone app's client store worker, which carries a copy of
* the Matrix SDK and its crypto, has no business in a package whose host
* supplies the client: the bundler emits it on loading its import, used or
* not (see src/utils/initClient.ts). This fails the build on each of those.
* A library build inlines every asset it needs as a data URL unless the import
* says otherwise: if one adds an import without `no-inline` the
* module grows by the asset (due to encoding a third larger than the original file)
* that every host then downloads and parses before the first call.
* MediaPipe's runtime alone is 11 MB, so it should not be inlined.
* The standalone app's client store worker, which carries a copy of the Matrix SDK
* and its crypto, is also not needed in a package whose host supplies the client:
* the bundler packages if it is imported, even if not used (see src/utils/initClient.ts).
* The script makes sure, the build fails on each of those issues.
*/
import { existsSync } from "node:fs";
+15 -8
View File
@@ -5,8 +5,9 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE in the repository root for full details.
*/
import { defineConfig } from "vite";
import { defineConfig, mergeConfig } from "vite";
import { posix } from "node:path";
import { fileURLToPath } from "node:url";
import { vitePluginsConfig, withoutMatrixCrypto } from "./vite.config.ts";
import { scopeStylesToRoot } from "./component/build/scopeStylesToRoot.ts";
@@ -21,17 +22,23 @@ export default defineConfig(({ mode }) => {
return {
...base,
plugins: [...(base.plugins ?? []), withoutMatrixCrypto()],
resolve: {
...base.resolve,
alias: {
...base.resolve?.alias,
// mergeConfig appends to the base's aliases, whatever form they are in
resolve: mergeConfig(base.resolve ?? {}, {
alias: [
// react-i18next depends on the CommonJS `use-sync-external-store/shim`, whose
// `require("react")` cannot be bundled against an external React: rolldown leaves a
// `require` shim that throws in the browser. React 18+ provides `useSyncExternalStore`
// itself, so point the shim at React.
"use-sync-external-store/shim": "react",
},
},
{ find: "use-sync-external-store/shim", replacement: "react" },
// Only the bare name, not its subpaths: see component/guestJsSdk.ts
{
find: /^matrix-js-sdk$/,
replacement: fileURLToPath(
new URL("./component/guestJsSdk.ts", import.meta.url),
),
},
],
}),
// A library has no public directory to serve. Without this the build copies
// whatever is in `public` — including the developer's own config.json, which
// is not in the repository — into the output we would publish.