Skip to content

Commit 02faee1

Browse files
committed
Move everything to a react-strict-svg package
1 parent f06644a commit 02faee1

24 files changed

Lines changed: 489 additions & 29 deletions

package-lock.json

Lines changed: 119 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/react-strict-dom/src/native/index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@ import typeof * as TStyleX from '@stylexjs/stylex';
2020
import * as React from 'react';
2121
import * as compat from './compat';
2222
import * as html from './html';
23-
import * as svg from './svg';
2423
import * as _css from './css';
2524
import { ProvideCustomProperties } from './modules/ContextCustomProperties';
2625
import {
2726
ProvideViewportScale,
2827
useViewportScale
2928
} from './modules/ContextViewportScale';
29+
import { useNativeProps } from './modules/useNativeProps';
30+
import { useStrictDOMElement } from './modules/useStrictDOMElement';
31+
import { isPropAllowed } from '../shared/isPropAllowed';
3032

3133
type StyleTheme<V, T> = Theme<V, T>;
3234
type StyleVars<T> = VarGroup<T>;
@@ -65,6 +67,8 @@ export {
6567
contexts,
6668
css,
6769
html,
68-
svg,
69-
useViewportScale as useViewportScale_DO_NOT_USE
70+
useViewportScale as useViewportScale_DO_NOT_USE,
71+
useNativeProps as useNativeProps_DO_NOT_USE,
72+
useStrictDOMElement as useStrictDOMElement_DO_NOT_USE,
73+
isPropAllowed as isPropAllowed_DO_NOT_USE
7074
};

packages/react-strict-dom/src/types/StrictProps.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import type { StrictReactDOMLabelProps } from './StrictReactDOMLabelProps';
1717
import type { StrictReactDOMListItemProps } from './StrictReactDOMListItemProps';
1818
import type { StrictReactDOMOptionProps } from './StrictReactDOMOptionProps';
1919
import type { StrictReactDOMSelectProps } from './StrictReactDOMSelectProps';
20-
import type { StrictReactDOMSvgProps } from './StrictReactDOMSvgProps';
2120
import type { StrictReactDOMTextAreaProps } from './StrictReactDOMTextAreaProps';
2221

2322
export type StrictProps = Readonly<{
@@ -30,6 +29,5 @@ export type StrictProps = Readonly<{
3029
...StrictReactDOMListItemProps,
3130
...StrictReactDOMOptionProps,
3231
...StrictReactDOMSelectProps,
33-
...StrictReactDOMSvgProps,
3432
...StrictReactDOMTextAreaProps
3533
}>;

packages/react-strict-dom/src/web/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import type {
1616
} from '@stylexjs/stylex';
1717

1818
import * as html from './html';
19-
import * as svg from './svg';
2019
import * as css from '@stylexjs/stylex';
20+
import { isPropAllowed } from '../shared/isPropAllowed';
2121

2222
type StyleTheme<V, T> = Theme<V, T>;
2323
type StyleVars<T> = VarGroup<T>;
@@ -26,4 +26,4 @@ type StylesWithout<T> = StyleXStylesWithout<T>;
2626

2727
export type { StaticStyles, StyleTheme, StyleVars, Styles, StylesWithout };
2828

29-
export { css, html, svg };
29+
export { css, html, isPropAllowed as isPropAllowed_DO_NOT_USE };

packages/react-strict-dom/src/web/runtime.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,6 @@ const sub: StrictReactDOMPropsStyle = styles.inline;
157157
// $FlowFixMe[incompatible-type]
158158
const sup: StrictReactDOMPropsStyle = styles.inline;
159159
// $FlowFixMe[incompatible-type]
160-
const svg: StrictReactDOMPropsStyle = styles.img;
161-
// $FlowFixMe[incompatible-type]
162160
const textarea: StrictReactDOMPropsStyle = [
163161
styles.inlineblock,
164162
styles.textarea
@@ -214,7 +212,6 @@ export const defaultStyles = {
214212
strong: strong as typeof strong,
215213
sub: sub as typeof sub,
216214
sup: sup as typeof sup,
217-
svg: svg as typeof svg,
218215
textarea: textarea as typeof textarea,
219216
u: u as typeof u,
220217
ul: ul as typeof ul

packages/react-strict-svg/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) Meta Platforms, Inc. and affiliates.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
'use strict';
9+
10+
const babelConfig = require('../react-strict-dom/tools/jest/babelConfig.js');
11+
12+
module.exports = {
13+
displayName: 'react-strict-svg (web)',
14+
rootDir: __dirname,
15+
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
16+
testEnvironment: 'jsdom',
17+
testMatch: ['<rootDir>/src/web/**/__tests__/*-test.js'],
18+
moduleNameMapper: {
19+
'^react-strict-dom$': '<rootDir>/../react-strict-dom/src/web/index.js'
20+
},
21+
transform: {
22+
'\\.[jt]sx?$': ['babel-jest', babelConfig()]
23+
}
24+
};
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
'use strict';
9+
10+
if (
11+
typeof HTMLElement !== 'undefined' &&
12+
typeof HTMLElement.prototype.animate !== 'function'
13+
) {
14+
HTMLElement.prototype.animate = function () {
15+
return {
16+
finished: Promise.resolve(),
17+
cancel() {}
18+
};
19+
};
20+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"name": "react-strict-svg",
3+
"version": "0.0.55",
4+
"description": "React Strict SVG",
5+
"exports": {
6+
".": {
7+
"react-native": {
8+
"types": "./dist/native/index.d.ts",
9+
"default": "./dist/native/index.js"
10+
},
11+
"default": {
12+
"types": "./dist/web/index.d.ts",
13+
"default": "./dist/web/index.js"
14+
}
15+
},
16+
"./package.json": "./package.json"
17+
},
18+
"files": [
19+
"dist/*",
20+
"LICENSE",
21+
"package.json"
22+
],
23+
"sideEffects": false,
24+
"scripts": {
25+
"jest": "jest --config ./jest.config.js",
26+
"jest:report": "jest --config ./jest.config.js --collect-coverage",
27+
"build": "rollup --config ./tools/rollup.config.mjs",
28+
"clean": "del-cli \"./dist/*\"",
29+
"prebuild": "npm run clean && generate-types -i src/ -o dist"
30+
},
31+
"dependencies": {
32+
"@stylexjs/stylex": "^0.18.3",
33+
"react-strict-dom": "0.0.55"
34+
},
35+
"devDependencies": {
36+
"@rollup/plugin-babel": "^6.0.4",
37+
"@rollup/plugin-commonjs": "^26.0.1",
38+
"@rollup/plugin-node-resolve": "^15.2.3",
39+
"@testing-library/react": "^16.3.0",
40+
"react": "~19.0.0",
41+
"react-dom": "~19.0.0",
42+
"react-test-renderer": "~19.0.0",
43+
"rollup": "^4.22.4"
44+
},
45+
"peerDependencies": {
46+
"react": "^19.0.0",
47+
"react-dom": "^19.0.0",
48+
"react-native": ">=0.79.5",
49+
"react-native-svg": "^15.8.0"
50+
}
51+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @flow strict
8+
*/
9+
10+
import * as svg from './svg';
11+
12+
export { svg };

0 commit comments

Comments
 (0)