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
7 changes: 7 additions & 0 deletions .changeset/sweet-tires-flash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@lynx-js/runtime-wrapper-webpack-plugin": minor
---

Add parameter forwarding for Browser Object Model (BOM) APIs.

This allows direct access to APIs like `fetch`, `requestAnimationFrame`.
4 changes: 2 additions & 2 deletions .github/workflows/deploy-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
# See: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/caching-dependencies-to-speed-up-workflows#restrictions-for-accessing-a-cache
build-all:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
group: ${{ github.workflow }}-build-${{ github.ref }}
cancel-in-progress: true
uses: ./.github/workflows/workflow-build.yml
if: github.repository == 'lynx-family/lynx-stack'
Expand Down Expand Up @@ -87,7 +87,7 @@ jobs:
runs-on: ubuntu-latest
if: github.repository == 'lynx-family/lynx-stack'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
group: ${{ github.workflow }}-publish-${{ github.ref }}
cancel-in-progress: false
environment: main branch
permissions:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/workflow-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: ${{ inputs.codecov-flags }}
override_branch: ${{ github.event_name == 'merge_queue' && 'main' || '' }}
override_branch: ${{ github.event_name == 'merge_group' && 'main' || '' }}
- name: Upload Test Result
if: ${{ inputs.is-web && failure() }}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"ts-patch": "^3.3.0",
"turbo": "^2.5.3",
"typescript": "^5.8.3",
"typescript-eslint": "^8.32.0",
"typescript-eslint": "^8.32.1",
"vitest": "^3.1.3"
},
"packageManager": "pnpm@10.10.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/rspeedy/create-rspeedy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"test": "vitest"
},
"dependencies": {
"create-rstack": "1.4.4"
"create-rstack": "1.4.5"
},
"devDependencies": {
"@lynx-js/qrcode-rsbuild-plugin": "workspace:^",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,33 @@ const defaultInjectVars = [
'Behavior',
'LynxJSBI',
'lynx',

// BOM API
'window',
'document',
'frames',
'self',
'location',
'navigator',
'localStorage',
'history',
'Caches',
'screen',
'alert',
'confirm',
'prompt',
'fetch',
'XMLHttpRequest',
'__WebSocket__', // We would provide `WebSocket` using `ProvidePlugin`
'webkit',
'Reporter',
'print',
'__Function__', // We should allow using `Function`
'global',

// Lynx API
'requestAnimationFrame',
'cancelAnimationFrame',
];

/**
Expand Down Expand Up @@ -242,7 +268,9 @@ lynx.targetSdkVersion=lynx.targetSdkVersion||${
JSON.stringify(targetSdkVersion)
};
${overrideRuntimePromise ? `var Promise = lynx.Promise;` : ''}
var fetch = lynx.fetch;
fetch = fetch || lynx.fetch;
requestAnimationFrame = requestAnimationFrame || lynx.requestAnimationFrame;
cancelAnimationFrame = cancelAnimationFrame || lynx.cancelAnimationFrame;
`
);
};
Expand Down
31 changes: 31 additions & 0 deletions packages/webpack/runtime-wrapper-webpack-plugin/test/cases.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,37 @@ describeCases({
null,
null,
console,
undefined, // Component
undefined, // ReactLynx
undefined, // nativeAppId
undefined, // Behavior
undefined, // LynxJSBI
undefined, // lynx
undefined, // window
// BOM API
undefined, // document
undefined, // frames
undefined, // self
undefined, // location
undefined, // navigator
undefined, // localStorage
undefined, // history
undefined, // Caches
undefined, // screen
undefined, // alert
undefined, // confirm
undefined, // prompt
undefined, // fetch
undefined, // XMLHttpRequest
undefined, // WebSocket
undefined, // webkit
undefined, // Reporter
undefined, // print
undefined, // Function
undefined, // global
// Lynx API
vi.fn(), // requestAnimationFrame
vi.fn(), // cancelAnimationFrame
);
},
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
// Copyright 2024 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.
*/
expect(requestAnimationFrame).toStrictEqual(expect.any(Function));
expect(cancelAnimationFrame).toStrictEqual(expect.any(Function));
expect(requestAnimationFrame).not.toBe(lynx.requestAnimationFrame);
expect(cancelAnimationFrame).not.toBe(lynx.cancelAnimationFrame);
expect(requestAnimationFrame).not.toBe(globalThis.requestAnimationFrame);
expect(cancelAnimationFrame).not.toBe(globalThis.cancelAnimationFrame);
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
// Copyright 2024 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.
*/
import config from './webpack.config.js';

export default config;
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
// Copyright 2024 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.
*/
import { RuntimeWrapperWebpackPlugin } from '../../../../src';

/** @type {import('webpack').Configuration} */
export default {
plugins: [
new RuntimeWrapperWebpackPlugin(),
],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
// Copyright 2024 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.
*/

expect(WebSocket).toBe(globalThis.WebSocket);
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
// Copyright 2024 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.
*/
import config from './webpack.config.js';

export default config;
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
// Copyright 2024 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.
*/
import { RuntimeWrapperWebpackPlugin } from '../../../../src';

/** @type {import('webpack').Configuration} */
export default {
plugins: [
new RuntimeWrapperWebpackPlugin(),
],
};
Loading