-
Notifications
You must be signed in to change notification settings - Fork 180
remove lazy loading #1018
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
remove lazy loading #1018
Changes from 18 commits
f9746e8
2687031
a453900
44b42e7
fe50017
0c1e85a
1f5097e
65610b5
1a31669
5e4132c
1cb758f
3b755fa
ee75663
0530864
8a64eda
aa1ed33
185822a
da1c094
f3fee6f
b410840
789e98d
1695718
cf72cb7
2ef0748
6180c10
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| name: cache-built-deps | ||
| description: Cache built JS artifacts (common + mobile-sdk-alpha) | ||
| inputs: | ||
| cache-version: | ||
| description: Cache version string for cache key | ||
| required: true | ||
| outputs: | ||
| cache-hit: | ||
| description: Whether cache was hit during restore | ||
| value: ${{ steps.restore.outputs.cache-hit }} | ||
| runs: | ||
| using: composite | ||
| steps: | ||
| - id: restore | ||
| name: Restore Built Dependencies | ||
| uses: actions/cache/restore@v4 | ||
| with: | ||
| path: | | ||
| common/dist | ||
| packages/mobile-sdk-alpha/dist | ||
| key: built-deps-${{ inputs.cache-version }}-${{ hashFiles('common/**/*', 'packages/mobile-sdk-alpha/**/*', '!common/dist/**', '!packages/mobile-sdk-alpha/dist/**') }} | ||
| fail-on-cache-miss: false | ||
| - name: Save Built Dependencies | ||
| if: steps.restore.outputs.cache-hit != 'true' | ||
| uses: actions/cache/save@v4 | ||
| with: | ||
| path: | | ||
| common/dist | ||
| packages/mobile-sdk-alpha/dist | ||
| key: built-deps-${{ inputs.cache-version }}-${{ hashFiles('common/**/*', 'packages/mobile-sdk-alpha/**/*', '!common/dist/**', '!packages/mobile-sdk-alpha/dist/**') }} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| 22 | ||
| 22.12.0 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -157,6 +157,7 @@ | |
| "@testing-library/react-native": "^13.3.3", | ||
| "@tsconfig/react-native": "^3.0.6", | ||
| "@types/add": "^2", | ||
| "@types/dompurify": "^3.2.0", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move dompurify to dependencies (runtime), keep @types in devDeps. The web SvgXml wrapper imports dompurify at runtime. Having it in devDependencies risks missing module errors in production web builds and CI. @types/dompurify can stay in devDependencies. Apply: --- a/app/package.json
+++ b/app/package.json
@@
"dependencies": {
@@
+ "dompurify": "^3.2.6",
@@
},
"devDependencies": {
@@
- "dompurify": "^3.2.6",
@@
}Also applies to: 174-174 🤖 Prompt for AI Agents |
||
| "@types/elliptic": "^6", | ||
| "@types/jest": "^29.5.14", | ||
| "@types/node-forge": "^1.3.14", | ||
|
|
@@ -170,6 +171,7 @@ | |
| "@typescript-eslint/parser": "^8.39.0", | ||
| "@vitejs/plugin-react-swc": "^3.10.2", | ||
| "babel-plugin-module-resolver": "^5.0.2", | ||
| "dompurify": "^3.2.6", | ||
| "eslint": "^8.57.0", | ||
| "eslint-config-prettier": "10.1.8", | ||
| "eslint-import-resolver-typescript": "^3.7.0", | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,18 @@ | ||||||||||||||||||||||||||
| // SPDX-FileCopyrightText: 2025 Social Connect Labs, Inc. | ||||||||||||||||||||||||||
| // SPDX-License-Identifier: BUSL-1.1 | ||||||||||||||||||||||||||
| // NOTE: Converts to Apache-2.0 on 2029-06-11 per LICENSE. | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| import React, { forwardRef } from 'react'; | ||||||||||||||||||||||||||
| import type { StyleProp, ViewStyle } from 'react-native'; | ||||||||||||||||||||||||||
| import { SvgXml as RNSvgXml } from 'react-native-svg'; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
Comment on lines
+5
to
+8
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Fix ref forwarding and remove the The wrapper declares Preferred patch: -import React, { forwardRef } from 'react';
+import React, { forwardRef } from 'react';
+import type { ElementRef } from 'react';
@@
-export const SvgXml = forwardRef<any, Props>((p, _ref) => <RNSvgXml {...p} />);
+export const SvgXml = forwardRef<ElementRef<typeof RNSvgXml>, Props>(
+ (props, ref) => <RNSvgXml ref={ref} {...props} />
+);If -import React, { forwardRef } from 'react';
+import React from 'react';
@@
-export const SvgXml = forwardRef<any, Props>((p, _ref) => <RNSvgXml {...p} />);
+export const SvgXml = (props: Props) => <RNSvgXml {...props} />;To double-check impact, scan for ref usage on this component: #!/bin/bash
# Find call sites that pass a ref to SvgXml wrapper
rg -nP --type=tsx -C2 '<SvgXml[^>]*\bref=' appAlso applies to: 16-18 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||
| type Props = { | ||||||||||||||||||||||||||
| xml: string; | ||||||||||||||||||||||||||
| width?: number; | ||||||||||||||||||||||||||
| height?: number; | ||||||||||||||||||||||||||
| style?: StyleProp<ViewStyle>; | ||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||
|
Comment on lines
+9
to
+14
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Allow string dimensions to prevent layout breakage.
type Props = {
xml: string;
- width?: number;
- height?: number;
+ width?: number | string;
+ height?: number | string;
style?: StyleProp<ViewStyle>;
};📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| export const SvgXml = forwardRef<any, Props>((p, _ref) => <RNSvgXml {...p} />); | ||||||||||||||||||||||||||
| SvgXml.displayName = 'SvgXml'; | ||||||||||||||||||||||||||
| export default SvgXml; | ||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| // SPDX-FileCopyrightText: 2025 Social Connect Labs, Inc. | ||
| // SPDX-License-Identifier: BUSL-1.1 | ||
| // NOTE: Converts to Apache-2.0 on 2029-06-11 per LICENSE. | ||
|
|
||
| // Re-export from the native version - Metro resolver will automatically | ||
| // pick the appropriate platform-specific file (.web.tsx or .native.tsx) | ||
| export { SvgXml } from '@/components/homeScreen/SvgXmlWrapper.native'; | ||
| export { default } from '@/components/homeScreen/SvgXmlWrapper.native'; |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,37 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // SPDX-FileCopyrightText: 2025 Social Connect Labs, Inc. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // SPDX-License-Identifier: BUSL-1.1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // NOTE: Converts to Apache-2.0 on 2029-06-11 per LICENSE. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import DOMPurify from 'dompurify'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import React, { createElement, forwardRef } from 'react'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type Props = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| xml: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| width?: number; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| height?: number; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| style?: React.CSSProperties; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } & React.HTMLAttributes<HTMLDivElement>; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const SvgXml = forwardRef<HTMLDivElement, Props>( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ({ xml, width, height, style, ...props }, ref) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Initialize DOMPurify for web browser environment | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const purify = DOMPurify(window); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const safe = purify.sanitize(xml, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| USE_PROFILES: { svg: true, svgFilters: true }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+15
to
+21
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Guard DOMPurify factory for SSR/test environments and avoid re-instantiation. DOMPurify(window) will throw if window is undefined (SSR, some tests). Add a guard and memoize the instance per mount. Apply: -import DOMPurify from 'dompurify';
-import React, { createElement, forwardRef } from 'react';
+import createDOMPurify from 'dompurify';
+import React, { createElement, forwardRef, useMemo } from 'react';
@@
-export const SvgXml = forwardRef<HTMLDivElement, Props>(
- ({ xml, width, height, style, ...props }, ref) => {
- // Initialize DOMPurify for web browser environment
- const purify = DOMPurify(window);
- const safe = purify.sanitize(xml, {
+export const SvgXml = forwardRef<HTMLDivElement, Props>(
+ ({ xml, width, height, style, ...props }, ref) => {
+ const purify = useMemo(
+ () => (typeof window !== 'undefined' ? createDOMPurify(window) : null),
+ [],
+ );
+ const safe = purify?.sanitize(xml, {
USE_PROFILES: { svg: true, svgFilters: true },
- });
+ }) ?? '';📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return createElement('div', { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ref, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| style: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| width: width || 'auto', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| height: height || 'auto', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| display: 'inline-block', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ...style, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dangerouslySetInnerHTML: { __html: safe }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ...props, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SvgXml.displayName = 'SvgXml'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export default SvgXml; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
NDK cache should use a composite and gate installation on cache-hit.
Direct actions/cache calls violate policy and always running
sdkmanagerwastes minutes. Wrap NDK caching in a composite that exposes cache-hit, then install only on miss.New composite (add file .github/actions/cache-ndk/action.yml):