@lynx-js/luna-stage 0.0.0-oidc-bootstrap.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +415 -5
- package/dist/components/context/create-context.d.ts +55 -0
- package/dist/components/context/create-context.d.ts.map +1 -0
- package/dist/components/context/create-context.js +32 -0
- package/dist/components/context/create-context.js.map +1 -0
- package/dist/components/context/index.d.ts +2 -0
- package/dist/components/context/index.d.ts.map +1 -0
- package/dist/components/context/index.js +1 -0
- package/dist/components/stage/index.d.ts +2 -0
- package/dist/components/stage/index.d.ts.map +1 -0
- package/dist/components/stage/index.js +1 -0
- package/dist/components/stage/stage.d.ts +10 -0
- package/dist/components/stage/stage.d.ts.map +1 -0
- package/dist/components/stage/stage.js +185 -0
- package/dist/components/stage/stage.js.map +1 -0
- package/dist/constants/stage.d.ts +4 -0
- package/dist/constants/stage.d.ts.map +1 -0
- package/dist/constants/stage.js +6 -0
- package/dist/constants/stage.js.map +1 -0
- package/dist/hooks/index.d.ts +6 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +5 -0
- package/dist/hooks/use-container-resize.d.ts +30 -0
- package/dist/hooks/use-container-resize.d.ts.map +1 -0
- package/dist/hooks/use-container-resize.js +63 -0
- package/dist/hooks/use-container-resize.js.map +1 -0
- package/dist/hooks/use-event-callback.d.ts +36 -0
- package/dist/hooks/use-event-callback.d.ts.map +1 -0
- package/dist/hooks/use-event-callback.js +18 -0
- package/dist/hooks/use-event-callback.js.map +1 -0
- package/dist/hooks/use-is-client.d.ts +2 -0
- package/dist/hooks/use-is-client.d.ts.map +1 -0
- package/dist/hooks/use-is-client.js +16 -0
- package/dist/hooks/use-is-client.js.map +1 -0
- package/dist/hooks/use-isomorphic-layout-effect.d.ts +4 -0
- package/dist/hooks/use-isomorphic-layout-effect.d.ts.map +1 -0
- package/dist/hooks/use-isomorphic-layout-effect.js +6 -0
- package/dist/hooks/use-isomorphic-layout-effect.js.map +1 -0
- package/dist/hooks/use-merged-refs.d.ts +5 -0
- package/dist/hooks/use-merged-refs.d.ts.map +1 -0
- package/dist/hooks/use-merged-refs.js +18 -0
- package/dist/hooks/use-merged-refs.js.map +1 -0
- package/dist/hooks/use-raf-clock.d.ts +17 -0
- package/dist/hooks/use-raf-clock.d.ts.map +1 -0
- package/dist/hooks/use-raf-clock.js +22 -0
- package/dist/hooks/use-raf-clock.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/lynx/index.d.ts +7 -0
- package/dist/lynx/index.d.ts.map +1 -0
- package/dist/lynx/index.js +3 -0
- package/dist/lynx/luna-lynx-stage.d.ts +32 -0
- package/dist/lynx/luna-lynx-stage.d.ts.map +1 -0
- package/dist/lynx/luna-lynx-stage.js +45 -0
- package/dist/lynx/luna-lynx-stage.js.map +1 -0
- package/dist/lynx/lynx-stage-constants.d.ts +8 -0
- package/dist/lynx/lynx-stage-constants.d.ts.map +1 -0
- package/dist/lynx/lynx-stage-constants.js +26 -0
- package/dist/lynx/lynx-stage-constants.js.map +1 -0
- package/dist/lynx/lynx-stage.d.ts +25 -0
- package/dist/lynx/lynx-stage.d.ts.map +1 -0
- package/dist/lynx/lynx-stage.js +33 -0
- package/dist/lynx/lynx-stage.js.map +1 -0
- package/dist/lynx/types.d.ts +77 -0
- package/dist/lynx/types.d.ts.map +1 -0
- package/dist/lynx/types.js +0 -0
- package/dist/lynx/use-lynx-stage.d.ts +5 -0
- package/dist/lynx/use-lynx-stage.d.ts.map +1 -0
- package/dist/lynx/use-lynx-stage.js +130 -0
- package/dist/lynx/use-lynx-stage.js.map +1 -0
- package/dist/motion/context/index.d.ts +6 -0
- package/dist/motion/context/index.d.ts.map +1 -0
- package/dist/motion/context/index.js +3 -0
- package/dist/motion/context/use-visual-size.d.ts +8 -0
- package/dist/motion/context/use-visual-size.d.ts.map +1 -0
- package/dist/motion/context/use-visual-size.js +8 -0
- package/dist/motion/context/use-visual-size.js.map +1 -0
- package/dist/motion/context/visual-size-context.d.ts +10 -0
- package/dist/motion/context/visual-size-context.d.ts.map +1 -0
- package/dist/motion/context/visual-size-context.js +5 -0
- package/dist/motion/context/visual-size-context.js.map +1 -0
- package/dist/motion/context/visual-size-provider.d.ts +9 -0
- package/dist/motion/context/visual-size-provider.d.ts.map +1 -0
- package/dist/motion/context/visual-size-provider.js +19 -0
- package/dist/motion/context/visual-size-provider.js.map +1 -0
- package/dist/motion/index.d.ts +5 -0
- package/dist/motion/index.d.ts.map +1 -0
- package/dist/motion/index.js +2 -0
- package/dist/motion/stage/container-motion.d.ts +25 -0
- package/dist/motion/stage/container-motion.d.ts.map +1 -0
- package/dist/motion/stage/container-motion.js +111 -0
- package/dist/motion/stage/container-motion.js.map +1 -0
- package/dist/motion/stage/index.d.ts +5 -0
- package/dist/motion/stage/index.d.ts.map +1 -0
- package/dist/motion/stage/index.js +3 -0
- package/dist/motion/stage/presentation-motion.d.ts +17 -0
- package/dist/motion/stage/presentation-motion.d.ts.map +1 -0
- package/dist/motion/stage/presentation-motion.js +33 -0
- package/dist/motion/stage/presentation-motion.js.map +1 -0
- package/dist/motion/stage/stage-motion.d.ts +5 -0
- package/dist/motion/stage/stage-motion.d.ts.map +1 -0
- package/dist/motion/stage/stage-motion.js +184 -0
- package/dist/motion/stage/stage-motion.js.map +1 -0
- package/dist/motion/stage/transform-utils.d.ts +9 -0
- package/dist/motion/stage/transform-utils.d.ts.map +1 -0
- package/dist/motion/stage/transform-utils.js +20 -0
- package/dist/motion/stage/transform-utils.js.map +1 -0
- package/dist/motion/stage/types.d.ts +85 -0
- package/dist/motion/stage/types.d.ts.map +1 -0
- package/dist/motion/stage/types.js +0 -0
- package/dist/motion/stage/use-container-resize-mv.d.ts +13 -0
- package/dist/motion/stage/use-container-resize-mv.d.ts.map +1 -0
- package/dist/motion/stage/use-container-resize-mv.js +64 -0
- package/dist/motion/stage/use-container-resize-mv.js.map +1 -0
- package/dist/types/align.d.ts +3 -0
- package/dist/types/align.d.ts.map +1 -0
- package/dist/types/align.js +0 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +0 -0
- package/dist/types/lynx-view.d.ts +18 -0
- package/dist/types/lynx-view.d.ts.map +1 -0
- package/dist/types/lynx-view.js +0 -0
- package/dist/types/stage-props.d.ts +94 -0
- package/dist/types/stage-props.d.ts.map +1 -0
- package/dist/types/stage-props.js +0 -0
- package/dist/utils/align.d.ts +3 -0
- package/dist/utils/align.d.ts.map +1 -0
- package/dist/utils/align.js +15 -0
- package/dist/utils/align.js.map +1 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/transform.d.ts +121 -0
- package/dist/utils/transform.d.ts.map +1 -0
- package/dist/utils/transform.js +37 -0
- package/dist/utils/transform.js.map +1 -0
- package/package.json +73 -5
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { LunaThemeKey } from '@lynx-js/luna-core';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
import type { UseLynxStageOptions } from './types';
|
|
4
|
+
import type { LynxGlobalProps } from '../types/lynx-view';
|
|
5
|
+
export type LunaLynxStageProps = Omit<UseLynxStageOptions, 'globalProps' | 'bundleRoot'> & {
|
|
6
|
+
/** LUNA theme key, e.g. `'luna-light'`, `'lunaris-dark'`. */
|
|
7
|
+
lunaTheme?: LunaThemeKey;
|
|
8
|
+
/**
|
|
9
|
+
* Additional global props to inject alongside LUNA theme props.
|
|
10
|
+
* Merged with the LUNA props — LUNA props take precedence on key conflicts.
|
|
11
|
+
*/
|
|
12
|
+
extraGlobalProps?: LynxGlobalProps;
|
|
13
|
+
/**
|
|
14
|
+
* Resource root used together with `entry` to locate the Lynx bundle.
|
|
15
|
+
* The default resolver normalizes a trailing slash and builds
|
|
16
|
+
* `${bundleRoot}${entry}.web.bundle`.
|
|
17
|
+
* @defaultValue '/'
|
|
18
|
+
*/
|
|
19
|
+
bundleRoot?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Shared Lynx worker group ID. Defaults to 7.
|
|
22
|
+
* Override to isolate workers between unrelated view groups.
|
|
23
|
+
*/
|
|
24
|
+
groupId?: number;
|
|
25
|
+
/**
|
|
26
|
+
* Enables pointer interactions on the underlying `<lynx-view>` host element.
|
|
27
|
+
* @defaultValue true
|
|
28
|
+
*/
|
|
29
|
+
interactive?: boolean;
|
|
30
|
+
};
|
|
31
|
+
export declare function LunaLynxStage(props: LunaLynxStageProps): ReactNode;
|
|
32
|
+
//# sourceMappingURL=luna-lynx-stage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"luna-lynx-stage.d.ts","sourceRoot":"","sources":["../../src/lynx/luna-lynx-stage.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAoB,MAAM,oBAAoB,CAAA;AACxE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAStC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAGlD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAEzD,MAAM,MAAM,kBAAkB,GAC1B,IAAI,CAAC,mBAAmB,EAAE,aAAa,GAAG,YAAY,CAAC,GACvD;IACA,6DAA6D;IAC7D,SAAS,CAAC,EAAE,YAAY,CAAA;IACxB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,eAAe,CAAA;IAClC;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB,CAAA;AA6CH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,SAAS,CAQlE"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import { CONTAINER_STYLE, DEFAULT_GROUP_ID, LYNX_VIEW_STYLE_INTERACTIVE, LYNX_VIEW_STYLE_NON_INTERACTIVE } from "./lynx-stage-constants.js";
|
|
4
|
+
import { useLynxStage } from "./use-lynx-stage.js";
|
|
5
|
+
import { useIsClient } from "../hooks/index.js";
|
|
6
|
+
function LunaLynxStageImpl({ lunaTheme = 'luna-light', extraGlobalProps, groupId = DEFAULT_GROUP_ID, bundleRoot = '/', interactive = true, ...stageOptions }) {
|
|
7
|
+
const globalProps = useMemo(()=>{
|
|
8
|
+
const resolvedThemeVariant = lunaTheme.split('-')[0];
|
|
9
|
+
return {
|
|
10
|
+
...extraGlobalProps ?? {},
|
|
11
|
+
lunaTheme,
|
|
12
|
+
lunaThemeVariant: resolvedThemeVariant
|
|
13
|
+
};
|
|
14
|
+
}, [
|
|
15
|
+
extraGlobalProps,
|
|
16
|
+
lunaTheme
|
|
17
|
+
]);
|
|
18
|
+
const { lynxViewRef, containerRef, src, ready } = useLynxStage({
|
|
19
|
+
...stageOptions,
|
|
20
|
+
globalProps,
|
|
21
|
+
bundleRoot
|
|
22
|
+
});
|
|
23
|
+
return /*#__PURE__*/ jsx("div", {
|
|
24
|
+
ref: containerRef,
|
|
25
|
+
style: CONTAINER_STYLE,
|
|
26
|
+
children: ready && /*#__PURE__*/ jsx("lynx-view", {
|
|
27
|
+
ref: lynxViewRef,
|
|
28
|
+
url: src,
|
|
29
|
+
style: interactive ? LYNX_VIEW_STYLE_INTERACTIVE : LYNX_VIEW_STYLE_NON_INTERACTIVE,
|
|
30
|
+
"lynx-group-id": groupId,
|
|
31
|
+
"transform-vh": true,
|
|
32
|
+
"transform-vw": true
|
|
33
|
+
}, src)
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function LunaLynxStage(props) {
|
|
37
|
+
const isClient = useIsClient();
|
|
38
|
+
if (!isClient) return null;
|
|
39
|
+
return /*#__PURE__*/ jsx(LunaLynxStageImpl, {
|
|
40
|
+
...props
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
export { LunaLynxStage };
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=luna-lynx-stage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lynx/luna-lynx-stage.js","sources":["../../src/lynx/luna-lynx-stage.tsx"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport type { LunaThemeKey, LunaThemeVariant } from '@lynx-js/luna-core'\nimport type { ReactNode } from 'react'\nimport { useMemo } from 'react'\n\nimport {\n CONTAINER_STYLE,\n DEFAULT_GROUP_ID,\n LYNX_VIEW_STYLE_INTERACTIVE,\n LYNX_VIEW_STYLE_NON_INTERACTIVE,\n} from './lynx-stage-constants'\nimport type { UseLynxStageOptions } from './types'\nimport { useLynxStage } from './use-lynx-stage'\nimport { useIsClient } from '../hooks'\nimport type { LynxGlobalProps } from '../types/lynx-view'\n\nexport type LunaLynxStageProps =\n & Omit<UseLynxStageOptions, 'globalProps' | 'bundleRoot'>\n & {\n /** LUNA theme key, e.g. `'luna-light'`, `'lunaris-dark'`. */\n lunaTheme?: LunaThemeKey\n /**\n * Additional global props to inject alongside LUNA theme props.\n * Merged with the LUNA props — LUNA props take precedence on key conflicts.\n */\n extraGlobalProps?: LynxGlobalProps\n /**\n * Resource root used together with `entry` to locate the Lynx bundle.\n * The default resolver normalizes a trailing slash and builds\n * `${bundleRoot}${entry}.web.bundle`.\n * @defaultValue '/'\n */\n bundleRoot?: string\n /**\n * Shared Lynx worker group ID. Defaults to 7.\n * Override to isolate workers between unrelated view groups.\n */\n groupId?: number\n /**\n * Enables pointer interactions on the underlying `<lynx-view>` host element.\n * @defaultValue true\n */\n interactive?: boolean\n }\n\nfunction LunaLynxStageImpl({\n lunaTheme = 'luna-light',\n extraGlobalProps,\n groupId = DEFAULT_GROUP_ID,\n bundleRoot = '/',\n interactive = true,\n ...stageOptions\n}: LunaLynxStageProps): ReactNode {\n const globalProps = useMemo<LynxGlobalProps>(() => {\n const resolvedThemeVariant = lunaTheme.split('-')[0] as LunaThemeVariant\n\n return {\n ...(extraGlobalProps ?? {}),\n lunaTheme,\n lunaThemeVariant: resolvedThemeVariant,\n }\n }, [extraGlobalProps, lunaTheme])\n\n const { lynxViewRef, containerRef, src, ready } = useLynxStage({\n ...stageOptions,\n globalProps,\n bundleRoot,\n })\n\n return (\n <div ref={containerRef} style={CONTAINER_STYLE}>\n {ready && (\n <lynx-view\n key={src}\n ref={lynxViewRef}\n url={src}\n style={interactive\n ? LYNX_VIEW_STYLE_INTERACTIVE\n : LYNX_VIEW_STYLE_NON_INTERACTIVE}\n lynx-group-id={groupId}\n transform-vh={true}\n transform-vw={true}\n />\n )}\n </div>\n )\n}\n\nexport function LunaLynxStage(props: LunaLynxStageProps): ReactNode {\n const isClient = useIsClient()\n\n if (!isClient) {\n return null\n }\n\n return <LunaLynxStageImpl {...props} />\n}\n"],"names":["LunaLynxStageImpl","lunaTheme","extraGlobalProps","groupId","DEFAULT_GROUP_ID","bundleRoot","interactive","stageOptions","globalProps","useMemo","resolvedThemeVariant","lynxViewRef","containerRef","src","ready","useLynxStage","CONTAINER_STYLE","LYNX_VIEW_STYLE_INTERACTIVE","LYNX_VIEW_STYLE_NON_INTERACTIVE","LunaLynxStage","props","isClient","useIsClient"],"mappings":";;;;;AAgDA,SAASA,kBAAkB,EACzBC,YAAY,YAAY,EACxBC,gBAAgB,EAChBC,UAAUC,gBAAgB,EAC1BC,aAAa,GAAG,EAChBC,cAAc,IAAI,EAClB,GAAGC,cACgB;IACnB,MAAMC,cAAcC,QAAyB;QAC3C,MAAMC,uBAAuBT,UAAU,KAAK,CAAC,IAAI,CAAC,EAAE;QAEpD,OAAO;YACL,GAAIC,oBAAoB,CAAC,CAAC;YAC1BD;YACA,kBAAkBS;QACpB;IACF,GAAG;QAACR;QAAkBD;KAAU;IAEhC,MAAM,EAAEU,WAAW,EAAEC,YAAY,EAAEC,GAAG,EAAEC,KAAK,EAAE,GAAGC,aAAa;QAC7D,GAAGR,YAAY;QACfC;QACAH;IACF;IAEA,OAAO,WAAP,GACE,IAAC;QAAI,KAAKO;QAAc,OAAOI;kBAC5BF,SAAS,WAATA,GACC,IAAC;YAEC,KAAKH;YACL,KAAKE;YACL,OAAOP,cACHW,8BACAC;YACJ,iBAAef;YACf,gBAAc;YACd,gBAAc;WARTU;;AAaf;AAEO,SAASM,cAAcC,KAAyB;IACrD,MAAMC,WAAWC;IAEjB,IAAI,CAACD,UACH,OAAO;IAGT,OAAO,WAAP,GAAO,IAACrB,mBAAiBA;QAAE,GAAGoB,KAAK;;AACrC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CSSProperties } from 'react';
|
|
2
|
+
import type { CSSVarProperties } from '../types/lynx-view';
|
|
3
|
+
export declare const LYNX_VIEW_STYLE: CSSProperties & CSSVarProperties;
|
|
4
|
+
export declare const LYNX_VIEW_STYLE_INTERACTIVE: CSSProperties & CSSVarProperties;
|
|
5
|
+
export declare const LYNX_VIEW_STYLE_NON_INTERACTIVE: CSSProperties & CSSVarProperties;
|
|
6
|
+
export declare const CONTAINER_STYLE: CSSProperties;
|
|
7
|
+
export declare const DEFAULT_GROUP_ID = 7;
|
|
8
|
+
//# sourceMappingURL=lynx-stage-constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lynx-stage-constants.d.ts","sourceRoot":"","sources":["../../src/lynx/lynx-stage-constants.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAE1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAQ1D,eAAO,MAAM,eAAe,EAAE,aAAa,GAAG,gBAQ7C,CAAA;AAED,eAAO,MAAM,2BAA2B,EAAE,aAAa,GAAG,gBAGzD,CAAA;AAED,eAAO,MAAM,+BAA+B,EAAE,aAAa,GAAG,gBAI3D,CAAA;AAEH,eAAO,MAAM,eAAe,EAAE,aAI7B,CAAA;AAED,eAAO,MAAM,gBAAgB,IAAI,CAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const LYNX_VIEW_STYLE = {
|
|
2
|
+
width: '100%',
|
|
3
|
+
height: '100%',
|
|
4
|
+
pointerEvents: 'auto',
|
|
5
|
+
containerType: 'size',
|
|
6
|
+
'--rpx-unit': 'calc(100cqw / 750)',
|
|
7
|
+
'--vh-unit': '1cqh',
|
|
8
|
+
'--vw-unit': '1cqw'
|
|
9
|
+
};
|
|
10
|
+
const LYNX_VIEW_STYLE_INTERACTIVE = {
|
|
11
|
+
...LYNX_VIEW_STYLE,
|
|
12
|
+
pointerEvents: 'auto'
|
|
13
|
+
};
|
|
14
|
+
const LYNX_VIEW_STYLE_NON_INTERACTIVE = {
|
|
15
|
+
...LYNX_VIEW_STYLE,
|
|
16
|
+
pointerEvents: 'none'
|
|
17
|
+
};
|
|
18
|
+
const CONTAINER_STYLE = {
|
|
19
|
+
position: 'relative',
|
|
20
|
+
width: '100%',
|
|
21
|
+
height: '100%'
|
|
22
|
+
};
|
|
23
|
+
const DEFAULT_GROUP_ID = 7;
|
|
24
|
+
export { CONTAINER_STYLE, DEFAULT_GROUP_ID, LYNX_VIEW_STYLE, LYNX_VIEW_STYLE_INTERACTIVE, LYNX_VIEW_STYLE_NON_INTERACTIVE };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=lynx-stage-constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lynx/lynx-stage-constants.js","sources":["../../src/lynx/lynx-stage-constants.ts"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport type { CSSProperties } from 'react'\n\nimport type { CSSVarProperties } from '../types/lynx-view'\n\n// Container-relative unit hooks for Lynx runtime:\n// - `containerType: 'size'` enables `cqw/cqh` units based on the host element box.\n// - `--vh-unit/--vw-unit` make `vh/vw` behave like \"container viewport\" inside `<lynx-view>`.\n// - `--rpx-unit` aligns `rpx` scaling with a 750-wide design baseline (mobile-like behavior).\n// Note: web-core already applies `contain: content` internally; combined with `containerType: 'size'`\n// this effectively behaves like `contain: strict` without us overriding containment explicitly.\nexport const LYNX_VIEW_STYLE: CSSProperties & CSSVarProperties = {\n width: '100%',\n height: '100%',\n pointerEvents: 'auto',\n containerType: 'size',\n '--rpx-unit': 'calc(100cqw / 750)',\n '--vh-unit': '1cqh',\n '--vw-unit': '1cqw',\n}\n\nexport const LYNX_VIEW_STYLE_INTERACTIVE: CSSProperties & CSSVarProperties = {\n ...LYNX_VIEW_STYLE,\n pointerEvents: 'auto',\n}\n\nexport const LYNX_VIEW_STYLE_NON_INTERACTIVE: CSSProperties & CSSVarProperties =\n {\n ...LYNX_VIEW_STYLE,\n pointerEvents: 'none',\n }\n\nexport const CONTAINER_STYLE: CSSProperties = {\n position: 'relative',\n width: '100%',\n height: '100%',\n}\n\nexport const DEFAULT_GROUP_ID = 7\n"],"names":["LYNX_VIEW_STYLE","LYNX_VIEW_STYLE_INTERACTIVE","LYNX_VIEW_STYLE_NON_INTERACTIVE","CONTAINER_STYLE","DEFAULT_GROUP_ID"],"mappings":"AAcO,MAAMA,kBAAoD;IAC/D,OAAO;IACP,QAAQ;IACR,eAAe;IACf,eAAe;IACf,cAAc;IACd,aAAa;IACb,aAAa;AACf;AAEO,MAAMC,8BAAgE;IAC3E,GAAGD,eAAe;IAClB,eAAe;AACjB;AAEO,MAAME,kCACX;IACE,GAAGF,eAAe;IAClB,eAAe;AACjB;AAEK,MAAMG,kBAAiC;IAC5C,UAAU;IACV,OAAO;IACP,QAAQ;AACV;AAEO,MAAMC,mBAAmB"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { UseLynxStageOptions } from './types';
|
|
3
|
+
import '../types/lynx-view';
|
|
4
|
+
export type LynxStageProps = Omit<UseLynxStageOptions, 'bundleRoot'> & {
|
|
5
|
+
/**
|
|
6
|
+
* Resource root used together with `entry` to locate the Lynx bundle.
|
|
7
|
+
* The default resolver normalizes a trailing slash and builds
|
|
8
|
+
* `${bundleRoot}${entry}.web.bundle`.
|
|
9
|
+
* @defaultValue '/'
|
|
10
|
+
*/
|
|
11
|
+
bundleRoot?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Shared Lynx worker group ID. Defaults to 7.
|
|
14
|
+
* Override to isolate workers between unrelated view groups.
|
|
15
|
+
* @defaultValue 7
|
|
16
|
+
*/
|
|
17
|
+
groupId?: number;
|
|
18
|
+
/**
|
|
19
|
+
* Enables pointer interactions on the underlying `<lynx-view>` host element.
|
|
20
|
+
* @defaultValue true
|
|
21
|
+
*/
|
|
22
|
+
interactive?: boolean;
|
|
23
|
+
};
|
|
24
|
+
export declare function LynxStage(props: LynxStageProps): ReactNode;
|
|
25
|
+
//# sourceMappingURL=lynx-stage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lynx-stage.d.ts","sourceRoot":"","sources":["../../src/lynx/lynx-stage.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAQtC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAGlD,OAAO,oBAAoB,CAAA;AAE3B,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,mBAAmB,EAAE,YAAY,CAAC,GAAG;IACrE;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB,CAAA;AAgCD,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,GAAG,SAAS,CAQ1D"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { CONTAINER_STYLE, DEFAULT_GROUP_ID, LYNX_VIEW_STYLE_INTERACTIVE, LYNX_VIEW_STYLE_NON_INTERACTIVE } from "./lynx-stage-constants.js";
|
|
3
|
+
import { useLynxStage } from "./use-lynx-stage.js";
|
|
4
|
+
import { useIsClient } from "../hooks/index.js";
|
|
5
|
+
import "../types/lynx-view.js";
|
|
6
|
+
function LynxStageImpl({ bundleRoot, groupId = DEFAULT_GROUP_ID, interactive = true, ...stageOptions }) {
|
|
7
|
+
const { lynxViewRef, containerRef, src, ready } = useLynxStage({
|
|
8
|
+
bundleRoot: bundleRoot ?? '/',
|
|
9
|
+
...stageOptions
|
|
10
|
+
});
|
|
11
|
+
return /*#__PURE__*/ jsx("div", {
|
|
12
|
+
ref: containerRef,
|
|
13
|
+
style: CONTAINER_STYLE,
|
|
14
|
+
children: ready && /*#__PURE__*/ jsx("lynx-view", {
|
|
15
|
+
ref: lynxViewRef,
|
|
16
|
+
url: src,
|
|
17
|
+
style: interactive ? LYNX_VIEW_STYLE_INTERACTIVE : LYNX_VIEW_STYLE_NON_INTERACTIVE,
|
|
18
|
+
"lynx-group-id": groupId,
|
|
19
|
+
"transform-vh": true,
|
|
20
|
+
"transform-vw": true
|
|
21
|
+
}, src)
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
function LynxStage(props) {
|
|
25
|
+
const isClient = useIsClient();
|
|
26
|
+
if (!isClient) return null;
|
|
27
|
+
return /*#__PURE__*/ jsx(LynxStageImpl, {
|
|
28
|
+
...props
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
export { LynxStage };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=lynx-stage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lynx/lynx-stage.js","sources":["../../src/lynx/lynx-stage.tsx"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport type { ReactNode } from 'react'\n\nimport {\n CONTAINER_STYLE,\n DEFAULT_GROUP_ID,\n LYNX_VIEW_STYLE_INTERACTIVE,\n LYNX_VIEW_STYLE_NON_INTERACTIVE,\n} from './lynx-stage-constants'\nimport type { UseLynxStageOptions } from './types'\nimport { useLynxStage } from './use-lynx-stage'\nimport { useIsClient } from '../hooks'\nimport '../types/lynx-view'\n\nexport type LynxStageProps = Omit<UseLynxStageOptions, 'bundleRoot'> & {\n /**\n * Resource root used together with `entry` to locate the Lynx bundle.\n * The default resolver normalizes a trailing slash and builds\n * `${bundleRoot}${entry}.web.bundle`.\n * @defaultValue '/'\n */\n bundleRoot?: string\n /**\n * Shared Lynx worker group ID. Defaults to 7.\n * Override to isolate workers between unrelated view groups.\n * @defaultValue 7\n */\n groupId?: number\n /**\n * Enables pointer interactions on the underlying `<lynx-view>` host element.\n * @defaultValue true\n */\n interactive?: boolean\n}\n\nfunction LynxStageImpl({\n bundleRoot,\n groupId = DEFAULT_GROUP_ID,\n interactive = true,\n ...stageOptions\n}: LynxStageProps): ReactNode {\n const { lynxViewRef, containerRef, src, ready } = useLynxStage({\n bundleRoot: bundleRoot ?? '/',\n ...stageOptions,\n })\n\n return (\n <div ref={containerRef} style={CONTAINER_STYLE}>\n {ready && (\n <lynx-view\n key={src}\n ref={lynxViewRef}\n url={src}\n style={interactive\n ? LYNX_VIEW_STYLE_INTERACTIVE\n : LYNX_VIEW_STYLE_NON_INTERACTIVE}\n lynx-group-id={groupId}\n transform-vh={true}\n transform-vw={true}\n />\n )}\n </div>\n )\n}\n\nexport function LynxStage(props: LynxStageProps): ReactNode {\n const isClient = useIsClient()\n\n if (!isClient) {\n return null\n }\n\n return <LynxStageImpl {...props} />\n}\n"],"names":["LynxStageImpl","bundleRoot","groupId","DEFAULT_GROUP_ID","interactive","stageOptions","lynxViewRef","containerRef","src","ready","useLynxStage","CONTAINER_STYLE","LYNX_VIEW_STYLE_INTERACTIVE","LYNX_VIEW_STYLE_NON_INTERACTIVE","LynxStage","props","isClient","useIsClient"],"mappings":";;;;;AAsCA,SAASA,cAAc,EACrBC,UAAU,EACVC,UAAUC,gBAAgB,EAC1BC,cAAc,IAAI,EAClB,GAAGC,cACY;IACf,MAAM,EAAEC,WAAW,EAAEC,YAAY,EAAEC,GAAG,EAAEC,KAAK,EAAE,GAAGC,aAAa;QAC7D,YAAYT,cAAc;QAC1B,GAAGI,YAAY;IACjB;IAEA,OAAO,WAAP,GACE,IAAC;QAAI,KAAKE;QAAc,OAAOI;kBAC5BF,SAAS,WAATA,GACC,IAAC;YAEC,KAAKH;YACL,KAAKE;YACL,OAAOJ,cACHQ,8BACAC;YACJ,iBAAeX;YACf,gBAAc;YACd,gBAAc;WARTM;;AAaf;AAEO,SAASM,UAAUC,KAAqB;IAC7C,MAAMC,WAAWC;IAEjB,IAAI,CAACD,UACH,OAAO;IAGT,OAAO,WAAP,GAAO,IAAChB,eAAaA;QAAE,GAAGe,KAAK;;AACjC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { LynxViewElement as LynxView } from '@lynx-js/web-core/client';
|
|
2
|
+
import type { RefObject } from 'react';
|
|
3
|
+
type GlobalProps = Record<string, unknown>;
|
|
4
|
+
export type ResolveBundleSrc = (params: {
|
|
5
|
+
/** Normalized resource root, guaranteed to end with a trailing slash. */
|
|
6
|
+
bundleRoot: string;
|
|
7
|
+
/** Bundle entry name provided by the host. */
|
|
8
|
+
entry: string;
|
|
9
|
+
}) => string;
|
|
10
|
+
export interface UseLynxStageOptions {
|
|
11
|
+
/**
|
|
12
|
+
* Resource root used together with `entry` to locate the Lynx bundle.
|
|
13
|
+
* The default resolver normalizes a trailing slash and builds
|
|
14
|
+
* `${bundleRoot}${entry}.web.bundle`.
|
|
15
|
+
*/
|
|
16
|
+
bundleRoot: string;
|
|
17
|
+
/**
|
|
18
|
+
* Entry name for the Lynx bundle.
|
|
19
|
+
*/
|
|
20
|
+
entry: string;
|
|
21
|
+
/**
|
|
22
|
+
* Optional hook for overriding how the final bundle URL is resolved from
|
|
23
|
+
* `bundleRoot` and `entry`.
|
|
24
|
+
*
|
|
25
|
+
* This callback is used to compute the resolved bundle URL during render.
|
|
26
|
+
* If it changes identity and returns a different URL, the hook treats that as
|
|
27
|
+
* a bundle change because `src` changed. The resolver always receives a
|
|
28
|
+
* normalized `bundleRoot` ending with `/`.
|
|
29
|
+
*/
|
|
30
|
+
resolveBundleSrc?: ResolveBundleSrc;
|
|
31
|
+
/**
|
|
32
|
+
* Global props to inject into the Lynx runtime via `updateGlobalProps`.
|
|
33
|
+
* Re-injected whenever the object reference changes.
|
|
34
|
+
*/
|
|
35
|
+
globalProps?: GlobalProps;
|
|
36
|
+
/**
|
|
37
|
+
* Called when the Lynx runtime calls a native module.
|
|
38
|
+
* Return a value to send back to the runtime.
|
|
39
|
+
*
|
|
40
|
+
* Treated as non-reactive: the latest handler is used without re-running
|
|
41
|
+
* effects when the function identity changes.
|
|
42
|
+
*/
|
|
43
|
+
onNativeModulesCall?: (name: string, data: unknown, moduleName: string) => unknown;
|
|
44
|
+
/**
|
|
45
|
+
* Called once when the view has rendered successfully.
|
|
46
|
+
*
|
|
47
|
+
* Treated as non-reactive: the latest handler is used without re-running
|
|
48
|
+
* effects when the function identity changes.
|
|
49
|
+
*/
|
|
50
|
+
onReady?: () => void;
|
|
51
|
+
/**
|
|
52
|
+
* Called when an error occurs during runtime load, template fetch, or rendering.
|
|
53
|
+
*
|
|
54
|
+
* Treated as non-reactive: the latest handler is used without re-running
|
|
55
|
+
* effects when the function identity changes.
|
|
56
|
+
*/
|
|
57
|
+
onError?: (error: string) => void;
|
|
58
|
+
}
|
|
59
|
+
export interface UseLynxStageResult {
|
|
60
|
+
/** Attach to the `<lynx-view>` element. */
|
|
61
|
+
lynxViewRef: RefObject<LynxView>;
|
|
62
|
+
/** Attach to the container `<div>` wrapping `<lynx-view>`. */
|
|
63
|
+
containerRef: RefObject<HTMLDivElement>;
|
|
64
|
+
/**
|
|
65
|
+
* Resolved bundle URL for the current `entry`/`bundleRoot`.
|
|
66
|
+
* Pass this value to `<lynx-view url={src} />` so the URL is available
|
|
67
|
+
* at element creation time (avoids ref/effect timing races).
|
|
68
|
+
*/
|
|
69
|
+
src: string;
|
|
70
|
+
/**
|
|
71
|
+
* Whether the Lynx runtime (`@lynx-js/web-core/client`) has finished loading.
|
|
72
|
+
* When `false`, delay mounting `<lynx-view>` to avoid upgrade/handshake races.
|
|
73
|
+
*/
|
|
74
|
+
ready: boolean;
|
|
75
|
+
}
|
|
76
|
+
export {};
|
|
77
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lynx/types.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,IAAI,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AAC3E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,KAAK,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAE1C,MAAM,MAAM,gBAAgB,GAAG,CAAC,MAAM,EAAE;IACtC,yEAAyE;IACzE,UAAU,EAAE,MAAM,CAAA;IAClB,8CAA8C;IAC9C,KAAK,EAAE,MAAM,CAAA;CACd,KAAK,MAAM,CAAA;AAEZ,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,UAAU,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;IACb;;;;;;;;OAQG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;IACnC;;;OAGG;IACH,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB;;;;;;OAMG;IACH,mBAAmB,CAAC,EAAE,CACpB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,OAAO,EACb,UAAU,EAAE,MAAM,KACf,OAAO,CAAA;IACZ;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IACpB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;CAClC;AAED,MAAM,WAAW,kBAAkB;IACjC,2CAA2C;IAC3C,WAAW,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAA;IAChC,8DAA8D;IAC9D,YAAY,EAAE,SAAS,CAAC,cAAc,CAAC,CAAA;IACvC;;;;OAIG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;;OAGG;IACH,KAAK,EAAE,OAAO,CAAA;CACf"}
|
|
File without changes
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { UseLynxStageOptions, UseLynxStageResult } from './types';
|
|
2
|
+
import '../types/lynx-view';
|
|
3
|
+
export type { ResolveBundleSrc, UseLynxStageOptions, UseLynxStageResult, } from './types';
|
|
4
|
+
export declare function useLynxStage({ bundleRoot, entry, globalProps, resolveBundleSrc, onNativeModulesCall, onReady, onError, }: UseLynxStageOptions): UseLynxStageResult;
|
|
5
|
+
//# sourceMappingURL=use-lynx-stage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-lynx-stage.d.ts","sourceRoot":"","sources":["../../src/lynx/use-lynx-stage.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAEtE,OAAO,oBAAoB,CAAA;AAE3B,YAAY,EACV,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,SAAS,CAAA;AAgEhB,wBAAgB,YAAY,CAAC,EAC3B,UAAU,EACV,KAAK,EACL,WAAW,EACX,gBAAgB,EAChB,mBAAmB,EACnB,OAAO,EACP,OAAO,GACR,EAAE,mBAAmB,GAAG,kBAAkB,CAkI1C"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from "react";
|
|
2
|
+
import { useEventCallback } from "../hooks/use-event-callback.js";
|
|
3
|
+
import "../types/lynx-view.js";
|
|
4
|
+
function normalizeBundleRoot(bundleRoot) {
|
|
5
|
+
return bundleRoot.endsWith('/') ? bundleRoot : `${bundleRoot}/`;
|
|
6
|
+
}
|
|
7
|
+
"u" < typeof performance || performance.now();
|
|
8
|
+
function debugLog(tag) {}
|
|
9
|
+
let runtimeReady = null;
|
|
10
|
+
function ensureRuntime() {
|
|
11
|
+
return runtimeReady ??= (()=>{
|
|
12
|
+
debugLog('runtime:import:start');
|
|
13
|
+
return import("@lynx-js/web-core/client").then(async ()=>{
|
|
14
|
+
debugLog('runtime:import:done');
|
|
15
|
+
if ("u" < typeof customElements) return;
|
|
16
|
+
if (!customElements.get('lynx-view')) await customElements.whenDefined('lynx-view');
|
|
17
|
+
debugLog('runtime:custom-element-defined', customElements.get('lynx-view'));
|
|
18
|
+
}).catch((error)=>{
|
|
19
|
+
debugLog('runtime:import:error');
|
|
20
|
+
runtimeReady = null;
|
|
21
|
+
throw error;
|
|
22
|
+
});
|
|
23
|
+
})();
|
|
24
|
+
}
|
|
25
|
+
function useLynxStage({ bundleRoot, entry, globalProps, resolveBundleSrc, onNativeModulesCall, onReady, onError }) {
|
|
26
|
+
const lynxViewRef = useRef(null);
|
|
27
|
+
const containerRef = useRef(null);
|
|
28
|
+
const [ready, setReady] = useState(false);
|
|
29
|
+
const renderedRef = useRef(false);
|
|
30
|
+
const reportReadyEvent = useEventCallback(onReady);
|
|
31
|
+
const reportErrorEvent = useEventCallback(onError);
|
|
32
|
+
const onNativeModulesCallEvent = useEventCallback(onNativeModulesCall);
|
|
33
|
+
const normalizedBundleRoot = normalizeBundleRoot(bundleRoot);
|
|
34
|
+
const src = resolveBundleSrc?.({
|
|
35
|
+
bundleRoot: normalizedBundleRoot,
|
|
36
|
+
entry
|
|
37
|
+
}) ?? `${normalizedBundleRoot}${entry}.web.bundle`;
|
|
38
|
+
useEffect(()=>{
|
|
39
|
+
debugLog(`reset(${entry})`);
|
|
40
|
+
renderedRef.current = false;
|
|
41
|
+
}, [
|
|
42
|
+
src,
|
|
43
|
+
entry
|
|
44
|
+
]);
|
|
45
|
+
useEffect(()=>{
|
|
46
|
+
debugLog(`runtime-effect(${entry}):start`);
|
|
47
|
+
ensureRuntime().then(()=>{
|
|
48
|
+
debugLog(`runtime-effect(${entry}):resolved → setReady(true)`);
|
|
49
|
+
setReady(true);
|
|
50
|
+
}).catch((err)=>{
|
|
51
|
+
debugLog(`runtime-effect(${entry}):rejected`);
|
|
52
|
+
reportErrorEvent(`Failed to load Lynx runtime: ${err instanceof Error ? err.message : String(err)}`);
|
|
53
|
+
});
|
|
54
|
+
}, [
|
|
55
|
+
reportErrorEvent,
|
|
56
|
+
entry
|
|
57
|
+
]);
|
|
58
|
+
useEffect(()=>{
|
|
59
|
+
if (!ready) return;
|
|
60
|
+
const view = lynxViewRef.current;
|
|
61
|
+
if (!view) return void debugLog(`nativeModules(${entry}): no view yet`);
|
|
62
|
+
debugLog(`nativeModules(${entry}): wiring`);
|
|
63
|
+
view.onNativeModulesCall = (name, data, moduleName)=>onNativeModulesCallEvent(name, data, moduleName);
|
|
64
|
+
}, [
|
|
65
|
+
ready,
|
|
66
|
+
src,
|
|
67
|
+
onNativeModulesCallEvent,
|
|
68
|
+
entry
|
|
69
|
+
]);
|
|
70
|
+
useEffect(()=>{
|
|
71
|
+
if (!ready || !globalProps || !lynxViewRef.current) return;
|
|
72
|
+
debugLog(`globalProps(${entry}): updating`);
|
|
73
|
+
lynxViewRef.current.updateGlobalProps(globalProps);
|
|
74
|
+
}, [
|
|
75
|
+
ready,
|
|
76
|
+
src,
|
|
77
|
+
globalProps,
|
|
78
|
+
entry
|
|
79
|
+
]);
|
|
80
|
+
useEffect(()=>{
|
|
81
|
+
const lynxView = lynxViewRef.current;
|
|
82
|
+
if (!ready || !lynxView || renderedRef.current) return;
|
|
83
|
+
debugLog(`rendered(${entry})`);
|
|
84
|
+
let errored = false;
|
|
85
|
+
const onError = (event)=>{
|
|
86
|
+
if (errored) return;
|
|
87
|
+
errored = true;
|
|
88
|
+
if (!('detail' in event)) return void reportErrorEvent('Unknown Lynx error');
|
|
89
|
+
const detail = event.detail;
|
|
90
|
+
const err = detail?.error;
|
|
91
|
+
const message = err?.message ?? 'Unknown Lynx error';
|
|
92
|
+
const fileName = detail?.fileName;
|
|
93
|
+
const release = detail?.release;
|
|
94
|
+
const line = detail?.sourceMap?.offset?.line;
|
|
95
|
+
const col = detail?.sourceMap?.offset?.col;
|
|
96
|
+
const location = null != line || null != col ? `${line ?? '?'}:${col ?? '?'}` : void 0;
|
|
97
|
+
const context = [
|
|
98
|
+
fileName,
|
|
99
|
+
location,
|
|
100
|
+
release
|
|
101
|
+
].filter(Boolean).join(' ');
|
|
102
|
+
reportErrorEvent(context ? `${message} (${context})` : message);
|
|
103
|
+
};
|
|
104
|
+
lynxView.addEventListener('error', onError);
|
|
105
|
+
const t = setTimeout(()=>{
|
|
106
|
+
if (renderedRef.current || errored) return;
|
|
107
|
+
renderedRef.current = true;
|
|
108
|
+
reportReadyEvent();
|
|
109
|
+
}, 0);
|
|
110
|
+
return ()=>{
|
|
111
|
+
clearTimeout(t);
|
|
112
|
+
lynxView.removeEventListener('error', onError);
|
|
113
|
+
};
|
|
114
|
+
}, [
|
|
115
|
+
ready,
|
|
116
|
+
entry,
|
|
117
|
+
src,
|
|
118
|
+
reportReadyEvent,
|
|
119
|
+
reportErrorEvent
|
|
120
|
+
]);
|
|
121
|
+
return {
|
|
122
|
+
lynxViewRef,
|
|
123
|
+
containerRef,
|
|
124
|
+
src,
|
|
125
|
+
ready
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
export { useLynxStage };
|
|
129
|
+
|
|
130
|
+
//# sourceMappingURL=use-lynx-stage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lynx/use-lynx-stage.js","sources":["../../src/lynx/use-lynx-stage.ts"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport type { LynxViewElement as LynxView } from '@lynx-js/web-core/client'\nimport { useEffect, useRef, useState } from 'react'\n\nimport type { UseLynxStageOptions, UseLynxStageResult } from './types'\nimport { useEventCallback } from '../hooks/use-event-callback'\nimport '../types/lynx-view'\n\nexport type {\n ResolveBundleSrc,\n UseLynxStageOptions,\n UseLynxStageResult,\n} from './types'\n\ntype LynxViewWithExtensions = LynxView & {\n onNativeModulesCall?: (\n name: string,\n data: unknown,\n moduleName: string,\n ) => unknown\n}\n\ntype UpdateGlobalPropsArg = Parameters<LynxView['updateGlobalProps']>[0]\n\ninterface LynxErrorDetail {\n error?: Error\n sourceMap?: { offset?: { line?: number, col?: number } }\n release?: string\n fileName?: 'lepus.js' | 'app-service.js'\n}\n\nfunction normalizeBundleRoot(bundleRoot: string): string {\n return bundleRoot.endsWith('/')\n ? bundleRoot\n : `${bundleRoot}/`\n}\n\n// ─── Debug logger ─────────────────────────────────────────────────────────────\n\nconst DEBUG = false\nconst t0 = typeof performance === 'undefined' ? 0 : performance.now()\nfunction debugLog(tag: string, ...args: unknown[]): void {\n if (!DEBUG) return\n const elapsed = (performance.now() - t0).toFixed(0).padStart(6)\n console.info(`[lynx +${elapsed}ms] ${tag}`, ...args)\n}\n\n// ─── Runtime singleton ────────────────────────────────────────────────────────\n\nlet runtimeReady: Promise<void> | null = null\n\nfunction ensureRuntime(): Promise<void> {\n return (runtimeReady ??= (() => {\n debugLog('runtime:import:start')\n return import('@lynx-js/web-core/client')\n .then(async () => {\n debugLog('runtime:import:done')\n if (typeof customElements === 'undefined') {\n return\n }\n if (!customElements.get('lynx-view')) {\n await customElements.whenDefined('lynx-view')\n }\n debugLog(\n 'runtime:custom-element-defined',\n !!customElements.get('lynx-view'),\n )\n })\n .catch((error) => {\n debugLog('runtime:import:error', error)\n runtimeReady = null\n throw error\n })\n })())\n}\n\nexport function useLynxStage({\n bundleRoot,\n entry,\n globalProps,\n resolveBundleSrc,\n onNativeModulesCall,\n onReady,\n onError,\n}: UseLynxStageOptions): UseLynxStageResult {\n const lynxViewRef = useRef<LynxView>(null)\n const containerRef = useRef<HTMLDivElement | null>(null)\n\n const [ready, setReady] = useState(false)\n\n const renderedRef = useRef(false)\n\n // Stable refs for callbacks — avoids re-running effects on every render\n const reportReadyEvent = useEventCallback(onReady)\n const reportErrorEvent = useEventCallback(onError)\n const onNativeModulesCallEvent = useEventCallback(onNativeModulesCall)\n\n const normalizedBundleRoot = normalizeBundleRoot(bundleRoot)\n const src = resolveBundleSrc?.({\n bundleRoot: normalizedBundleRoot,\n entry,\n }) ?? `${normalizedBundleRoot}${entry}.web.bundle`\n\n // Reset when the resolved bundle URL changes.\n useEffect(() => {\n debugLog(`reset(${entry})`, src)\n renderedRef.current = false\n }, [src, entry])\n\n // Load web-core eagerly on mount\n useEffect(() => {\n debugLog(`runtime-effect(${entry}):start`)\n ensureRuntime()\n .then(() => {\n debugLog(`runtime-effect(${entry}):resolved → setReady(true)`)\n setReady(true)\n })\n .catch((err: unknown) => {\n debugLog(`runtime-effect(${entry}):rejected`, err)\n reportErrorEvent(\n `Failed to load Lynx runtime: ${\n err instanceof Error ? err.message : String(err)\n }`,\n )\n })\n }, [reportErrorEvent, entry])\n\n // Wire up onNativeModulesCall after runtime is ready\n useEffect(() => {\n if (!ready) return\n const view = lynxViewRef.current as LynxViewWithExtensions | null\n if (!view) {\n debugLog(`nativeModules(${entry}): no view yet`, src)\n return\n }\n debugLog(`nativeModules(${entry}): wiring`, src)\n view.onNativeModulesCall = (name, data, moduleName) =>\n onNativeModulesCallEvent(name, data, moduleName)\n }, [ready, src, onNativeModulesCallEvent, entry])\n\n // Inject globalProps whenever they change\n useEffect(() => {\n if (!ready || !globalProps || !lynxViewRef.current) return\n debugLog(`globalProps(${entry}): updating`, src)\n lynxViewRef.current.updateGlobalProps(\n globalProps as unknown as UpdateGlobalPropsArg,\n )\n }, [ready, src, globalProps, entry])\n\n useEffect(() => {\n const lynxView = lynxViewRef.current as LynxViewWithExtensions | null\n if (!ready || !lynxView || renderedRef.current) return\n debugLog(`rendered(${entry})`, src)\n\n let errored = false\n const onError = (event: Event) => {\n if (errored) return\n errored = true\n if (!('detail' in event)) {\n reportErrorEvent('Unknown Lynx error')\n return\n }\n\n const detail = event.detail as LynxErrorDetail | undefined\n\n const err = detail?.error\n const message = err?.message ?? 'Unknown Lynx error'\n\n const fileName = detail?.fileName\n const release = detail?.release\n const line = detail?.sourceMap?.offset?.line\n const col = detail?.sourceMap?.offset?.col\n\n const location = (line != null || col != null)\n ? `${line ?? '?'}:${col ?? '?'}`\n : undefined\n\n const context = [\n fileName,\n location,\n release,\n ].filter(Boolean).join(' ')\n\n reportErrorEvent(context ? `${message} (${context})` : message)\n }\n ;(lynxView as unknown as HTMLElement).addEventListener('error', onError)\n\n const t = setTimeout(() => {\n if (renderedRef.current || errored) return\n renderedRef.current = true\n reportReadyEvent()\n }, 0)\n\n return () => {\n clearTimeout(t)\n ;(lynxView as unknown as HTMLElement).removeEventListener(\n 'error',\n onError,\n )\n }\n }, [\n ready,\n entry,\n src,\n reportReadyEvent,\n reportErrorEvent,\n ])\n\n return {\n lynxViewRef,\n containerRef,\n src,\n ready,\n }\n}\n"],"names":["normalizeBundleRoot","bundleRoot","performance","debugLog","tag","runtimeReady","ensureRuntime","customElements","error","useLynxStage","entry","globalProps","resolveBundleSrc","onNativeModulesCall","onReady","onError","lynxViewRef","useRef","containerRef","ready","setReady","useState","renderedRef","reportReadyEvent","useEventCallback","reportErrorEvent","onNativeModulesCallEvent","normalizedBundleRoot","src","useEffect","err","Error","String","view","name","data","moduleName","lynxView","errored","event","detail","message","fileName","release","line","col","location","undefined","context","Boolean","t","setTimeout","clearTimeout"],"mappings":"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"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { VisualSizeContext } from './visual-size-context';
|
|
2
|
+
export { VisualSizeProvider } from './visual-size-provider';
|
|
3
|
+
export { useVisualSize } from './use-visual-size';
|
|
4
|
+
export type { VisualSizeValue } from './visual-size-context';
|
|
5
|
+
export type { VisualSizeProviderProps } from './visual-size-provider';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/motion/context/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAC5D,YAAY,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { VisualSizeValue } from './visual-size-context';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the visual size provided by a parent VisualSizeProvider,
|
|
4
|
+
* or `null` if none is present (graceful fallback — no throw).
|
|
5
|
+
* Callers should fall back to a default size when this returns null.
|
|
6
|
+
*/
|
|
7
|
+
export declare function useVisualSize(): VisualSizeValue | null;
|
|
8
|
+
//# sourceMappingURL=use-visual-size.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-visual-size.d.ts","sourceRoot":"","sources":["../../../src/motion/context/use-visual-size.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAE5D;;;;GAIG;AACH,wBAAgB,aAAa,IAAI,eAAe,GAAG,IAAI,CAEtD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"motion/context/use-visual-size.js","sources":["../../../src/motion/context/use-visual-size.ts"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { useContext } from 'react'\n\nimport { VisualSizeContext } from './visual-size-context'\nimport type { VisualSizeValue } from './visual-size-context'\n\n/**\n * Returns the visual size provided by a parent VisualSizeProvider,\n * or `null` if none is present (graceful fallback — no throw).\n * Callers should fall back to a default size when this returns null.\n */\nexport function useVisualSize(): VisualSizeValue | null {\n return useContext(VisualSizeContext)\n}\n"],"names":["useVisualSize","useContext","VisualSizeContext"],"mappings":";;AAcO,SAASA;IACd,OAAOC,WAAWC;AACpB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { MotionValue } from 'motion/react';
|
|
2
|
+
import type { Context } from 'react';
|
|
3
|
+
interface VisualSizeValue {
|
|
4
|
+
visualW: MotionValue<number>;
|
|
5
|
+
visualH: MotionValue<number>;
|
|
6
|
+
}
|
|
7
|
+
declare const VisualSizeContext: Context<VisualSizeValue | null>;
|
|
8
|
+
export { VisualSizeContext };
|
|
9
|
+
export type { VisualSizeValue };
|
|
10
|
+
//# sourceMappingURL=visual-size-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visual-size-context.d.ts","sourceRoot":"","sources":["../../../src/motion/context/visual-size-context.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAE/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAEpC,UAAU,eAAe;IACvB,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;IAC5B,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;CAC7B;AAED,QAAA,MAAM,iBAAiB,EAAE,OAAO,CAAC,eAAe,GAAG,IAAI,CAEhD,CAAA;AAEP,OAAO,EAAE,iBAAiB,EAAE,CAAA;AAC5B,YAAY,EAAE,eAAe,EAAE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"motion/context/visual-size-context.js","sources":["../../../src/motion/context/visual-size-context.tsx"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport type { MotionValue } from 'motion/react'\nimport { createContext } from 'react'\nimport type { Context } from 'react'\n\ninterface VisualSizeValue {\n visualW: MotionValue<number>\n visualH: MotionValue<number>\n}\n\nconst VisualSizeContext: Context<VisualSizeValue | null> = createContext<\n VisualSizeValue | null\n>(null)\n\nexport { VisualSizeContext }\nexport type { VisualSizeValue }\n"],"names":["VisualSizeContext","createContext"],"mappings":";AAaA,MAAMA,oBAAiBA,WAAAA,GAAoCC,cAEzD"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { JSX } from 'react/jsx-runtime';
|
|
3
|
+
import type { VisualSizeValue } from './visual-size-context';
|
|
4
|
+
type VisualSizeProviderProps = VisualSizeValue & {
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
};
|
|
7
|
+
export type { VisualSizeProviderProps };
|
|
8
|
+
export declare function VisualSizeProvider({ visualW, visualH, children, }: VisualSizeProviderProps): JSX.Element;
|
|
9
|
+
//# sourceMappingURL=visual-size-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visual-size-provider.d.ts","sourceRoot":"","sources":["../../../src/motion/context/visual-size-provider.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAA;AAG5C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAE5D,KAAK,uBAAuB,GAAG,eAAe,GAAG;IAC/C,QAAQ,CAAC,EAAE,SAAS,CAAA;CACrB,CAAA;AACD,YAAY,EAAE,uBAAuB,EAAE,CAAA;AACvC,wBAAgB,kBAAkB,CAAC,EACjC,OAAO,EACP,OAAO,EACP,QAAQ,GACT,EAAE,uBAAuB,GAAG,GAAG,CAAC,OAAO,CAUvC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import { VisualSizeContext } from "./visual-size-context.js";
|
|
4
|
+
function VisualSizeProvider({ visualW, visualH, children }) {
|
|
5
|
+
const value = useMemo(()=>({
|
|
6
|
+
visualW,
|
|
7
|
+
visualH
|
|
8
|
+
}), [
|
|
9
|
+
visualW,
|
|
10
|
+
visualH
|
|
11
|
+
]);
|
|
12
|
+
return /*#__PURE__*/ jsx(VisualSizeContext.Provider, {
|
|
13
|
+
value: value,
|
|
14
|
+
children: children
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
export { VisualSizeProvider };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=visual-size-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"motion/context/visual-size-provider.js","sources":["../../../src/motion/context/visual-size-provider.tsx"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { useMemo } from 'react'\nimport type { ReactNode } from 'react'\nimport type { JSX } from 'react/jsx-runtime'\n\nimport { VisualSizeContext } from './visual-size-context'\nimport type { VisualSizeValue } from './visual-size-context'\n\ntype VisualSizeProviderProps = VisualSizeValue & {\n children?: ReactNode\n}\nexport type { VisualSizeProviderProps }\nexport function VisualSizeProvider({\n visualW,\n visualH,\n children,\n}: VisualSizeProviderProps): JSX.Element {\n const value: VisualSizeValue = useMemo(\n () => ({ visualW, visualH }),\n [visualW, visualH],\n )\n return (\n <VisualSizeContext.Provider value={value}>\n {children}\n </VisualSizeContext.Provider>\n )\n}\n"],"names":["VisualSizeProvider","visualW","visualH","children","value","useMemo","VisualSizeContext"],"mappings":";;;AAeO,SAASA,mBAAmB,EACjCC,OAAO,EACPC,OAAO,EACPC,QAAQ,EACgB;IACxB,MAAMC,QAAyBC,QAC7B,IAAO;YAAEJ;YAASC;QAAQ,IAC1B;QAACD;QAASC;KAAQ;IAEpB,OAAO,WAAP,GACE,IAACI,kBAAkB,QAAQ;QAAC,OAAOF;kBAChCD;;AAGP"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { VisualSizeProvider, useVisualSize } from './context';
|
|
2
|
+
export type { VisualSizeValue, VisualSizeProviderProps } from './context';
|
|
3
|
+
export { MotionStage, MotionStageContainer, MotionPresentation } from './stage';
|
|
4
|
+
export type { MotionStageProps, MotionPresentationProps, MotionStageContainerProps, } from './stage';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/motion/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAC7D,YAAY,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAA;AACzE,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAC/E,YAAY,EACV,gBAAgB,EAChB,uBAAuB,EACvB,yBAAyB,GAC1B,MAAM,SAAS,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ForwardRefExoticComponent, RefAttributes } from 'react';
|
|
2
|
+
import type { MotionStageContainerProps } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Layout-animation container that neutralizes Motion's scale side effects.
|
|
5
|
+
*
|
|
6
|
+
* Framer Motion uses `transform: scale(...)` for layout animations to avoid
|
|
7
|
+
* reflow. This scales descendants as well, distorting their coordinate space.
|
|
8
|
+
*
|
|
9
|
+
* We use a two-layer structure:
|
|
10
|
+
* - outer: participates in layout animation (may be scaled)
|
|
11
|
+
* - inner: stable anchor for children
|
|
12
|
+
*
|
|
13
|
+
* Instead of applying inverse transforms, we extract the scale and reconstruct
|
|
14
|
+
* the "visual size" (layout × scale), exposing it via context so children render
|
|
15
|
+
* against stable dimensions.
|
|
16
|
+
*
|
|
17
|
+
* Note:
|
|
18
|
+
* This component is typically used inside `AnimatePresence mode="popLayout"`,
|
|
19
|
+
* so it must forward its ref to the underlying DOM node, as `popLayout` needs
|
|
20
|
+
* that DOM node to measure the element's position and then temporarily take
|
|
21
|
+
* the exiting node out of normal layout flow while siblings reflow.
|
|
22
|
+
*/
|
|
23
|
+
declare const MotionStageContainer: ForwardRefExoticComponent<MotionStageContainerProps & RefAttributes<HTMLDivElement>>;
|
|
24
|
+
export { MotionStageContainer };
|
|
25
|
+
//# sourceMappingURL=container-motion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"container-motion.d.ts","sourceRoot":"","sources":["../../../src/motion/stage/container-motion.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,yBAAyB,EAEzB,aAAa,EACd,MAAM,OAAO,CAAA;AAGd,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAA;AAsBxD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,QAAA,MAAM,oBAAoB,EAAE,yBAAyB,CACnD,yBAAyB,GAAG,aAAa,CAAC,cAAc,CAAC,CAG1D,CAAA;AAuJD,OAAO,EAAE,oBAAoB,EAAE,CAAA"}
|