@lynx-js/react 0.128.0 → 0.129.0
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/CHANGELOG.md +20 -0
- package/components/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/refresh/.turbo/turbo-build.log +1 -1
- package/runtime/__test__/core/entry-re-eval.test.ts +161 -0
- package/runtime/__test__/core/reload-scoped-dual-thread-communication.test.ts +129 -0
- package/runtime/__test__/core/thread-function-call.test.ts +1 -0
- package/runtime/__test__/element-template/fixtures/background/render/_shared.tsx +2 -0
- package/runtime/__test__/element-template/native/index.test.ts +8 -0
- package/runtime/__test__/element-template/native/main-thread-ref-init-value.test.ts +100 -0
- package/runtime/__test__/element-template/native/reload-dual-thread-communication.test.ts +101 -0
- package/runtime/__test__/element-template/native/reload.test.ts +50 -1
- package/runtime/__test__/element-template/runtime/background/commit-hook.test.ts +104 -47
- package/runtime/__test__/element-template/runtime/background/main-thread-function/compiled-fixtures.test.tsx +7 -1
- package/runtime/__test__/element-template/runtime/background/re-eval-reload.test.ts +69 -0
- package/runtime/__test__/element-template/runtime/hydration/hydration-listener.test.ts +31 -5
- package/runtime/__test__/element-template/runtime/patch/element-template-patch.test.tsx +17 -3
- package/runtime/__test__/element-template/runtime/render/render-transform.contract.test.ts +2 -0
- package/runtime/__test__/element-template/runtime/template/main-thread-function.test.ts +89 -2
- package/runtime/__test__/element-template/test-utils/debug/compiledFixtureModule.ts +5 -0
- package/runtime/__test__/snapshot/lifecycle/re-eval-reload.test.jsx +114 -0
- package/runtime/__test__/snapshot/lifecycle/reload-background-function.test.jsx +169 -0
- package/runtime/__test__/snapshot/lifecycle/reload-delayed-background.test.jsx +63 -0
- package/runtime/__test__/snapshot/lifecycle/reload-delayed-main-thread.test.jsx +103 -0
- package/runtime/__test__/snapshot/lifecycle.test.jsx +61 -1
- package/runtime/__test__/snapshot/lynx/lazy-effect-scheduling.test.jsx +105 -0
- package/runtime/__test__/snapshot/ssr.test.jsx +2 -2
- package/runtime/__test__/snapshot/worklet/runOnBackground.test.js +6 -11
- package/runtime/__test__/snapshot/worklet/runOnMainThread.test.jsx +1 -1
- package/runtime/__test__/snapshot/worklet/workletRef.test.jsx +24 -1
- package/runtime/__test__/worklet-runtime/jsFunctionLifecycle.test.js +15 -1
- package/runtime/__test__/worklet-runtime/mainThreadObject.test.js +46 -0
- package/runtime/__test__/worklet-runtime/runOnMainThread.test.js +3 -3
- package/runtime/lib/core/background-function/exec-map.d.ts +2 -0
- package/runtime/lib/core/background-function/exec-map.js +7 -0
- package/runtime/lib/core/background-function/exec-map.js.map +1 -1
- package/runtime/lib/core/background-function/run-on-background.js +15 -16
- package/runtime/lib/core/background-function/run-on-background.js.map +1 -1
- package/runtime/lib/core/card-lifetime.d.ts +5 -0
- package/runtime/lib/core/card-lifetime.js +17 -0
- package/runtime/lib/core/card-lifetime.js.map +1 -0
- package/runtime/lib/core/entry-reload.d.ts +7 -0
- package/runtime/lib/core/entry-reload.js +49 -0
- package/runtime/lib/core/entry-reload.js.map +1 -0
- package/runtime/lib/core/lynx/lazy-bundle.js +4 -1
- package/runtime/lib/core/lynx/lazy-bundle.js.map +1 -1
- package/runtime/lib/core/main-thread-ref-id.js +4 -4
- package/runtime/lib/core/main-thread-ref-id.js.map +1 -1
- package/runtime/lib/core/reload-scoped-event.d.ts +5 -0
- package/runtime/lib/core/reload-scoped-event.js +26 -0
- package/runtime/lib/core/reload-scoped-event.js.map +1 -0
- package/runtime/lib/core/reload-version.js +4 -3
- package/runtime/lib/core/reload-version.js.map +1 -1
- package/runtime/lib/core/runtime-destroy.d.ts +2 -0
- package/runtime/lib/core/runtime-destroy.js +9 -0
- package/runtime/lib/core/runtime-destroy.js.map +1 -1
- package/runtime/lib/core/thread-function-call/main-thread.js +5 -4
- package/runtime/lib/core/thread-function-call/main-thread.js.map +1 -1
- package/runtime/lib/core/thread-function-call/return-value.js +6 -5
- package/runtime/lib/core/thread-function-call/return-value.js.map +1 -1
- package/runtime/lib/element-template/background/commit-hook.js +19 -16
- package/runtime/lib/element-template/background/commit-hook.js.map +1 -1
- package/runtime/lib/element-template/background/hydration-listener.js +2 -6
- package/runtime/lib/element-template/background/hydration-listener.js.map +1 -1
- package/runtime/lib/element-template/main-thread-ref-init-value.d.ts +3 -0
- package/runtime/lib/element-template/main-thread-ref-init-value.js +38 -0
- package/runtime/lib/element-template/main-thread-ref-init-value.js.map +1 -0
- package/runtime/lib/element-template/native/index.js +2 -0
- package/runtime/lib/element-template/native/index.js.map +1 -1
- package/runtime/lib/element-template/native/mts-destroy.js +2 -0
- package/runtime/lib/element-template/native/mts-destroy.js.map +1 -1
- package/runtime/lib/element-template/native/patch-listener.js +1 -4
- package/runtime/lib/element-template/native/patch-listener.js.map +1 -1
- package/runtime/lib/element-template/native/reload-background.d.ts +1 -1
- package/runtime/lib/element-template/native/reload-background.js +12 -1
- package/runtime/lib/element-template/native/reload-background.js.map +1 -1
- package/runtime/lib/element-template/native/reload-main-thread.d.ts +6 -0
- package/runtime/lib/element-template/native/reload-main-thread.js +18 -2
- package/runtime/lib/element-template/native/reload-main-thread.js.map +1 -1
- package/runtime/lib/element-template/protocol/lifecycle-constant.d.ts +2 -1
- package/runtime/lib/element-template/protocol/lifecycle-constant.js +1 -0
- package/runtime/lib/element-template/protocol/lifecycle-constant.js.map +1 -1
- package/runtime/lib/element-template/protocol/types.d.ts +0 -2
- package/runtime/lib/element-template/protocol/types.js.map +1 -1
- package/runtime/lib/shared/index-map.d.ts +4 -1
- package/runtime/lib/shared/index-map.js +5 -2
- package/runtime/lib/shared/index-map.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/destroy.js +6 -0
- package/runtime/lib/snapshot/lifecycle/destroy.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/event/firstScreenSync.d.ts +6 -2
- package/runtime/lib/snapshot/lifecycle/event/firstScreenSync.js +21 -18
- package/runtime/lib/snapshot/lifecycle/event/firstScreenSync.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/reload.d.ts +9 -2
- package/runtime/lib/snapshot/lifecycle/reload.js +29 -8
- package/runtime/lib/snapshot/lifecycle/reload.js.map +1 -1
- package/runtime/lib/snapshot/list/list.js +3 -2
- package/runtime/lib/snapshot/list/list.js.map +1 -1
- package/runtime/lib/snapshot/lynx/calledByNative.js +3 -3
- package/runtime/lib/snapshot/lynx/calledByNative.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/list.js +2 -1
- package/runtime/lib/snapshot/snapshot/list.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/snapshotInstanceManager.d.ts +4 -2
- package/runtime/lib/snapshot/snapshot/snapshotInstanceManager.js +11 -11
- package/runtime/lib/snapshot/snapshot/snapshotInstanceManager.js.map +1 -1
- package/runtime/lib/snapshot/worklet/call/runOnMainThread.d.ts +1 -0
- package/runtime/lib/snapshot/worklet/call/runOnMainThread.js +6 -1
- package/runtime/lib/snapshot/worklet/call/runOnMainThread.js.map +1 -1
- package/runtime/lib/snapshot/worklet/ctx.d.ts +1 -1
- package/runtime/lib/snapshot/worklet/ctx.js +6 -1
- package/runtime/lib/snapshot/worklet/ctx.js.map +1 -1
- package/runtime/lib/snapshot/worklet/ref/updateInitValue.js +6 -0
- package/runtime/lib/snapshot/worklet/ref/updateInitValue.js.map +1 -1
- package/runtime/lib/tsconfig.tsbuildinfo +1 -1
- package/runtime/lib/worklet-runtime/delayRunOnBackground.js +3 -1
- package/runtime/lib/worklet-runtime/delayRunOnBackground.js.map +1 -1
- package/runtime/lib/worklet-runtime/jsFunctionLifecycle.js +2 -1
- package/runtime/lib/worklet-runtime/jsFunctionLifecycle.js.map +1 -1
- package/runtime/lib/worklet-runtime/listeners.js +2 -2
- package/runtime/lib/worklet-runtime/listeners.js.map +1 -1
- package/runtime/lib/worklet-runtime/mainThreadObject.js +3 -1
- package/runtime/lib/worklet-runtime/mainThreadObject.js.map +1 -1
- package/runtime/lib/worklet-runtime/runOnMainThread.js +4 -3
- package/runtime/lib/worklet-runtime/runOnMainThread.js.map +1 -1
- package/runtime/src/core/background-function/exec-map.ts +9 -0
- package/runtime/src/core/background-function/run-on-background.ts +14 -16
- package/runtime/src/core/card-lifetime.ts +18 -0
- package/runtime/src/core/entry-reload.ts +63 -0
- package/runtime/src/core/lynx/lazy-bundle.ts +4 -1
- package/runtime/src/core/main-thread-ref-id.ts +5 -4
- package/runtime/src/core/reload-scoped-event.ts +35 -0
- package/runtime/src/core/reload-version.ts +5 -3
- package/runtime/src/core/runtime-destroy.ts +11 -0
- package/runtime/src/core/thread-function-call/main-thread.ts +4 -4
- package/runtime/src/core/thread-function-call/return-value.ts +6 -5
- package/runtime/src/element-template/background/commit-hook.ts +20 -17
- package/runtime/src/element-template/background/hydration-listener.ts +2 -6
- package/runtime/src/element-template/main-thread-ref-init-value.ts +44 -0
- package/runtime/src/element-template/native/index.ts +2 -0
- package/runtime/src/element-template/native/mts-destroy.ts +3 -0
- package/runtime/src/element-template/native/patch-listener.ts +0 -5
- package/runtime/src/element-template/native/reload-background.ts +13 -1
- package/runtime/src/element-template/native/reload-main-thread.ts +30 -2
- package/runtime/src/element-template/protocol/lifecycle-constant.ts +1 -0
- package/runtime/src/element-template/protocol/types.ts +0 -2
- package/runtime/src/shared/index-map.ts +3 -2
- package/runtime/src/snapshot/lifecycle/destroy.ts +7 -0
- package/runtime/src/snapshot/lifecycle/event/firstScreenSync.ts +26 -19
- package/runtime/src/snapshot/lifecycle/reload.ts +47 -11
- package/runtime/src/snapshot/list/list.ts +9 -2
- package/runtime/src/snapshot/lynx/calledByNative.ts +3 -4
- package/runtime/src/snapshot/snapshot/list.ts +5 -1
- package/runtime/src/snapshot/snapshot/snapshotInstanceManager.ts +19 -12
- package/runtime/src/snapshot/worklet/call/runOnMainThread.ts +10 -1
- package/runtime/src/snapshot/worklet/ctx.ts +10 -1
- package/runtime/src/snapshot/worklet/ref/updateInitValue.ts +6 -0
- package/runtime/src/worklet-runtime/README.md +13 -0
- package/runtime/src/worklet-runtime/delayRunOnBackground.ts +3 -1
- package/runtime/src/worklet-runtime/jsFunctionLifecycle.ts +2 -1
- package/runtime/src/worklet-runtime/listeners.ts +4 -7
- package/runtime/src/worklet-runtime/mainThreadObject.ts +2 -1
- package/runtime/src/worklet-runtime/runOnMainThread.ts +4 -3
- package/runtime/types/types.d.ts +3 -1
- package/testing-library/.turbo/turbo-build.log +7 -7
- package/testing-library/src/__tests__/worklet.test.jsx +10 -5
- package/transform/.turbo/turbo-build$colon$wasm.log +339 -134
- package/transform/__test__/defines.spec.js +107 -0
- package/transform/crates/swc_plugin_worklet/definition_imports.rs +97 -0
- package/transform/crates/swc_plugin_worklet/lib.rs +7 -6
- package/transform/dist/wasm.cjs +1 -1
- package/transform/index.d.ts +3 -1
- package/transform/src/lib.rs +172 -11
- package/transform/swc-plugin-reactlynx/.turbo/turbo-build.log +57 -55
- package/transform/swc-plugin-reactlynx/swc_plugin_reactlynx.wasm +0 -0
- package/transform/swc-plugin-reactlynx-compat/.turbo/turbo-build.log +66 -274
package/transform/index.d.ts
CHANGED
|
@@ -804,7 +804,7 @@ export interface Define {
|
|
|
804
804
|
unmergeable?: boolean
|
|
805
805
|
/** @internal Compiler requirements of the extracted registration. */
|
|
806
806
|
runtimeRequirements?: TransformRuntimeRequirements
|
|
807
|
-
/** @internal
|
|
807
|
+
/** @internal Imports required by this definition. */
|
|
808
808
|
imports?: DefineImport[]
|
|
809
809
|
}
|
|
810
810
|
/** @internal */
|
|
@@ -815,6 +815,8 @@ export interface DefineImport {
|
|
|
815
815
|
imported: string
|
|
816
816
|
/** @internal */
|
|
817
817
|
local: string
|
|
818
|
+
/** @internal */
|
|
819
|
+
namespace?: boolean
|
|
818
820
|
}
|
|
819
821
|
/** @internal */
|
|
820
822
|
export interface ElementTemplateAsset {
|
package/transform/src/lib.rs
CHANGED
|
@@ -305,7 +305,7 @@ pub struct Define {
|
|
|
305
305
|
pub unmergeable: Option<bool>,
|
|
306
306
|
/// @internal
|
|
307
307
|
pub runtime_requirements: Option<TransformRuntimeRequirements>,
|
|
308
|
-
///
|
|
308
|
+
/// Imports needed when this definition moves to another module.
|
|
309
309
|
/// @internal
|
|
310
310
|
pub imports: Option<Vec<DefineImport>>,
|
|
311
311
|
}
|
|
@@ -319,6 +319,8 @@ pub struct DefineImport {
|
|
|
319
319
|
pub imported: String,
|
|
320
320
|
/// @internal
|
|
321
321
|
pub local: String,
|
|
322
|
+
/// @internal
|
|
323
|
+
pub namespace: Option<bool>,
|
|
322
324
|
}
|
|
323
325
|
|
|
324
326
|
#[napi(object)]
|
|
@@ -365,6 +367,7 @@ fn print_define(
|
|
|
365
367
|
items: Vec<ModuleItem>,
|
|
366
368
|
top_level_mark: Mark,
|
|
367
369
|
comments: &SingleThreadedComments,
|
|
370
|
+
filename: &str,
|
|
368
371
|
) -> Result<(String, Vec<DefineImport>), String> {
|
|
369
372
|
let mut module = match Program::Module(Module {
|
|
370
373
|
span: DUMMY_SP,
|
|
@@ -384,23 +387,40 @@ fn print_define(
|
|
|
384
387
|
|
|
385
388
|
// Print imports and statements through the same hygiene pass before
|
|
386
389
|
// separating them. The consumer must not guess bindings from generated code.
|
|
390
|
+
let filename = filename.replace('\\', "/");
|
|
387
391
|
let mut imports = vec![];
|
|
388
392
|
let mut statements = vec![];
|
|
389
393
|
for item in module.body {
|
|
390
394
|
if let ModuleItem::ModuleDecl(ModuleDecl::Import(import)) = item {
|
|
395
|
+
let mut source = import.src.value.to_string_lossy().into_owned();
|
|
396
|
+
// std::path's absolute-path checks are unsupported on wasm.
|
|
397
|
+
if source == "." || source == ".." || source.starts_with("./") || source.starts_with("../") {
|
|
398
|
+
if let Some((directory, _)) = filename.rsplit_once('/') {
|
|
399
|
+
source = format!("{directory}/{source}");
|
|
400
|
+
if !source.starts_with('/') && source.as_bytes().get(1) != Some(&b':') {
|
|
401
|
+
source = format!("./{source}");
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
}
|
|
391
405
|
for specifier in import.specifiers {
|
|
392
|
-
let
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
406
|
+
let local = specifier.local().sym.to_string();
|
|
407
|
+
let namespace = matches!(specifier, ImportSpecifier::Namespace(_)).then_some(true);
|
|
408
|
+
let imported = match specifier {
|
|
409
|
+
ImportSpecifier::Default(_) => "default".into(),
|
|
410
|
+
ImportSpecifier::Namespace(_) => "*".into(),
|
|
411
|
+
ImportSpecifier::Named(named) => match named.imported {
|
|
412
|
+
Some(ModuleExportName::Ident(ident)) => ident.sym.to_string(),
|
|
413
|
+
Some(ModuleExportName::Str(value)) => value.value.to_string_lossy().into_owned(),
|
|
414
|
+
None => named.local.sym.to_string(),
|
|
415
|
+
},
|
|
416
|
+
#[allow(unreachable_patterns)]
|
|
417
|
+
_ => return Err("unknown definition import specifier".into()),
|
|
399
418
|
};
|
|
400
419
|
imports.push(DefineImport {
|
|
401
|
-
source:
|
|
420
|
+
source: source.clone(),
|
|
402
421
|
imported,
|
|
403
|
-
local
|
|
422
|
+
local,
|
|
423
|
+
namespace,
|
|
404
424
|
});
|
|
405
425
|
}
|
|
406
426
|
} else {
|
|
@@ -1004,7 +1024,7 @@ fn transform_react_lynx_inner(
|
|
|
1004
1024
|
let mut defines_for_worklet: Vec<Define> = vec![];
|
|
1005
1025
|
helpers::HELPERS.set(&helpers::Helpers::new(false), || {
|
|
1006
1026
|
for define in defines_collector.borrow().iter() {
|
|
1007
|
-
let (code, imports) = match print_define(&c, define.items.clone(), top_level_mark, &comments) {
|
|
1027
|
+
let (code, imports) = match print_define(&c, define.items.clone(), top_level_mark, &comments, &options.filename) {
|
|
1008
1028
|
Ok(printed) => printed,
|
|
1009
1029
|
Err(err) => {
|
|
1010
1030
|
define_errors.push(esbuild::PartialMessage {
|
|
@@ -1225,6 +1245,147 @@ mod wasm {
|
|
|
1225
1245
|
mod tests {
|
|
1226
1246
|
use super::*;
|
|
1227
1247
|
|
|
1248
|
+
fn worklet_definition(source: &str, filename: &str) -> Define {
|
|
1249
|
+
let result = transform_react_lynx_inner(
|
|
1250
|
+
source.into(),
|
|
1251
|
+
TransformNodiffOptions {
|
|
1252
|
+
filename: filename.into(),
|
|
1253
|
+
worklet: Either::B(WorkletVisitorConfig {
|
|
1254
|
+
target: swc_plugins_shared::target_napi::TransformTarget::JS,
|
|
1255
|
+
custom_global_ident_names: Some(vec!["call".into(), "api".into(), "named".into()]),
|
|
1256
|
+
..Default::default()
|
|
1257
|
+
}),
|
|
1258
|
+
css_scope: Either::A(false),
|
|
1259
|
+
..Default::default()
|
|
1260
|
+
},
|
|
1261
|
+
);
|
|
1262
|
+
assert!(result.errors.is_empty(), "{:?}", result.errors);
|
|
1263
|
+
let mut definitions = result.defines_for_worklet.unwrap();
|
|
1264
|
+
assert_eq!(definitions.len(), 1);
|
|
1265
|
+
definitions.remove(0)
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
#[test]
|
|
1269
|
+
fn should_collect_business_imports_for_background_only_worklets() {
|
|
1270
|
+
let definition = worklet_definition(
|
|
1271
|
+
r#"
|
|
1272
|
+
import { runOnBackground, useState } from '@lynx-js/react';
|
|
1273
|
+
export const handler = () => {
|
|
1274
|
+
'main thread';
|
|
1275
|
+
runOnBackground(() => {})();
|
|
1276
|
+
};
|
|
1277
|
+
"#,
|
|
1278
|
+
"test.js",
|
|
1279
|
+
);
|
|
1280
|
+
let imports = definition.imports.unwrap();
|
|
1281
|
+
let dependency = imports
|
|
1282
|
+
.iter()
|
|
1283
|
+
.find(|item| item.imported == "runOnBackground")
|
|
1284
|
+
.unwrap();
|
|
1285
|
+
assert_eq!(dependency.source, "@lynx-js/react");
|
|
1286
|
+
assert!(definition
|
|
1287
|
+
.code
|
|
1288
|
+
.contains(&format!("{}(_jsFn1)()", dependency.local)));
|
|
1289
|
+
assert!(!imports.iter().any(|item| item.imported == "useState"));
|
|
1290
|
+
assert_eq!(imports.len(), 2);
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
#[test]
|
|
1294
|
+
fn should_preserve_import_forms_and_rebase_relative_definition_dependencies() {
|
|
1295
|
+
for (filename, expected) in [
|
|
1296
|
+
("/project/src/test.js", "/project/src/./bridge.js"),
|
|
1297
|
+
("C:\\project\\src\\test.js", "C:/project/src/./bridge.js"),
|
|
1298
|
+
("src/test.js", "./src/./bridge.js"),
|
|
1299
|
+
("test.js", "./bridge.js"),
|
|
1300
|
+
] {
|
|
1301
|
+
let definition = worklet_definition(
|
|
1302
|
+
r#"
|
|
1303
|
+
import call, * as api from './bridge.js';
|
|
1304
|
+
import { original as named } from './bridge.js';
|
|
1305
|
+
export const handler = () => {
|
|
1306
|
+
'main thread';
|
|
1307
|
+
return [call(), api.value, { named }];
|
|
1308
|
+
};
|
|
1309
|
+
"#,
|
|
1310
|
+
filename,
|
|
1311
|
+
);
|
|
1312
|
+
let imports = definition.imports.unwrap();
|
|
1313
|
+
let default = imports
|
|
1314
|
+
.iter()
|
|
1315
|
+
.find(|item| item.imported == "default")
|
|
1316
|
+
.unwrap();
|
|
1317
|
+
assert_eq!(default.source, expected);
|
|
1318
|
+
assert_eq!(default.local, "call");
|
|
1319
|
+
assert_eq!(default.namespace, None);
|
|
1320
|
+
let namespace = imports
|
|
1321
|
+
.iter()
|
|
1322
|
+
.find(|item| item.namespace == Some(true))
|
|
1323
|
+
.unwrap();
|
|
1324
|
+
assert_eq!(namespace.imported, "*");
|
|
1325
|
+
assert_eq!(namespace.source, expected);
|
|
1326
|
+
let named = imports
|
|
1327
|
+
.iter()
|
|
1328
|
+
.find(|item| item.imported == "original")
|
|
1329
|
+
.unwrap();
|
|
1330
|
+
assert_eq!(named.source, expected);
|
|
1331
|
+
assert!(definition.code.contains(&named.local));
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
#[test]
|
|
1336
|
+
fn should_rebase_only_relative_definition_imports() {
|
|
1337
|
+
for (source, expected) in [
|
|
1338
|
+
(".", "/project/src/."),
|
|
1339
|
+
("..", "/project/src/.."),
|
|
1340
|
+
("./bridge.js", "/project/src/./bridge.js"),
|
|
1341
|
+
("../bridge.js", "/project/src/../bridge.js"),
|
|
1342
|
+
(".hidden/x", ".hidden/x"),
|
|
1343
|
+
("..hidden/x", "..hidden/x"),
|
|
1344
|
+
("bridge", "bridge"),
|
|
1345
|
+
] {
|
|
1346
|
+
let definition = worklet_definition(
|
|
1347
|
+
&format!(
|
|
1348
|
+
"import call from '{source}'; export const handler = () => {{ 'main thread'; return call(); }};"
|
|
1349
|
+
),
|
|
1350
|
+
"/project/src/test.js",
|
|
1351
|
+
);
|
|
1352
|
+
let imports = definition.imports.unwrap();
|
|
1353
|
+
let dependency = imports
|
|
1354
|
+
.iter()
|
|
1355
|
+
.find(|item| item.imported == "default")
|
|
1356
|
+
.unwrap();
|
|
1357
|
+
assert_eq!(dependency.source, expected);
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1360
|
+
|
|
1361
|
+
#[test]
|
|
1362
|
+
fn should_exclude_captured_and_shadowed_imports_from_worklet_dependencies() {
|
|
1363
|
+
for source in [
|
|
1364
|
+
"import { value } from './values.js'; export const handler = () => { 'main thread'; return value; };",
|
|
1365
|
+
"import { runOnBackground } from './bridge.js'; export const handler = (runOnBackground) => { 'main thread'; runOnBackground(() => {})(); };",
|
|
1366
|
+
] {
|
|
1367
|
+
let definition = worklet_definition(source, "test.js");
|
|
1368
|
+
let imports = definition.imports.unwrap();
|
|
1369
|
+
assert_eq!(imports.len(), 1);
|
|
1370
|
+
assert_eq!(imports[0].imported, "registerWorklet");
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1374
|
+
#[test]
|
|
1375
|
+
fn should_preserve_string_named_definition_imports() {
|
|
1376
|
+
let definition = worklet_definition(
|
|
1377
|
+
"import { 'string-name' as call } from 'bridge'; export const handler = () => { 'main thread'; return call(); };",
|
|
1378
|
+
"test.js",
|
|
1379
|
+
);
|
|
1380
|
+
let imports = definition.imports.unwrap();
|
|
1381
|
+
let dependency = imports
|
|
1382
|
+
.iter()
|
|
1383
|
+
.find(|item| item.imported == "string-name")
|
|
1384
|
+
.unwrap();
|
|
1385
|
+
assert_eq!(dependency.source, "bridge");
|
|
1386
|
+
assert!(definition.code.contains(&format!("{}()", dependency.local)));
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1228
1389
|
#[test]
|
|
1229
1390
|
fn test_syntax_serialize_and_deserialize() {
|
|
1230
1391
|
use serde_json::json;
|
|
@@ -2,30 +2,36 @@ $ node ./build.js
|
|
|
2
2
|
Blocking waiting for file lock on package cache
|
|
3
3
|
Blocking waiting for file lock on package cache
|
|
4
4
|
Blocking waiting for file lock on package cache
|
|
5
|
+
Downloading crates ...
|
|
6
|
+
Downloaded cbor4ii v1.2.2
|
|
7
|
+
Downloaded swc_plugin_macro v2.0.0
|
|
8
|
+
Downloaded swc_plugin_proxy v30.0.0
|
|
9
|
+
Downloaded swc_plugin v1.0.1
|
|
10
|
+
Blocking waiting for file lock on package cache
|
|
5
11
|
Blocking waiting for file lock on build directory
|
|
6
12
|
Compiling foldhash v0.2.0
|
|
7
13
|
Compiling zerovec v0.11.6
|
|
8
14
|
Compiling getrandom v0.3.4
|
|
9
15
|
Compiling ahash v0.8.12
|
|
10
|
-
Compiling hashbrown v0.17.1
|
|
11
16
|
Compiling either v1.17.0
|
|
17
|
+
Compiling hashbrown v0.17.1
|
|
12
18
|
Compiling swc_visit v2.0.2
|
|
13
|
-
Compiling aho-corasick v1.1.4
|
|
14
19
|
Compiling hashbrown v0.14.5
|
|
20
|
+
Compiling aho-corasick v1.1.4
|
|
15
21
|
Compiling indexmap v2.14.0
|
|
22
|
+
Compiling hstr v4.0.0
|
|
16
23
|
Compiling tinystr v0.8.3
|
|
17
|
-
Compiling potential_utf v0.1.5
|
|
18
|
-
Compiling icu_collections v2.2.0
|
|
19
24
|
Compiling icu_locale_core v2.2.0
|
|
25
|
+
Compiling potential_utf v0.1.5
|
|
20
26
|
Compiling serde_json v1.0.151
|
|
21
|
-
Compiling
|
|
27
|
+
Compiling icu_collections v2.2.0
|
|
22
28
|
Compiling icu_provider v2.2.0
|
|
23
29
|
Compiling swc_atoms v10.0.0
|
|
30
|
+
Compiling regex-automata v0.4.16
|
|
24
31
|
Compiling icu_properties v2.2.0
|
|
25
32
|
Compiling icu_normalizer v2.2.0
|
|
26
|
-
Compiling regex-automata v0.4.16
|
|
27
|
-
Compiling swc_ecma_regexp_common v0.0.1
|
|
28
33
|
Compiling typenum v1.20.1
|
|
34
|
+
Compiling swc_ecma_regexp_common v0.0.1
|
|
29
35
|
Compiling crossbeam-utils v0.8.22
|
|
30
36
|
Compiling idna_adapter v1.2.2
|
|
31
37
|
Compiling idna v1.1.0
|
|
@@ -34,105 +40,101 @@ $ node ./build.js
|
|
|
34
40
|
Compiling url v2.5.8
|
|
35
41
|
Compiling hashbrown v0.16.1
|
|
36
42
|
Compiling swc_sourcemap v10.0.2
|
|
43
|
+
Compiling regex v1.13.1
|
|
37
44
|
Compiling bstr v1.13.0
|
|
38
45
|
Compiling regress v0.11.1
|
|
39
|
-
Compiling regex v1.13.1
|
|
40
46
|
Compiling swc_common v26.0.0
|
|
41
47
|
Compiling swc_ecma_ast v29.0.0
|
|
42
48
|
Compiling swc_ecma_regexp_ast v3.0.0
|
|
43
49
|
Compiling swc_ecma_regexp_visit v0.15.0
|
|
44
|
-
Compiling swc_ecma_regexp v0.15.0
|
|
45
|
-
Compiling swc_ecma_compat_regexp v9.0.0
|
|
46
50
|
Compiling globset v0.4.19
|
|
47
|
-
Compiling
|
|
51
|
+
Compiling swc_ecma_compat_regexp v9.0.0
|
|
52
|
+
Compiling swc_ecma_regexp v0.15.0
|
|
48
53
|
Compiling block-buffer v0.10.4
|
|
49
|
-
Compiling
|
|
54
|
+
Compiling crypto-common v0.1.7
|
|
55
|
+
Compiling swc_config v6.0.0
|
|
50
56
|
Compiling digest v0.10.7
|
|
51
57
|
Compiling arrayvec v0.7.8
|
|
52
|
-
Compiling swc_config v6.0.0
|
|
53
|
-
Compiling swc_ecma_transforms_macros v1.0.1
|
|
54
58
|
Compiling fixedbitset v0.5.7
|
|
55
|
-
Compiling zmij v1.0.23
|
|
56
|
-
Compiling petgraph v0.7.1
|
|
57
59
|
Compiling swc_allocator v5.0.0
|
|
58
60
|
Compiling sha1 v0.10.7
|
|
61
|
+
Compiling petgraph v0.7.1
|
|
59
62
|
Compiling chrono v0.4.45
|
|
60
|
-
Compiling browserslist-data v0.2.0
|
|
61
63
|
Compiling swc_error_reporters v28.0.0
|
|
62
64
|
Compiling matchers v0.2.0
|
|
65
|
+
Compiling browserslist-data v0.2.0
|
|
63
66
|
Compiling itertools v0.15.0
|
|
64
67
|
Compiling nom v8.0.0
|
|
65
|
-
Compiling static-map-macro v0.3.4
|
|
66
|
-
Compiling precomputed-map v0.2.0
|
|
67
|
-
Compiling foldhash v0.1.5
|
|
68
|
-
Compiling swc_ecma_visit v29.0.0
|
|
69
|
-
Compiling swc_ecma_parser v45.1.1
|
|
70
68
|
Compiling tracing-subscriber v0.3.23
|
|
71
|
-
Compiling browserslist-rs v0.20.0
|
|
72
|
-
Compiling swc_ecma_preset_env v63.0.0
|
|
73
69
|
Compiling st-map v0.2.4
|
|
74
70
|
Compiling cargo_metadata v0.18.1
|
|
71
|
+
Compiling swc_ecma_visit v29.0.0
|
|
72
|
+
Compiling swc_ecma_parser v45.1.1
|
|
73
|
+
Compiling browserslist-rs v0.20.0
|
|
75
74
|
Compiling par-iter v2.0.0
|
|
76
75
|
Compiling ryu-js v1.0.3
|
|
77
76
|
Compiling radix_fmt v1.0.0
|
|
78
77
|
Compiling pathdiff v0.2.3
|
|
79
78
|
Compiling testing v27.0.0
|
|
80
79
|
Compiling preset_env_base v9.0.0
|
|
80
|
+
Compiling swc_ecma_preset_env v63.0.0
|
|
81
|
+
Compiling sha2 v0.10.9
|
|
82
|
+
Compiling lru v0.18.4
|
|
83
|
+
Compiling path-clean v1.0.1
|
|
84
|
+
Compiling foldhash v0.1.5
|
|
85
|
+
Compiling precomputed-map v0.2.0
|
|
86
|
+
Compiling swc_ecma_loader v27.0.0
|
|
87
|
+
Compiling swc_ecma_testing v27.0.0
|
|
88
|
+
Compiling swc_transform_common v20.0.0
|
|
89
|
+
Compiling swc_node_comments v27.0.0
|
|
90
|
+
Compiling jsonc-parser v0.26.3
|
|
91
|
+
Compiling swc_core v77.1.2
|
|
92
|
+
Compiling swc_plugin_proxy v30.0.0
|
|
93
|
+
Compiling sha-1 v0.10.1
|
|
94
|
+
Compiling hybrid-array v0.4.13
|
|
95
|
+
Compiling crypto-common v0.2.2
|
|
96
|
+
Compiling block-buffer v0.12.1
|
|
97
|
+
Compiling const-oid v0.10.2
|
|
81
98
|
Compiling swc_ecma_utils v35.0.0
|
|
82
99
|
Compiling swc_ecma_hooks v1.0.0
|
|
100
|
+
Compiling digest v0.11.3
|
|
101
|
+
Compiling sha2 v0.11.0
|
|
83
102
|
Compiling swc_ecma_transforms_base v49.0.1
|
|
84
103
|
Compiling swc_ecma_codegen v32.0.0
|
|
104
|
+
Compiling swc_ecma_ext_transforms v35.0.0
|
|
85
105
|
Compiling swc_ecma_transformer v21.0.1
|
|
86
106
|
Compiling swc_ecma_transforms_classes v49.0.0
|
|
87
|
-
Compiling swc_ecma_transforms_optimization v52.0.0
|
|
88
107
|
Compiling swc_ecma_compat_common v45.0.0
|
|
89
108
|
Compiling swc_ecma_compat_es2015 v55.0.0
|
|
90
109
|
Compiling swc_ecma_compat_es2022 v53.0.0
|
|
91
|
-
Compiling
|
|
110
|
+
Compiling swc_ecma_transforms_optimization v52.0.0
|
|
92
111
|
Compiling swc_ecma_compat_es2020 v53.0.0
|
|
112
|
+
Compiling swc_ecma_compat_es2016 v50.0.0
|
|
93
113
|
Compiling swc_ecma_compat_es2018 v51.0.0
|
|
94
114
|
Compiling swc_ecma_compat_es2019 v50.0.0
|
|
95
|
-
Compiling swc_ecma_compat_es2016 v50.0.0
|
|
96
115
|
Compiling swc_ecma_compat_es2021 v50.0.0
|
|
116
|
+
Compiling swc_ecma_compat_bugfixes v56.0.0
|
|
97
117
|
Compiling swc_ecma_compat_es2017 v50.0.0
|
|
98
118
|
Compiling swc_ecma_transforms_react v55.0.1
|
|
99
119
|
Compiling swc_ecma_transforms_compat v57.0.1
|
|
100
120
|
Compiling swc_ecma_transforms_typescript v55.0.1
|
|
101
121
|
Compiling swc_ecma_transforms_proposal v49.0.0
|
|
102
|
-
Compiling swc_ecma_minifier v61.0.4
|
|
103
122
|
Compiling swc_ecma_transforms v62.0.0
|
|
104
|
-
Compiling
|
|
105
|
-
Compiling
|
|
106
|
-
Compiling
|
|
123
|
+
Compiling swc_ecma_minifier v61.0.4
|
|
124
|
+
Compiling swc_ecma_transforms_testing v53.0.0
|
|
125
|
+
Compiling swc_plugin_define_dce v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugin_define_dce)
|
|
107
126
|
Compiling swc_compiler_base v64.0.0
|
|
108
|
-
Compiling swc_ecma_testing v27.0.0
|
|
109
|
-
Compiling swc_ecma_loader v27.0.0
|
|
110
|
-
Compiling swc_ecma_ext_transforms v35.0.0
|
|
111
|
-
Compiling swc_node_comments v27.0.0
|
|
112
|
-
Compiling swc_transform_common v20.0.0
|
|
113
|
-
Compiling jsonc-parser v0.26.3
|
|
114
|
-
Compiling swc_core v77.1.2
|
|
115
127
|
Compiling swc v75.0.1
|
|
116
|
-
Compiling swc_ecma_transforms_testing v53.0.0
|
|
117
|
-
Compiling swc_plugin_proxy v30.0.0
|
|
118
|
-
Compiling sha-1 v0.10.1
|
|
119
|
-
Compiling hybrid-array v0.4.13
|
|
120
|
-
Compiling crypto-common v0.2.2
|
|
121
|
-
Compiling block-buffer v0.12.1
|
|
122
|
-
Compiling const-oid v0.10.2
|
|
123
128
|
Compiling swc_plugins_shared v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugins_shared)
|
|
124
|
-
Compiling digest v0.11.3
|
|
125
|
-
Compiling sha2 v0.11.0
|
|
126
|
-
Compiling swc_plugin_define_dce v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugin_define_dce)
|
|
127
|
-
Compiling swc_plugin_directive_dce v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugin_directive_dce)
|
|
128
|
-
Compiling swc_plugin_element_template v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugin_element_template)
|
|
129
129
|
Compiling swc_plugin_list v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugin_list)
|
|
130
|
-
Compiling swc_plugin_shake v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugin_shake)
|
|
131
130
|
Compiling swc_plugin_worklet v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugin_worklet)
|
|
132
|
-
Compiling
|
|
131
|
+
Compiling swc_plugin_shake v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugin_shake)
|
|
132
|
+
Compiling swc_plugin_css_scope v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugin_css_scope)
|
|
133
|
+
Compiling swc_plugin_element_template v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugin_element_template)
|
|
134
|
+
Compiling swc_plugin_directive_dce v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugin_directive_dce)
|
|
133
135
|
Compiling swc_plugin_dynamic_import v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugin_dynamic_import)
|
|
134
|
-
Compiling swc_plugin_snapshot v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugin_snapshot)
|
|
135
136
|
Compiling swc_plugin_text v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugin_text)
|
|
136
|
-
Compiling
|
|
137
|
+
Compiling swc_plugin_inject v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugin_inject)
|
|
138
|
+
Compiling swc_plugin_snapshot v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugin_snapshot)
|
|
137
139
|
Compiling swc_plugin_reactlynx v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/swc-plugin-reactlynx)
|
|
138
|
-
Finished `release` profile [optimized] target(s) in
|
|
140
|
+
Finished `release` profile [optimized] target(s) in 6m 41s
|
|
Binary file
|