Compare commits

...

14 Commits

Author SHA1 Message Date
ClarkXia c20d38eee7
Merge 34659a428e into ace5e1dd15 2025-07-24 16:30:29 +08:00
ClarkXia ace5e1dd15
Merge pull request #7127 from alibaba/hotfix/env
CI / build (16.x, ubuntu-latest) (push) Has been cancelled Details
CI / build (16.x, windows-latest) (push) Has been cancelled Details
CI / build (18.x, ubuntu-latest) (push) Has been cancelled Details
CI / build (18.x, windows-latest) (push) Has been cancelled Details
Coverage / coverage (16.x) (push) Has been cancelled Details
Release / Release (16) (push) Has been cancelled Details
hotfix: add isPHA and isKraken env for backward compatibility
2025-07-24 15:27:08 +08:00
ClarkXia 0141336861
Merge pull request #7125 from alibaba/release/next
CI / build (16.x, ubuntu-latest) (push) Waiting to run Details
CI / build (16.x, windows-latest) (push) Waiting to run Details
CI / build (18.x, ubuntu-latest) (push) Waiting to run Details
CI / build (18.x, windows-latest) (push) Waiting to run Details
Coverage / coverage (16.x) (push) Waiting to run Details
Release / Release (16) (push) Waiting to run Details
Release@3.6.4
2025-07-24 10:49:29 +08:00
ClarkXia 7f302fa439
chore: update versions (#7126) 2025-07-24 10:01:12 +08:00
ZeroLing 0dd4aab050
重构内置 env.ts 实现 (#7124)
Publish canary / Publish Canary (18) (push) Blocked by required conditions Details
Publish canary / Check Changeset exists (push) Has been cancelled Details
CI / build (16.x, ubuntu-latest) (push) Has been cancelled Details
CI / build (16.x, windows-latest) (push) Has been cancelled Details
CI / build (18.x, ubuntu-latest) (push) Has been cancelled Details
CI / build (18.x, windows-latest) (push) Has been cancelled Details
Version / Version (16) (push) Has been cancelled Details
* refactor: add env for themis, delete PHA/Kraken, simplize WindVane

* chore: add changeset
2025-07-22 15:53:14 +08:00
Mixiu d55e34bc56
feat(runtime): add suspense event dispatch in Suspense component (#7122)
* feat(runtime): add suspense event dispatch in Suspense component

* chore(runtime): add changeset

* fix(runtime): Apply suggestions from code review

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* fix(runtime): optimize Suspense component script rendering

* fix(runtime): move dispatchSuspenseEvent function outside of withSuspense in Suspense.tsx

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-07-22 15:47:58 +08:00
ClarkXia b2d93c6ffe Merge branch 'master' into release/next 2025-07-14 10:37:03 +08:00
ClarkXia 72bfa88d17 chore: update version
Publish canary / Check Changeset exists (push) Has been cancelled Details
CI / build (16.x, ubuntu-latest) (push) Has been cancelled Details
CI / build (16.x, windows-latest) (push) Has been cancelled Details
CI / build (18.x, ubuntu-latest) (push) Has been cancelled Details
CI / build (18.x, windows-latest) (push) Has been cancelled Details
Version / Version (16) (push) Has been cancelled Details
Publish canary / Publish Canary (18) (push) Has been cancelled Details
2025-07-08 19:24:32 +08:00
ClarkXia 9b95b4c031 Merge branch 'master' into release/next 2025-07-08 19:19:02 +08:00
ClarkXia 22d1b49c9c chore: version 2025-07-08 19:15:34 +08:00
ClarkXia 4569200caf
feat: support externals field in assets-manifest (#7116)
Publish canary / Check Changeset exists (push) Waiting to run Details
Publish canary / Publish Canary (18) (push) Blocked by required conditions Details
CI / build (16.x, ubuntu-latest) (push) Waiting to run Details
CI / build (16.x, windows-latest) (push) Waiting to run Details
CI / build (18.x, ubuntu-latest) (push) Waiting to run Details
CI / build (18.x, windows-latest) (push) Waiting to run Details
Version / Version (16) (push) Waiting to run Details
2025-07-08 16:40:00 +08:00
ClarkXia 34659a428e
chore: update types 2024-07-25 11:43:12 +08:00
ClarkXia 5a15fac778 feat: plugin react-query 2024-07-09 15:11:58 +08:00
ClarkXia 2837d34b55 feat: init plugin-react-query 2024-07-09 13:47:10 +08:00
21 changed files with 292 additions and 16 deletions

View File

@ -1,5 +1,17 @@
# Changelog
## 3.6.5
- hotfix: add isPHA and isKraken env for backward compatibility.
## 3.6.4
### Patch Changes
- 0dd4aab0: refactor: add env for themis, delete PHA/Kraken, simplize WindVane
- Updated dependencies [d55e34bc]
- @ice/runtime@1.5.6
## 3.6.3
### Patch Changes

View File

@ -1,6 +1,6 @@
{
"name": "@ice/app",
"version": "3.6.3",
"version": "3.6.5",
"description": "provide scripts and configuration used by web framework ice",
"type": "module",
"main": "./esm/index.js",

View File

@ -9,16 +9,16 @@ export const isByteDanceMicroApp = isClient && import.meta.target === 'bytedance
export const isBaiduSmartProgram = isClient && import.meta.target === 'baidu-smartprogram';
export const isKuaiShouMiniProgram = isClient && import.meta.target === 'kuaishou-miniprogram';
export const isWeChatMiniProgram = isClient && import.meta.target === 'wechat-miniprogram';
export const isKraken = isClient && import.meta.target === 'kraken';
export const isQuickApp = false; // Now ice.js will not implement quick app target.
export const isMiniApp = isAliMiniApp;// in universal-env, isMiniApp is equals to isAliMiniApp
export const isMiniApp = isAliMiniApp; // in universal-env, isMiniApp is equals to isAliMiniApp
export const isKraken = isClient && import.meta.target === 'kraken';
// Following variables are runtime executed envs.
// See also @uni/env.
export const isPHA = isWeb && typeof pha === 'object';
const ua = typeof navigator === 'object' ? navigator.userAgent || navigator.swuserAgent : '';
const wvRegExp = /.+AliApp\((\w+)\/((?:\d+\.)+\d+)\).* .*(WindVane)(?:\/((?:\d+\.)+\d+))?.*/;
export const isWindVane = wvRegExp.test(ua) && isWeb && typeof WindVane !== 'undefined' && typeof WindVane.call !== 'undefined';
export const isThemis = /Themis/.test(ua);
export const isWindVane = /WindVane/i.test(ua) && isWeb && typeof WindVane !== 'undefined' && typeof WindVane.call !== 'undefined';
// WindVane.call is a function while page importing lib-windvane
export const isFRM = isMiniApp && isWeb && typeof my !== 'undefined' && typeof my.isFRM !== 'undefined';
@ -28,13 +28,14 @@ export default {
isNode,
isWeex,
isKraken,
isPHA,
isThemis,
isMiniApp,
isByteDanceMicroApp,
isBaiduSmartProgram,
isKuaiShouMiniProgram,
isWeChatMiniProgram,
isQuickApp,
isPHA,
isWindVane,
isFRM,
};

View File

@ -1,5 +1,11 @@
# @ice/miniapp-react-dom
## 1.1.6
### Patch Changes
- @ice/miniapp-runtime@1.2.6
## 1.1.5
### Patch Changes

View File

@ -1,6 +1,6 @@
{
"name": "@ice/miniapp-react-dom",
"version": "1.1.5",
"version": "1.1.6",
"description": "like react-dom, but for miniapps.",
"type": "module",
"types": "./esm/index.d.ts",

View File

@ -1,5 +1,12 @@
# Changelog
## 1.2.6
### Patch Changes
- Updated dependencies [d55e34bc]
- @ice/runtime@1.5.6
## 1.2.5
### Patch Changes

View File

@ -1,6 +1,6 @@
{
"name": "@ice/miniapp-runtime",
"version": "1.2.5",
"version": "1.2.6",
"description": "ice runtime for miniapps.",
"type": "module",
"types": "./esm/index.d.ts",

View File

@ -56,8 +56,8 @@
"webpack-dev-server": "4.15.0"
},
"peerDependencies": {
"@ice/app": "^3.6.3",
"@ice/runtime": "^1.5.4"
"@ice/app": "^3.6.4",
"@ice/runtime": "^1.5.6"
},
"publishConfig": {
"access": "public"

View File

@ -1,5 +1,12 @@
# Changelog
## 1.2.7
### Patch Changes
- @ice/miniapp-runtime@1.2.6
- @ice/miniapp-react-dom@1.1.6
## 1.2.6
### Patch Changes

View File

@ -1,6 +1,6 @@
{
"name": "@ice/plugin-miniapp",
"version": "1.2.6",
"version": "1.2.7",
"description": "ice.js plugin for miniapp.",
"license": "MIT",
"type": "module",
@ -50,8 +50,8 @@
"sax": "^1.2.4"
},
"devDependencies": {
"@ice/app": "^3.6.3",
"@ice/runtime": "^1.5.4",
"@ice/app": "^3.6.4",
"@ice/runtime": "^1.5.6",
"webpack": "^5.88.0"
},
"repository": {

View File

@ -0,0 +1,5 @@
# @ice/plugin-react-query
## 1.0.0
- Initial release

View File

View File

@ -0,0 +1,36 @@
{
"name": "@ice/plugin-react-query",
"version": "1.0.0",
"description": "React Query plugin for ice.",
"license": "MIT",
"type": "module",
"main": "./esm/index.js",
"types": "./esm/index.d.ts",
"files": [
"esm",
"!esm/**/*.map",
"*.d.ts"
],
"dependencies": {
"@tanstack/react-query": "^5.50.1",
"@tanstack/react-query-devtools": "^5.50.1"
},
"devDependencies": {
"@ice/app": "^3.4.9",
"@ice/runtime": "^1.4.8",
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.0",
"@tanstack/query-devtools": "^5.50.1"
},
"repository": {
"type": "http",
"url": "https://github.com/alibaba/ice/tree/master/packages/plugin-request"
},
"scripts": {
"watch": "tsc -w --sourceMap",
"build": "tsc"
},
"publishConfig": {
"access": "public"
}
}

View File

@ -0,0 +1,47 @@
import { createRequire } from 'module';
import type { Plugin } from '@ice/app/types';
const require = createRequire(import.meta.url);
const PLUGIN_NAME = '@ice/plugin-react-query';
const plugin: Plugin<void> = () => {
return {
name: PLUGIN_NAME,
setup: ({ generator, onGetConfig }) => {
generator.addExport({
specifier: [
// Core API export from @tanstack/react-query
'useQuery',
'useMutation',
'useQueryClient',
'useMutationState',
'useSuspenseQuery',
'useSuspenseInfiniteQuery',
'useSuspenseQueries',
'queryOptions',
'infiniteQueryOptions',
'QueryClientProvider',
'useQueryClient',
'QueryErrorResetBoundary',
'useQueryErrorResetBoundary',
'useIsRestoring',
'IsRestoringProvider',
],
source: '@tanstack/react-query',
type: false,
});
onGetConfig((config) => {
// Add alias for react-query and react-query-devtools to avoid mismatching versions.
config.alias = {
...config.alias,
'@tanstack/react-query': require.resolve('@tanstack/react-query'),
'@tanstack/react-query-devtools': require.resolve('@tanstack/react-query-devtools'),
};
});
},
runtime: `${PLUGIN_NAME}/runtime`,
staticRuntime: true,
};
};
export default plugin;

View File

@ -0,0 +1,36 @@
import * as React from 'react';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
import type { RuntimePlugin } from '@ice/runtime/types';
import type { ReactQueryConfig } from './types';
const EXPORT_CONFIG_NAME = 'reactQueryConfig';
const runtime: RuntimePlugin = ({ addProvider, appContext }) => {
const { appExport } = appContext;
const reactQueryConfig = appExport[EXPORT_CONFIG_NAME] as ReactQueryConfig;
const queryClient = new QueryClient({
...(reactQueryConfig?.queryClientConfig || {}),
defaultOptions: {
queries: {
refetchOnWindowFocus: false,
retry: false,
...(reactQueryConfig?.queryClientConfig.defaultOptions?.queries || {}),
},
},
});
const ProviderWrapper = ({ children }) => {
return (
<QueryClientProvider client={queryClient}>
{children}
{ reactQueryConfig?.devTools &&
<ReactQueryDevtools
{...(reactQueryConfig.devTools || {})}
/> }
</QueryClientProvider>
);
};
addProvider(ProviderWrapper);
};
export default runtime;

View File

@ -0,0 +1,17 @@
import type { QueryClientConfig, QueryClient } from '@tanstack/react-query';
import type { DevtoolsButtonPosition, DevtoolsPosition, DevToolsErrorType } from '@tanstack/query-devtools';
interface DevtoolsOptions {
initialIsOpen?: boolean;
buttonPosition?: DevtoolsButtonPosition;
position?: DevtoolsPosition;
client?: QueryClient;
errorTypes?: Array<DevToolsErrorType>;
styleNonce?: string;
shadowDOMTarget?: ShadowRoot;
}
export interface ReactQueryConfig {
devTools?: DevtoolsOptions;
queryClientConfig?: QueryClientConfig;
}

View File

@ -0,0 +1,10 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"baseUrl": "./",
"rootDir": "src",
"outDir": "esm",
"jsx": "react"
},
"include": ["src"]
}

View File

@ -1,5 +1,11 @@
# @ice/runtime
## 1.5.6
### Patch Changes
- d55e34bc: feat: add suspense event dispatch in Suspense component
## 1.5.5
### Patch Changes

View File

@ -1,6 +1,6 @@
{
"name": "@ice/runtime",
"version": "1.5.5",
"version": "1.5.6",
"description": "Runtime module for ice.js",
"type": "module",
"types": "./esm/index.d.ts",

View File

@ -126,6 +126,11 @@ interface SuspenseProps {
[key: string]: any;
}
function dispatchSuspenseEvent(event: string, id: string) {
window.dispatchEvent(new CustomEvent(event, { detail: { id } }));
}
const DISPATCH_SUSPENSE_EVENT_STRING = dispatchSuspenseEvent.toString();
export function withSuspense(Component) {
return (props: SuspenseProps) => {
const { fallback, id, ...componentProps } = props;
@ -153,10 +158,22 @@ export function withSuspense(Component) {
return (
<React.Suspense fallback={fallback || null}>
<InlineScript
id={`suspense-parse-start-${id}`}
script={`(${DISPATCH_SUSPENSE_EVENT_STRING})('ice-suspense-parse-start','${id}');`}
/>
<SuspenseContext.Provider value={suspenseState}>
<Component {...componentProps} />
<InlineScript
id={`suspense-parse-data-${id}`}
script={`(${DISPATCH_SUSPENSE_EVENT_STRING})('ice-suspense-parse-data','${id}');`}
/>
<Data id={id} />
</SuspenseContext.Provider>
<InlineScript
id={`suspense-parse-end-${id}`}
script={`(${DISPATCH_SUSPENSE_EVENT_STRING})('ice-suspense-parse-end','${id}');`}
/>
</React.Suspense>
);
};
@ -174,3 +191,20 @@ function Data(props) {
/>
);
}
interface InlineScriptProps {
id: string;
script: string;
}
function InlineScript(props: InlineScriptProps) {
return (
<script
id={props.id}
dangerouslySetInnerHTML={{
__html: props.script,
}}
suppressHydrationWarning
/>
);
}

View File

@ -2157,10 +2157,10 @@ importers:
version: 1.2.4
devDependencies:
'@ice/app':
specifier: ^3.6.3
specifier: ^3.6.4
version: link:../ice
'@ice/runtime':
specifier: ^1.5.4
specifier: ^1.5.6
version: link:../runtime
webpack:
specifier: ^5.88.0
@ -2252,6 +2252,31 @@ importers:
specifier: ^5.88.0
version: 5.88.2
packages/plugin-react-query:
dependencies:
'@tanstack/react-query':
specifier: ^5.50.1
version: 5.50.1(react@18.2.0)
'@tanstack/react-query-devtools':
specifier: ^5.50.1
version: 5.50.1(@tanstack/react-query@5.50.1)(react@18.2.0)
devDependencies:
'@ice/app':
specifier: ^3.4.9
version: link:../ice
'@ice/runtime':
specifier: ^1.4.8
version: link:../runtime
'@tanstack/query-devtools':
specifier: ^5.50.1
version: 5.50.1
'@types/react':
specifier: ^18.0.0
version: 18.0.34
'@types/react-dom':
specifier: ^18.0.0
version: 18.0.11
packages/plugin-request:
dependencies:
ahooks:
@ -8568,6 +8593,33 @@ packages:
dependencies:
defer-to-connect: 1.1.3
/@tanstack/query-core@5.50.1:
resolution: {integrity: sha512-lpfhKPrJlyV2DSVcQb/HuozH3Av3kws4ge22agx+lNGpFkS4vLZ7St0l3GLwlAD+bqB+qXGex3JdRKUNtMviEQ==}
dev: false
/@tanstack/query-devtools@5.50.1:
resolution: {integrity: sha512-MQ5JK3yRwBP1SRuwoJVPGZP4cMLXCQ0t+6blDbcAVGEoqrEuvbgTdwlN729AKBR0hidOWPFR9n5YpI2Y8bBZOQ==}
/@tanstack/react-query-devtools@5.50.1(@tanstack/react-query@5.50.1)(react@18.2.0):
resolution: {integrity: sha512-zgPmEFv9GhLAx6eaf9r0ACbcxit1ZSuv/uPpOXBTTSPLijlWcfpQTOdZx0jYQ14t2cUfWjrAW41cUmcCvT4X/g==}
peerDependencies:
'@tanstack/react-query': ^5.50.1
react: ^18 || ^19
dependencies:
'@tanstack/query-devtools': 5.50.1
'@tanstack/react-query': 5.50.1(react@18.2.0)
react: 18.2.0
dev: false
/@tanstack/react-query@5.50.1(react@18.2.0):
resolution: {integrity: sha512-s0DW3rVBDPReDDovUjVqItVa3R2nPfUANK9nqGvarO2DwTiY9U4EBTsqizMxItRCoGgK5apeM7D3mxlHrSKpdQ==}
peerDependencies:
react: ^18.0.0
dependencies:
'@tanstack/query-core': 5.50.1
react: 18.2.0
dev: false
/@testing-library/dom@8.20.0:
resolution: {integrity: sha512-d9ULIT+a4EXLX3UU8FBjauG9NnsZHkHztXoIcTsOKoOw030fyjheN9svkTULjJxtYag9DZz5Jz5qkWZDPxTFwA==}
engines: {node: '>=12'}