react-native-worklets 0.11.1 → 0.11.3
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/Common/cpp/worklets/WorkletRuntime/WorkletHermesRuntime.cpp +5 -2
- package/RNWorklets.podspec +1 -1
- package/apple/worklets/apple/Networking/WorkletsNetworking.mm +3 -3
- package/apple/worklets/apple/WorkletsModule.mm +0 -1
- package/bundleMode/shims/turboModuleRegistryShim.js +1 -1
- package/lib/module/bundleMode/network.native.js +5 -0
- package/lib/module/bundleMode/network.native.js.map +1 -1
- package/lib/module/debug/jsVersion.js +1 -1
- package/lib/module/memory/valueUnpacker.native.js +1 -1
- package/lib/module/memory/valueUnpacker.native.js.map +1 -1
- package/lib/typescript/bundleMode/network.native.d.ts.map +1 -1
- package/lib/typescript/debug/jsVersion.d.ts +1 -1
- package/package.json +1 -1
- package/plugin/index.js +19 -7
- package/src/bundleMode/network.native.ts +6 -0
- package/src/debug/jsVersion.ts +1 -1
- package/src/memory/valueUnpacker.native.ts +2 -2
|
@@ -38,11 +38,14 @@ WorkletHermesRuntime::WorkletHermesRuntime(std::unique_ptr<facebook::hermes::Her
|
|
|
38
38
|
auto code = std::make_shared<const jsi::StringBuffer>(args[0].asString(rt).utf8(rt));
|
|
39
39
|
std::string sourceURL;
|
|
40
40
|
if (count > 1 && args[1].isString()) {
|
|
41
|
-
sourceURL = args[1].
|
|
41
|
+
sourceURL = args[1].getString(rt).utf8(rt);
|
|
42
42
|
}
|
|
43
43
|
std::shared_ptr<const jsi::Buffer> sourceMap;
|
|
44
44
|
if (count > 2 && args[2].isString()) {
|
|
45
|
-
|
|
45
|
+
auto sourceMapString = args[2].getString(rt).utf8(rt);
|
|
46
|
+
if (!sourceMapString.empty()) {
|
|
47
|
+
sourceMap = std::make_shared<const jsi::StringBuffer>(std::move(sourceMapString));
|
|
48
|
+
}
|
|
46
49
|
}
|
|
47
50
|
return wrappedRuntime->evaluateJavaScriptWithSourceMap(code, sourceMap, sourceURL);
|
|
48
51
|
});
|
package/RNWorklets.podspec
CHANGED
|
@@ -57,7 +57,6 @@ Pod::Spec.new do |s|
|
|
|
57
57
|
|
|
58
58
|
s.dependency 'React-jsi'
|
|
59
59
|
s.dependency 'React-hermes'
|
|
60
|
-
|
|
61
60
|
s.pod_target_xcconfig = {
|
|
62
61
|
"USE_HEADERMAP" => "YES",
|
|
63
62
|
"DEFINES_MODULE" => "YES",
|
|
@@ -70,6 +69,7 @@ Pod::Spec.new do |s|
|
|
|
70
69
|
'"$(PODS_ROOT)/DoubleConversion"',
|
|
71
70
|
'"$(PODS_ROOT)/Headers/Private/React-Core"',
|
|
72
71
|
'"$(PODS_ROOT)/Headers/Private/Yoga"',
|
|
72
|
+
'"$(PODS_CONFIGURATION_BUILD_DIR)/React-utils/React_utils.framework/Headers/react/utils/platform/ios"',
|
|
73
73
|
].join(' '),
|
|
74
74
|
"FRAMEWORK_SEARCH_PATHS" => '"${PODS_CONFIGURATION_BUILD_DIR}/React-hermes"',
|
|
75
75
|
"CLANG_CXX_LANGUAGE_STANDARD" => "c++20",
|
|
@@ -5,9 +5,6 @@
|
|
|
5
5
|
|
|
6
6
|
#import <mutex>
|
|
7
7
|
|
|
8
|
-
#import <FBReactNativeSpec/FBReactNativeSpec.h>
|
|
9
|
-
#import <React-Core/React/RCTFollyConvert.h>
|
|
10
|
-
#import <React-jsi/jsi/JSIDynamic.h>
|
|
11
8
|
#import <React/RCTAssert.h>
|
|
12
9
|
#import <React/RCTConvert.h>
|
|
13
10
|
#import <React/RCTHTTPRequestHandler.h>
|
|
@@ -17,7 +14,10 @@
|
|
|
17
14
|
#import <React/RCTNetworkTask.h>
|
|
18
15
|
#import <React/RCTNetworking.h>
|
|
19
16
|
#import <React/RCTUtils.h>
|
|
17
|
+
#import <ReactCommon/RCTTurboModule.h>
|
|
18
|
+
#import <jsi/JSIDynamic.h>
|
|
20
19
|
#import <react/featureflags/ReactNativeFeatureFlags.h>
|
|
20
|
+
#import <react/utils/FollyConvert.h>
|
|
21
21
|
|
|
22
22
|
#import <worklets/WorkletRuntime/WorkletRuntime.h>
|
|
23
23
|
#import <worklets/apple/Networking/WorkletsNetworking.h>
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
#import <React/RCTCallInvoker.h>
|
|
14
14
|
|
|
15
15
|
#ifdef WORKLETS_FETCH_PREVIEW_ENABLED
|
|
16
|
-
#import <FBReactNativeSpec/FBReactNativeSpec.h>
|
|
17
16
|
#import <React/RCTNetworking.h>
|
|
18
17
|
#import <ReactCommon/RCTTurboModule.h>
|
|
19
18
|
#import <worklets/apple/Networking/WorkletsNetworking.h>
|
|
@@ -33,7 +33,7 @@ if (
|
|
|
33
33
|
function getPolyfill(/** @type {string} */ name) {
|
|
34
34
|
if (__DEV__ && !TurboModulesPolyfill?.has(name)) {
|
|
35
35
|
throw new Error(
|
|
36
|
-
|
|
36
|
+
`[Worklets] Accessing TurboModules is not allowed on Worklet Runtimes. Requested: "${String(name)}".`
|
|
37
37
|
);
|
|
38
38
|
} else {
|
|
39
39
|
return TurboModulesPolyfill?.get(name);
|
|
@@ -6,10 +6,15 @@
|
|
|
6
6
|
* The NetworkingModule itself is injected via C++.
|
|
7
7
|
*/
|
|
8
8
|
export function initializeNetworking() {
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
10
|
+
require('react-native/Libraries/TurboModule/TurboModuleRegistry');
|
|
9
11
|
const TurboModules = globalThis.TurboModules;
|
|
10
12
|
TurboModules.set('FileReaderModule', makeMockTurboModule('FileReaderModule'));
|
|
11
13
|
TurboModules.set('PlatformConstants', makeMockTurboModule('PlatformConstants'));
|
|
12
14
|
TurboModules.set('WebSocketModule', makeMockTurboModule('WebSocketModule'));
|
|
15
|
+
TurboModules.set('NativeReactNativeFeatureFlagsCxx', new Proxy({}, {
|
|
16
|
+
get: () => () => undefined
|
|
17
|
+
}));
|
|
13
18
|
TurboModules.set('BlobModule', makeMockTurboModule('BlobModule', ['addNetworkingHandler']));
|
|
14
19
|
|
|
15
20
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["initializeNetworking","TurboModules","globalThis","set","makeMockTurboModule","
|
|
1
|
+
{"version":3,"names":["initializeNetworking","require","TurboModules","globalThis","set","makeMockTurboModule","Proxy","get","undefined","noopMethods","name","extraNoopMethods","proxy","_target","prop","includes","Error","String"],"sourceRoot":"../../../src","sources":["bundleMode/network.native.ts"],"mappings":"AAAA,YAAY;;AAEZ;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,oBAAoBA,CAAA,EAAG;EACrC;EACAC,OAAO,CAAC,wDAAwD,CAAC;EACjE,MAAMC,YAAY,GAAGC,UAAU,CAACD,YAAY;EAE5CA,YAAY,CAACE,GAAG,CAAC,kBAAkB,EAAEC,mBAAmB,CAAC,kBAAkB,CAAC,CAAC;EAC7EH,YAAY,CAACE,GAAG,CACd,mBAAmB,EACnBC,mBAAmB,CAAC,mBAAmB,CACzC,CAAC;EACDH,YAAY,CAACE,GAAG,CAAC,iBAAiB,EAAEC,mBAAmB,CAAC,iBAAiB,CAAC,CAAC;EAC3EH,YAAY,CAACE,GAAG,CACd,kCAAkC,EAClC,IAAIE,KAAK,CAAC,CAAC,CAAC,EAAE;IAAEC,GAAG,EAAEA,CAAA,KAAM,MAAMC;EAAU,CAAC,CAC9C,CAAC;EACDN,YAAY,CAACE,GAAG,CACd,YAAY,EACZC,mBAAmB,CAAC,YAAY,EAAE,CAAC,sBAAsB,CAAC,CAC5D,CAAC;;EAED;AACF;AACA;AACA;AACA;AACA;AACA;EACE;EACAJ,OAAO,CAAC,sCAAsC,CAAC;AACjD;AAEA,MAAMQ,WAAW,GAAG,CAAC,cAAc,CAAC;AAEpC,SAASJ,mBAAmBA,CAACK,IAAY,EAAEC,gBAA2B,EAAE;EACtE,MAAMC,KAAK,GAAG,IAAIN,KAAK,CACrB,CAAC,CAAC,EACF;IACEC,GAAG,EAAE,SAASA,GAAGA,CAACM,OAAO,EAAEC,IAAI,EAAE;MAC/B,IACE,CAAC,GAAGL,WAAW,EAAE,IAAIE,gBAAgB,IAAI,EAAE,CAAC,CAAC,CAACI,QAAQ,CAACD,IAAc,CAAC,EACtE;QACA,OAAO,MAAM;UACX,OAAO,MAAM,CAAC,CAAC;QACjB,CAAC;MACH;MACA,MAAM,IAAIE,KAAK,CACb,wCAAwCC,MAAM,CAC5CH,IACF,CAAC,WAAWJ,IAAI,8CAA8CA,IAAI,oDACpE,CAAC;IACH;EACF,CACF,CAAC;EAED,OAAOE,KAAK;AACd","ignoreList":[]}
|
|
@@ -14,7 +14,7 @@ export function installValueUnpacker() {
|
|
|
14
14
|
const initData = objectToUnpack.__initData;
|
|
15
15
|
if (initData.bytecode !== undefined) {
|
|
16
16
|
workletFun = globalThis.evalBytecode(initData.bytecode);
|
|
17
|
-
} else if (globalThis.evalWithSourceMap) {
|
|
17
|
+
} else if (globalThis.evalWithSourceMap && initData.sourceMap) {
|
|
18
18
|
// if the runtime (hermes only for now) supports loading source maps
|
|
19
19
|
// we want to use the proper filename for the location as it guarantees
|
|
20
20
|
// that debugger understands and loads the source code of the file where
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["installValueUnpacker","workletsCache","Map","handleCache","WeakMap","valueUnpacker","objectToUnpack","workletHash","__workletHash","undefined","workletFun","get","initData","__initData","bytecode","globalThis","evalBytecode","evalWithSourceMap","
|
|
1
|
+
{"version":3,"names":["installValueUnpacker","workletsCache","Map","handleCache","WeakMap","valueUnpacker","objectToUnpack","workletHash","__workletHash","undefined","workletFun","get","initData","__initData","bytecode","globalThis","evalBytecode","evalWithSourceMap","sourceMap","code","location","evalWithSourceUrl","eval","set","functionInstance","bind","_recur","__init","value","Error","_toString","__valueUnpacker"],"sourceRoot":"../../../src","sources":["memory/valueUnpacker.native.ts"],"mappings":"AAAA,YAAY;;AAcZ,OAAO,SAASA,oBAAoBA,CAAA,EAAG;EACrC,SAAS;EACT,oBAAoB;;EACpB,MAAMC,aAA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AAS,EAAE;MAC9C,IAAImB,KAAK,GAAGzB,WAAW,CAACQ,GAAG,CAACL,cAAc,CAAC;MAC3C,IAAIsB,KAAK,KAAKnB,SAAS,EAAE;QACvBmB,KAAK,GAAGtB,cAAc,CAACqB,MAAM,CAAC,CAAC;QAC/BxB,WAAW,CAACoB,GAAG,CAACjB,cAAc,EAAEsB,KAAK,CAAC;MACxC;MACA,OAAOA,KAAK;IACd,CAAC,MAAM;MACL,MAAM,IAAIC,KAAK,CACb,2DAA2Dd,UAAU,CAACe,SAAS,CAC7ExB,cACF,CAAC,IACH,CAAC;IACH;EACF;EAEAS,UAAU,CAACgB,eAAe,GAAG1B,aAA8B;AAC7D","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network.native.d.ts","sourceRoot":"","sources":["../../../src/bundleMode/network.native.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,oBAAoB,
|
|
1
|
+
{"version":3,"file":"network.native.d.ts","sourceRoot":"","sources":["../../../src/bundleMode/network.native.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,oBAAoB,SA6BnC"}
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
* version used to build the native part of the library in runtime. Remember to
|
|
4
4
|
* keep this in sync with the version declared in `package.json`
|
|
5
5
|
*/
|
|
6
|
-
export declare const jsVersion = "0.11.
|
|
6
|
+
export declare const jsVersion = "0.11.3";
|
|
7
7
|
//# sourceMappingURL=jsVersion.d.ts.map
|
package/package.json
CHANGED
package/plugin/index.js
CHANGED
|
@@ -381,9 +381,19 @@ var require_utils = __commonJS({
|
|
|
381
381
|
exports2.replaceWithFactoryCall = replaceWithFactoryCall;
|
|
382
382
|
var types_12 = require("@babel/types");
|
|
383
383
|
function isRelease(state) {
|
|
384
|
-
var _a, _b
|
|
385
|
-
const
|
|
386
|
-
|
|
384
|
+
var _a, _b;
|
|
385
|
+
const releasePattern = /(prod|release|stag[ei])/i;
|
|
386
|
+
const developmentPattern = /dev/i;
|
|
387
|
+
const envName = state.file.opts.envName;
|
|
388
|
+
if (envName) {
|
|
389
|
+
if (envName.match(releasePattern)) {
|
|
390
|
+
return true;
|
|
391
|
+
}
|
|
392
|
+
if (envName.match(developmentPattern)) {
|
|
393
|
+
return false;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
return !!(((_a = process.env.BABEL_ENV) === null || _a === void 0 ? void 0 : _a.match(releasePattern)) || ((_b = process.env.NODE_ENV) === null || _b === void 0 ? void 0 : _b.match(releasePattern)));
|
|
387
397
|
}
|
|
388
398
|
function replaceWithFactoryCall(toReplace, name, factoryCall) {
|
|
389
399
|
if (!name || !needsDeclaration(toReplace)) {
|
|
@@ -414,6 +424,7 @@ var require_globals = __commonJS({
|
|
|
414
424
|
exports2.isGeneratedWorkletFile = isGeneratedWorkletFile;
|
|
415
425
|
exports2.initializeGlobals = initializeGlobals;
|
|
416
426
|
exports2.addCustomGlobals = addCustomGlobals;
|
|
427
|
+
var assert_1 = require("assert");
|
|
417
428
|
var path_1 = __importDefault(require("path"));
|
|
418
429
|
var autoworkletization_12 = require_autoworkletization();
|
|
419
430
|
var types_12 = require_types();
|
|
@@ -555,7 +566,8 @@ var require_globals = __commonJS({
|
|
|
555
566
|
addCustomGlobals(state);
|
|
556
567
|
}
|
|
557
568
|
const userImportForwarding = state.opts.importForwarding;
|
|
558
|
-
state.
|
|
569
|
+
(0, assert_1.strict)(state.importForwarding === void 0, "state.importForwarding should be undefined at this point");
|
|
570
|
+
state.importForwarding = {
|
|
559
571
|
relativePaths: [
|
|
560
572
|
...defaultAllowedPaths,
|
|
561
573
|
...(_a = userImportForwarding === null || userImportForwarding === void 0 ? void 0 : userImportForwarding.relativePaths) !== null && _a !== void 0 ? _a : []
|
|
@@ -614,7 +626,7 @@ var require_imports = __commonJS({
|
|
|
614
626
|
var _a;
|
|
615
627
|
if (nodePath.get("callee").isIdentifier({ name: "require" }) && ((_a = nodePath.get("arguments")[0]) === null || _a === void 0 ? void 0 : _a.isStringLiteral())) {
|
|
616
628
|
const requiredModule = nodePath.get("arguments")[0];
|
|
617
|
-
if (requiredModule.node.value.startsWith(".") && canForwardRelativeImport(state.file.opts.filename || "", state.
|
|
629
|
+
if (requiredModule.node.value.startsWith(".") && canForwardRelativeImport(state.file.opts.filename || "", state.importForwarding.relativePaths)) {
|
|
618
630
|
requiredModule.replaceWith(createImportPathLiteral(requiredModule.node.value, state));
|
|
619
631
|
}
|
|
620
632
|
}
|
|
@@ -711,13 +723,13 @@ var require_closure = __commonJS({
|
|
|
711
723
|
scope = scope.parent;
|
|
712
724
|
}
|
|
713
725
|
if (state.opts.bundleMode && (0, imports_1.isImport)(binding)) {
|
|
714
|
-
if ((0, imports_1.isImportRelative)(binding) && (0, imports_1.canForwardRelativeImport)(state.filename, state.
|
|
726
|
+
if ((0, imports_1.isImportRelative)(binding) && (0, imports_1.canForwardRelativeImport)(state.filename, state.importForwarding.relativePaths)) {
|
|
715
727
|
capturedNames.add(name);
|
|
716
728
|
relativeBindingsToImport.add(binding);
|
|
717
729
|
return;
|
|
718
730
|
}
|
|
719
731
|
const source = binding.path.parentPath.node.source.value;
|
|
720
|
-
if ((0, imports_1.canForwardModuleImport)(source, state.
|
|
732
|
+
if ((0, imports_1.canForwardModuleImport)(source, state.importForwarding.moduleNames)) {
|
|
721
733
|
capturedNames.add(name);
|
|
722
734
|
moduleBindingsToImport.add(binding);
|
|
723
735
|
return;
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
* The NetworkingModule itself is injected via C++.
|
|
7
7
|
*/
|
|
8
8
|
export function initializeNetworking() {
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
10
|
+
require('react-native/Libraries/TurboModule/TurboModuleRegistry');
|
|
9
11
|
const TurboModules = globalThis.TurboModules;
|
|
10
12
|
|
|
11
13
|
TurboModules.set('FileReaderModule', makeMockTurboModule('FileReaderModule'));
|
|
@@ -14,6 +16,10 @@ export function initializeNetworking() {
|
|
|
14
16
|
makeMockTurboModule('PlatformConstants')
|
|
15
17
|
);
|
|
16
18
|
TurboModules.set('WebSocketModule', makeMockTurboModule('WebSocketModule'));
|
|
19
|
+
TurboModules.set(
|
|
20
|
+
'NativeReactNativeFeatureFlagsCxx',
|
|
21
|
+
new Proxy({}, { get: () => () => undefined })
|
|
22
|
+
);
|
|
17
23
|
TurboModules.set(
|
|
18
24
|
'BlobModule',
|
|
19
25
|
makeMockTurboModule('BlobModule', ['addNetworkingHandler'])
|
package/src/debug/jsVersion.ts
CHANGED
|
@@ -26,7 +26,7 @@ export function installValueUnpacker() {
|
|
|
26
26
|
const initData = objectToUnpack.__initData;
|
|
27
27
|
if (initData!.bytecode !== undefined) {
|
|
28
28
|
workletFun = globalThis.evalBytecode!(initData!.bytecode);
|
|
29
|
-
} else if (globalThis.evalWithSourceMap) {
|
|
29
|
+
} else if (globalThis.evalWithSourceMap && initData!.sourceMap) {
|
|
30
30
|
// if the runtime (hermes only for now) supports loading source maps
|
|
31
31
|
// we want to use the proper filename for the location as it guarantees
|
|
32
32
|
// that debugger understands and loads the source code of the file where
|
|
@@ -34,7 +34,7 @@ export function installValueUnpacker() {
|
|
|
34
34
|
workletFun = globalThis.evalWithSourceMap(
|
|
35
35
|
initData!.code!,
|
|
36
36
|
initData!.location!,
|
|
37
|
-
initData!.sourceMap
|
|
37
|
+
initData!.sourceMap
|
|
38
38
|
);
|
|
39
39
|
} else if (globalThis.evalWithSourceUrl) {
|
|
40
40
|
// if the runtime doesn't support loading source maps, in dev mode we
|