react-native-windows 0.81.0-preview.4 → 0.81.0-preview.8
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/Chakra/ChakraUtils.cpp +0 -2
- package/Directory.Build.props +5 -2
- package/Folly/Folly.vcxproj +6 -7
- package/Folly/cgmanifest.json +1 -1
- package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.cpp +19 -0
- package/Microsoft.ReactNative/Fabric/Composition/UriImageManager.cpp +5 -3
- package/Microsoft.ReactNative/Fabric/WindowsImageManager.cpp +14 -1
- package/Microsoft.ReactNative/ReactHost/ReactHost.cpp +0 -4
- package/PropertySheets/Generated/PackageVersion.g.props +2 -2
- package/PropertySheets/React.Cpp.props +1 -0
- package/Shared/MemoryMappedBuffer.cpp +0 -2
- package/package.json +11 -11
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/css/CSSTokenizer.h +0 -232
package/Chakra/ChakraUtils.cpp
CHANGED
|
@@ -166,8 +166,6 @@ FileMappingBigString::FileMappingBigString(const std::wstring &filename, uint32_
|
|
|
166
166
|
return;
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
-
WerRegisterMemoryBlock(m_fileData.get(), m_fileSize);
|
|
170
|
-
|
|
171
169
|
static const uint32_t s_pageSize = getPageSize();
|
|
172
170
|
if (m_fileSize % s_pageSize != 0) {
|
|
173
171
|
// Data are owned by m_fileData, deleter is no-op
|
package/Directory.Build.props
CHANGED
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
<IncludeSource Condition="'$(Configuration)' == 'Release'">false</IncludeSource>
|
|
28
28
|
<!-- When bumping the Folly version, be sure to bump the git hash of that version's commit, find the matching fastfloat dependency and build Folly.vcxproj (to update its cgmanifest.json) too. -->
|
|
29
29
|
<FollyVersion>2024.10.14.00</FollyVersion>
|
|
30
|
-
<FastFloatVersion>
|
|
30
|
+
<FastFloatVersion>8.0.0</FastFloatVersion>
|
|
31
31
|
<FollyCommitHash>ad90720829db5ba0c3d0e44994856dcce33d7940</FollyCommitHash>
|
|
32
|
-
<FastFloatCommitHash>
|
|
32
|
+
<FastFloatCommitHash>77cc847c842c49e7e3477c1e95da2b6540166d66</FastFloatCommitHash>
|
|
33
33
|
<!-- When bumping the fmt version, be sure to bump the git hash of that version's commit and build fmt.vcxproj (to update its cgmanifest.json) too. -->
|
|
34
34
|
<FmtVersion>10.1.0</FmtVersion>
|
|
35
35
|
<FmtCommitHash>ca2e3685b160617d3d95fcd9e789c4e06ca88</FmtCommitHash>
|
|
@@ -52,6 +52,9 @@
|
|
|
52
52
|
<FollyDir Condition="'$(FollyDir)' == '' AND Exists('$([MSBuild]::NormalizeDirectory($(ReactNativeDir)..\..\node_modules))')">$(ReactNativeDir)..\..\node_modules\.folly\folly-$(FollyVersion)</FollyDir>
|
|
53
53
|
<FollyDir>$([MSBuild]::NormalizeDirectory($(FollyDir)))</FollyDir>
|
|
54
54
|
|
|
55
|
+
<FastFloatDir Condition="'$(FastFloatDir)' == '' AND Exists('$([MSBuild]::NormalizeDirectory($(ReactNativeDir)..\..\node_modules))')">$(ReactNativeDir)..\..\node_modules\.fastfloat\fast_float-$(FastFloatVersion)</FastFloatDir>
|
|
56
|
+
<FastFloatDir>$([MSBuild]::NormalizeDirectory($(FastFloatDir)))</FastFloatDir>
|
|
57
|
+
|
|
55
58
|
<FmtDir Condition="'$(FmtDir)' == '' AND Exists('$([MSBuild]::NormalizeDirectory($(ReactNativeDir)..\..\node_modules))')">$(ReactNativeDir)..\..\node_modules\.fmt\fmt-$(FmtVersion)</FmtDir>
|
|
56
59
|
<FmtDir>$([MSBuild]::NormalizeDirectory($(FmtDir)))</FmtDir>
|
|
57
60
|
|
package/Folly/Folly.vcxproj
CHANGED
|
@@ -243,7 +243,6 @@
|
|
|
243
243
|
<ClInclude Include="$(FollyDir)\folly\Uri.h" />
|
|
244
244
|
<ClInclude Include="$(FollyDir)\folly\Utility.h" />
|
|
245
245
|
<ClInclude Include="$(FollyDir)\folly\Varint.h" />
|
|
246
|
-
<ClInclude Include="$(FollyDir)\..\fast_float-6.1.4\include\fast_float\fast_float.h" />
|
|
247
246
|
<ClInclude Include="pch.h" />
|
|
248
247
|
</ItemGroup>
|
|
249
248
|
<ItemGroup>
|
|
@@ -271,7 +270,7 @@
|
|
|
271
270
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
|
272
271
|
<CompileAsWinRT>false</CompileAsWinRT>
|
|
273
272
|
<SDLCheck>true</SDLCheck>
|
|
274
|
-
<AdditionalIncludeDirectories>$(ReactNativeWindowsDir)stubs;$(FollyDir);$(
|
|
273
|
+
<AdditionalIncludeDirectories>$(ReactNativeWindowsDir)stubs;$(FollyDir);$(FastFloatDir)\include;$(FmtDir)\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
275
274
|
<PreprocessorDefinitions>FOLLY_CFG_NO_COROUTINES;FOLLY_NO_CONFIG;NOMINMAX;_CRT_SECURE_NO_WARNINGS;WINAPI_PARTITION_APP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
276
275
|
<ForcedUsingFiles />
|
|
277
276
|
<DisableSpecificWarnings>4251;4293;4305;4800;4804;4310;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
|
@@ -292,8 +291,8 @@
|
|
|
292
291
|
<CGManifestFile>$(MSBuildThisFileDirectory)cgmanifest.json</CGManifestFile>
|
|
293
292
|
</PropertyGroup>
|
|
294
293
|
<PropertyGroup>
|
|
295
|
-
<FastFloatZipDir>$(
|
|
296
|
-
<FastFloatZipFile>$(
|
|
294
|
+
<FastFloatZipDir>$(FastFloatDir)..\.fastfloatzip</FastFloatZipDir>
|
|
295
|
+
<FastFloatZipFile>$(FastFloatZipDir)\fastfloat.zip</FastFloatZipFile>
|
|
297
296
|
</PropertyGroup>
|
|
298
297
|
<Target Name="DownloadFolly" BeforeTargets="PrepareForBuild" Inputs="$(FollyZipFile)" Outputs="$(FollyZipFile)">
|
|
299
298
|
<Message Importance="High" Text="Downloading folly..." />
|
|
@@ -320,11 +319,11 @@
|
|
|
320
319
|
OverwriteReadOnlyFiles="true" />
|
|
321
320
|
</Target>
|
|
322
321
|
<Target Name="UnzipFastFloat" BeforeTargets="PrepareForBuild" DependsOnTargets="DownloadFastFloat">
|
|
323
|
-
<Message Condition="!Exists('$(
|
|
322
|
+
<Message Condition="!Exists('$(FastFloatDir)\include\fast_float\fast_float.h')" Importance="High" Text="Unzipping FastFloat to $([MSBuild]::NormalizePath($(FastFloatDir)..))." />
|
|
324
323
|
<Unzip
|
|
325
|
-
Condition="!Exists('$(
|
|
324
|
+
Condition="!Exists('$(FastFloatDir)\include\fast_float\fast_float.h')"
|
|
326
325
|
SourceFiles="$(FastFloatZipFile)"
|
|
327
|
-
DestinationFolder="$([MSBuild]::NormalizePath($(
|
|
326
|
+
DestinationFolder="$([MSBuild]::NormalizePath($(FastFloatDir)..))"
|
|
328
327
|
OverwriteReadOnlyFiles="true" />
|
|
329
328
|
</Target>
|
|
330
329
|
<Target Name="WriteCGManifest" BeforeTargets="PrepareForBuild" DependsOnTargets="DownloadFolly" Inputs="$(FollyZipFile)" Outputs="$(CGManifestFile)">
|
package/Folly/cgmanifest.json
CHANGED
package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.cpp
CHANGED
|
@@ -66,6 +66,12 @@ struct ModalHostView : public winrt::implements<ModalHostView, winrt::Windows::F
|
|
|
66
66
|
m_appWindow = nullptr;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
// Bring parent window to foreground
|
|
70
|
+
if (m_parentHwnd) {
|
|
71
|
+
SetForegroundWindow(m_parentHwnd);
|
|
72
|
+
SetFocus(m_parentHwnd);
|
|
73
|
+
}
|
|
74
|
+
|
|
69
75
|
// Close bridge
|
|
70
76
|
m_popUp.Close();
|
|
71
77
|
m_popUp = nullptr;
|
|
@@ -247,6 +253,12 @@ struct ModalHostView : public winrt::implements<ModalHostView, winrt::Windows::F
|
|
|
247
253
|
m_reactContext.Properties().Handle(), m_prevWindowID);
|
|
248
254
|
}
|
|
249
255
|
|
|
256
|
+
// Bring parent window to foreground
|
|
257
|
+
if (m_parentHwnd) {
|
|
258
|
+
SetForegroundWindow(m_parentHwnd);
|
|
259
|
+
SetFocus(m_parentHwnd);
|
|
260
|
+
}
|
|
261
|
+
|
|
250
262
|
// Dispatch onDismiss event
|
|
251
263
|
if (auto eventEmitter = EventEmitter()) {
|
|
252
264
|
::Microsoft::ReactNativeSpecs::ModalHostViewEventEmitter::OnDismiss eventArgs;
|
|
@@ -287,9 +299,16 @@ struct ModalHostView : public winrt::implements<ModalHostView, winrt::Windows::F
|
|
|
287
299
|
overlappedPresenter.IsModal(true);
|
|
288
300
|
overlappedPresenter.SetBorderAndTitleBar(true, true);
|
|
289
301
|
|
|
302
|
+
// modal should only have close button
|
|
303
|
+
overlappedPresenter.IsMinimizable(false);
|
|
304
|
+
overlappedPresenter.IsMaximizable(false);
|
|
305
|
+
|
|
290
306
|
// Apply the presenter to the window
|
|
291
307
|
m_appWindow.SetPresenter(overlappedPresenter);
|
|
292
308
|
|
|
309
|
+
// Hide the title bar icon
|
|
310
|
+
m_appWindow.TitleBar().IconShowOptions(winrt::Microsoft::UI::Windowing::IconShowOptions::HideIconAndSystemMenu);
|
|
311
|
+
|
|
293
312
|
// Set initial title using the stored local props
|
|
294
313
|
if (m_localProps && m_localProps->title.has_value()) {
|
|
295
314
|
winrt::hstring titleValue = winrt::to_hstring(m_localProps->title.value());
|
|
@@ -291,9 +291,11 @@ ImageResponseOrImageErrorInfo ImageFailedResponse::ResolveImage() {
|
|
|
291
291
|
if (imageOrError.errorInfo->error.empty()) {
|
|
292
292
|
imageOrError.errorInfo->error = "Failed to load image.";
|
|
293
293
|
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
294
|
+
if (m_responseHeaders) {
|
|
295
|
+
for (auto &&[header, value] : m_responseHeaders) {
|
|
296
|
+
imageOrError.errorInfo->httpResponseHeaders.push_back(
|
|
297
|
+
std::make_pair<std::string, std::string>(winrt::to_string(header), winrt::to_string(value)));
|
|
298
|
+
}
|
|
297
299
|
}
|
|
298
300
|
return imageOrError;
|
|
299
301
|
}
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
#include <Fabric/Composition/ImageResponseImage.h>
|
|
11
11
|
#include <Fabric/Composition/UriImageManager.h>
|
|
12
12
|
#include <Networking/NetworkPropertyIds.h>
|
|
13
|
+
#include <Utils/CppWinrtLessExceptions.h>
|
|
13
14
|
#include <Utils/ImageUtils.h>
|
|
14
15
|
#include <fmt/format.h>
|
|
15
16
|
#include <functional/functor.h>
|
|
@@ -131,7 +132,19 @@ WindowsImageManager::GetImageRandomAccessStreamAsync(
|
|
|
131
132
|
request.Content(bodyContent);
|
|
132
133
|
}
|
|
133
134
|
|
|
134
|
-
|
|
135
|
+
auto asyncOp = m_httpClient.SendRequestAsync(request);
|
|
136
|
+
co_await lessthrow_await_adapter<winrt::Windows::Foundation::IAsyncOperationWithProgress<
|
|
137
|
+
winrt::Windows::Web::Http::HttpResponseMessage,
|
|
138
|
+
winrt::Windows::Web::Http::HttpProgress>>{asyncOp};
|
|
139
|
+
|
|
140
|
+
if (asyncOp.Status() == winrt::Windows::Foundation::AsyncStatus::Error ||
|
|
141
|
+
asyncOp.Status() == winrt::Windows::Foundation::AsyncStatus::Canceled) {
|
|
142
|
+
auto errorMessage = FormatHResultError(winrt::hresult_error(asyncOp.ErrorCode()));
|
|
143
|
+
co_return winrt::Microsoft::ReactNative::Composition::ImageFailedResponse(
|
|
144
|
+
winrt::to_hstring("Network request failed: " + errorMessage));
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
winrt::Windows::Web::Http::HttpResponseMessage response = asyncOp.GetResults();
|
|
135
148
|
|
|
136
149
|
if (!response.IsSuccessStatusCode()) {
|
|
137
150
|
co_return winrt::Microsoft::ReactNative::Composition::ImageFailedResponse(
|
|
@@ -310,10 +310,6 @@ class ReactNativeWindowsFeatureFlags : public facebook::react::ReactNativeFeatur
|
|
|
310
310
|
bool fuseboxEnabledRelease() override {
|
|
311
311
|
return true; // Enable Fusebox (modern CDP backend) by default for React Native Windows
|
|
312
312
|
}
|
|
313
|
-
|
|
314
|
-
bool fuseboxNetworkInspectionEnabled() override {
|
|
315
|
-
return true; // Enable network inspection support in Fusebox
|
|
316
|
-
}
|
|
317
313
|
};
|
|
318
314
|
|
|
319
315
|
//=============================================================================================
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
-->
|
|
11
11
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
12
12
|
<PropertyGroup>
|
|
13
|
-
<ReactNativeWindowsVersion>0.81.0-preview.
|
|
13
|
+
<ReactNativeWindowsVersion>0.81.0-preview.8</ReactNativeWindowsVersion>
|
|
14
14
|
<ReactNativeWindowsMajor>0</ReactNativeWindowsMajor>
|
|
15
15
|
<ReactNativeWindowsMinor>81</ReactNativeWindowsMinor>
|
|
16
16
|
<ReactNativeWindowsPatch>0</ReactNativeWindowsPatch>
|
|
17
17
|
<ReactNativeWindowsCanary>false</ReactNativeWindowsCanary>
|
|
18
|
-
<ReactNativeWindowsCommitId>
|
|
18
|
+
<ReactNativeWindowsCommitId>160ef08880f3f221982ca7840688f45126450539</ReactNativeWindowsCommitId>
|
|
19
19
|
</PropertyGroup>
|
|
20
20
|
</Project>
|
|
@@ -77,8 +77,6 @@ MemoryMappedBuffer::MemoryMappedBuffer(const wchar_t *const filename, uint32_t o
|
|
|
77
77
|
throw facebook::jsi::JSINativeException(
|
|
78
78
|
"MapViewOfFile/MapViewOfFileFromApp failed with last error " + std::to_string(GetLastError()));
|
|
79
79
|
}
|
|
80
|
-
|
|
81
|
-
WerRegisterMemoryBlock(m_fileData.get(), m_fileSize);
|
|
82
80
|
}
|
|
83
81
|
|
|
84
82
|
size_t MemoryMappedBuffer::size() const {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-windows",
|
|
3
|
-
"version": "0.81.0-preview.
|
|
3
|
+
"version": "0.81.0-preview.8",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -28,14 +28,14 @@
|
|
|
28
28
|
"@react-native-community/cli-platform-ios": "17.0.0",
|
|
29
29
|
"@react-native-windows/cli": "0.81.0-preview.1",
|
|
30
30
|
"@react-native/assets": "1.0.0",
|
|
31
|
-
"@react-native/assets-registry": "0.81.0
|
|
32
|
-
"@react-native/codegen": "0.81.0
|
|
33
|
-
"@react-native/community-cli-plugin": "0.81.0
|
|
34
|
-
"@react-native/gradle-plugin": "0.81.0
|
|
35
|
-
"@react-native/js-polyfills": "0.81.0
|
|
36
|
-
"@react-native/normalize-colors": "0.81.0
|
|
37
|
-
"@react-native/virtualized-lists": "0.81.0
|
|
38
|
-
"@react-native/new-app-screen": "0.81.0
|
|
31
|
+
"@react-native/assets-registry": "0.81.0",
|
|
32
|
+
"@react-native/codegen": "0.81.0",
|
|
33
|
+
"@react-native/community-cli-plugin": "0.81.0",
|
|
34
|
+
"@react-native/gradle-plugin": "0.81.0",
|
|
35
|
+
"@react-native/js-polyfills": "0.81.0",
|
|
36
|
+
"@react-native/normalize-colors": "0.81.0",
|
|
37
|
+
"@react-native/virtualized-lists": "0.81.0",
|
|
38
|
+
"@react-native/new-app-screen": "0.81.0",
|
|
39
39
|
"abort-controller": "^3.0.0",
|
|
40
40
|
"anser": "^1.4.9",
|
|
41
41
|
"ansi-regex": "^5.0.0",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@react-native-windows/codegen": "0.81.0-preview.1",
|
|
72
|
-
"@react-native/metro-config": "0.81.0
|
|
72
|
+
"@react-native/metro-config": "0.81.0",
|
|
73
73
|
"@rnw-scripts/babel-react-native-config": "0.0.0",
|
|
74
74
|
"@rnw-scripts/eslint-config": "1.2.37",
|
|
75
75
|
"@rnw-scripts/jest-out-of-tree-snapshot-resolver": "^1.1.41",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"peerDependencies": {
|
|
93
93
|
"@types/react": "^19.1.0",
|
|
94
94
|
"react": "^19.1.0",
|
|
95
|
-
"react-native": "0.81.0
|
|
95
|
+
"react-native": "0.81.0"
|
|
96
96
|
},
|
|
97
97
|
"beachball": {
|
|
98
98
|
"defaultNpmTag": "preview",
|
|
@@ -1,232 +0,0 @@
|
|
|
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
|
-
#pragma once
|
|
9
|
-
|
|
10
|
-
#include <cmath>
|
|
11
|
-
#include <string_view>
|
|
12
|
-
|
|
13
|
-
#include <folly/../../fast_float-6.1.4/include/fast_float/fast_float.h> // [Windows] - Full relative path needed to find file
|
|
14
|
-
#include <react/renderer/css/CSSToken.h>
|
|
15
|
-
|
|
16
|
-
namespace facebook::react {
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* A minimal tokenizer for a subset of CSS syntax.
|
|
20
|
-
*
|
|
21
|
-
* This is based on the W3C CSS Syntax specification, with simplifications made
|
|
22
|
-
* for syntax which React Native does not attempt to support.
|
|
23
|
-
* https://www.w3.org/TR/css-syntax-3/#tokenizing-and-parsing
|
|
24
|
-
*/
|
|
25
|
-
class CSSTokenizer {
|
|
26
|
-
public:
|
|
27
|
-
explicit constexpr CSSTokenizer(std::string_view characters)
|
|
28
|
-
: remainingCharacters_{characters} {}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Returns the next token according to the algorithm described in
|
|
32
|
-
* https://www.w3.org/TR/css-syntax-3/#consume-token
|
|
33
|
-
*/
|
|
34
|
-
constexpr CSSToken next() {
|
|
35
|
-
char nextChar = peek();
|
|
36
|
-
|
|
37
|
-
if (isWhitespace(nextChar)) {
|
|
38
|
-
return consumeWhitespace();
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
switch (nextChar) {
|
|
42
|
-
case '(':
|
|
43
|
-
return consumeCharacter(CSSTokenType::OpenParen);
|
|
44
|
-
case ')':
|
|
45
|
-
return consumeCharacter(CSSTokenType::CloseParen);
|
|
46
|
-
case '[':
|
|
47
|
-
return consumeCharacter(CSSTokenType::OpenSquare);
|
|
48
|
-
case ']':
|
|
49
|
-
return consumeCharacter(CSSTokenType::CloseSquare);
|
|
50
|
-
case '{':
|
|
51
|
-
return consumeCharacter(CSSTokenType::OpenCurly);
|
|
52
|
-
case '}':
|
|
53
|
-
return consumeCharacter(CSSTokenType::CloseCurly);
|
|
54
|
-
case ',':
|
|
55
|
-
return consumeCharacter(CSSTokenType::Comma);
|
|
56
|
-
case '+':
|
|
57
|
-
case '-':
|
|
58
|
-
case '.':
|
|
59
|
-
if (wouldStartNumber()) {
|
|
60
|
-
return consumeNumeric();
|
|
61
|
-
} else {
|
|
62
|
-
return consumeDelim();
|
|
63
|
-
}
|
|
64
|
-
case '#':
|
|
65
|
-
if (isIdent(peek(1))) {
|
|
66
|
-
return consumeHash();
|
|
67
|
-
} else {
|
|
68
|
-
return consumeDelim();
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (isDigit(nextChar)) {
|
|
73
|
-
return consumeNumeric();
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (isIdentStart(nextChar)) {
|
|
77
|
-
return consumeIdentlikeToken();
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (nextChar == '\0') {
|
|
81
|
-
return CSSToken{CSSTokenType::EndOfFile};
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return consumeDelim();
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
private:
|
|
88
|
-
constexpr char peek(size_t i = 0) const {
|
|
89
|
-
auto index = position_ + i;
|
|
90
|
-
return index >= remainingCharacters_.size() ? '\0'
|
|
91
|
-
: remainingCharacters_[index];
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
constexpr void advance() {
|
|
95
|
-
position_ += 1;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
constexpr CSSToken consumeDelim() {
|
|
99
|
-
advance();
|
|
100
|
-
return {CSSTokenType::Delim, consumeRunningValue()};
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
constexpr CSSToken consumeCharacter(CSSTokenType tokenType) {
|
|
104
|
-
advance();
|
|
105
|
-
consumeRunningValue();
|
|
106
|
-
return CSSToken{tokenType};
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
constexpr CSSToken consumeWhitespace() {
|
|
110
|
-
while (isWhitespace(peek())) {
|
|
111
|
-
advance();
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
consumeRunningValue();
|
|
115
|
-
return CSSToken{CSSTokenType::WhiteSpace};
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
constexpr bool wouldStartNumber() const {
|
|
119
|
-
// https://www.w3.org/TR/css-syntax-3/#starts-with-a-number
|
|
120
|
-
if (peek() == '+' || peek() == '-') {
|
|
121
|
-
if (isDigit(peek(1))) {
|
|
122
|
-
return true;
|
|
123
|
-
}
|
|
124
|
-
if (peek(1) == '.' && isDigit(peek(2))) {
|
|
125
|
-
return true;
|
|
126
|
-
}
|
|
127
|
-
} else if (peek() == '.' && isDigit(peek(1))) {
|
|
128
|
-
return true;
|
|
129
|
-
} else if (isDigit(peek())) {
|
|
130
|
-
return true;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
return false;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
constexpr CSSToken consumeNumber() {
|
|
137
|
-
// https://www.w3.org/TR/css-syntax-3/#consume-number
|
|
138
|
-
// https://www.w3.org/TR/css-syntax-3/#convert-a-string-to-a-number
|
|
139
|
-
auto* b = remainingCharacters_.data();
|
|
140
|
-
auto* e = b + remainingCharacters_.size();
|
|
141
|
-
|
|
142
|
-
float value;
|
|
143
|
-
fast_float::parse_options options{
|
|
144
|
-
fast_float::chars_format::general};
|
|
145
|
-
auto [ptr, ec] = fast_float::from_chars_advanced(b, e, value, options);
|
|
146
|
-
|
|
147
|
-
consumeRunningValue();
|
|
148
|
-
return {CSSTokenType::Number, value};
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
constexpr CSSToken consumeNumeric() {
|
|
152
|
-
// https://www.w3.org/TR/css-syntax-3/#consume-numeric-token
|
|
153
|
-
auto numberToken = consumeNumber();
|
|
154
|
-
|
|
155
|
-
if (isIdent(peek())) {
|
|
156
|
-
auto ident = consumeIdentSequence();
|
|
157
|
-
return {
|
|
158
|
-
CSSTokenType::Dimension,
|
|
159
|
-
numberToken.numericValue(),
|
|
160
|
-
ident.stringValue()};
|
|
161
|
-
} else if (peek() == '%') {
|
|
162
|
-
advance();
|
|
163
|
-
consumeRunningValue();
|
|
164
|
-
return {CSSTokenType::Percentage, numberToken.numericValue()};
|
|
165
|
-
} else {
|
|
166
|
-
return numberToken;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
constexpr CSSToken consumeIdentlikeToken() {
|
|
171
|
-
// https://www.w3.org/TR/css-syntax-3/#consume-ident-like-token
|
|
172
|
-
auto ident = consumeIdentSequence();
|
|
173
|
-
if (peek() == '(') {
|
|
174
|
-
advance();
|
|
175
|
-
consumeRunningValue();
|
|
176
|
-
return {CSSTokenType::Function, ident.stringValue()};
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
return ident;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
constexpr CSSToken consumeIdentSequence() {
|
|
183
|
-
// https://www.w3.org/TR/css-syntax-3/#consume-an-ident-sequence
|
|
184
|
-
while (isIdent(peek())) {
|
|
185
|
-
advance();
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
return {CSSTokenType::Ident, consumeRunningValue()};
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
constexpr CSSToken consumeHash() {
|
|
192
|
-
// https://www.w3.org/TR/css-syntax-3/#consume-token (U+0023 NUMBER SIGN)
|
|
193
|
-
advance();
|
|
194
|
-
consumeRunningValue();
|
|
195
|
-
|
|
196
|
-
return {CSSTokenType::Hash, consumeIdentSequence().stringValue()};
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
constexpr std::string_view consumeRunningValue() {
|
|
200
|
-
auto next = remainingCharacters_.substr(0, position_);
|
|
201
|
-
remainingCharacters_ = remainingCharacters_.substr(next.size());
|
|
202
|
-
position_ = 0;
|
|
203
|
-
return next;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
static constexpr bool isDigit(char c) {
|
|
207
|
-
// https://www.w3.org/TR/css-syntax-3/#digit
|
|
208
|
-
return c >= '0' && c <= '9';
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
static constexpr bool isIdentStart(char c) {
|
|
212
|
-
// https://www.w3.org/TR/css-syntax-3/#ident-start-code-point
|
|
213
|
-
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_' ||
|
|
214
|
-
static_cast<unsigned char>(c) > 0x80;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
static constexpr bool isIdent(char c) {
|
|
218
|
-
{
|
|
219
|
-
// https://www.w3.org/TR/css-syntax-3/#ident-code-point
|
|
220
|
-
return isIdentStart(c) || isDigit(c) || c == '-';
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
static constexpr bool isWhitespace(char c) {
|
|
225
|
-
// https://www.w3.org/TR/css-syntax-3/#whitespace
|
|
226
|
-
return c == ' ' || c == '\t' || c == '\r' || c == '\n';
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
std::string_view remainingCharacters_;
|
|
230
|
-
size_t position_{0};
|
|
231
|
-
};
|
|
232
|
-
} // namespace facebook::react
|