vite-plugin-taro 0.5.5 → 0.5.6
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.
|
@@ -13,22 +13,27 @@ function forward(handler, receiver, args) {
|
|
|
13
13
|
// DevTools re-executes the page and replays the replacement lifecycle on every edit. Taro's
|
|
14
14
|
// onUnload unmounts the React tree and onLoad mounts a fresh one, destroying state. While
|
|
15
15
|
// the runtime says a patch was just delivered, the pair is intercepted instead: onUnload
|
|
16
|
-
// captures the surviving page identity
|
|
17
|
-
//
|
|
18
|
-
// capsule module is cached across re-executions, so this closure holds the capture.
|
|
16
|
+
// captures the surviving page identity and its current native render data, and onLoad
|
|
17
|
+
// immediately paints that snapshot before rebinding and fully synchronizing the retained
|
|
18
|
+
// tree. The capsule module is cached across re-executions, so this closure holds the capture.
|
|
19
19
|
// Ordinary navigation (no patch) passes through unchanged. The wrappers are regular
|
|
20
20
|
// functions so the native page instance (`this`) reaches the original handlers.
|
|
21
21
|
if (typeof __rolldown_runtime__ !== 'undefined') {
|
|
22
22
|
const originalOnUnload = config.onUnload;
|
|
23
23
|
const originalOnLoad = config.onLoad;
|
|
24
24
|
const originalOnShow = config.onShow;
|
|
25
|
+
// This is the sole cross-instance handoff. It is mutable because DevTools destroys the
|
|
26
|
+
// old native Page before creating its replacement; ordinary navigation never reads it.
|
|
25
27
|
let captured;
|
|
26
28
|
config.onUnload = function (...args) {
|
|
27
29
|
if (__rolldown_runtime__.isHotReloading()) {
|
|
28
30
|
const instance = this;
|
|
29
31
|
captured = {
|
|
30
32
|
$taroPath: instance.$taroPath,
|
|
31
|
-
$taroParams: instance.$taroParams
|
|
33
|
+
$taroParams: instance.$taroParams,
|
|
34
|
+
// WeChat owns this serializable view-model snapshot. Retaining it is cheaper
|
|
35
|
+
// than deep-cloning the complete recursive Taro node tree before every edit.
|
|
36
|
+
data: instance.data
|
|
32
37
|
};
|
|
33
38
|
return;
|
|
34
39
|
}
|
|
@@ -36,10 +41,14 @@ if (typeof __rolldown_runtime__ !== 'undefined') {
|
|
|
36
41
|
};
|
|
37
42
|
config.onLoad = function (...args) {
|
|
38
43
|
if (__rolldown_runtime__.isHotReloading() && captured) {
|
|
44
|
+
const instance = this;
|
|
45
|
+
// Paint the last native projection as the first bridge operation. Taro's full
|
|
46
|
+
// performUpdate below runs in a timer, so this direct setData removes most of the
|
|
47
|
+
// empty-page interval without delaying synchronization to the current tree.
|
|
48
|
+
instance.setData(captured.data);
|
|
39
49
|
// Restore the surviving page identity onto the replacement native instance: the
|
|
40
50
|
// re-loaded $taroPath embeds a fresh timestamp, so without this the tree and the
|
|
41
51
|
// native side would disagree on the page key.
|
|
42
|
-
const instance = this;
|
|
43
52
|
instance.$taroPath = captured.$taroPath;
|
|
44
53
|
instance.$taroParams = captured.$taroParams;
|
|
45
54
|
// Rebind the retained tree to the replacement receiver and resync the native
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-taro",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.6",
|
|
4
4
|
"author": "sep2",
|
|
5
5
|
"description": "Vite 8 plugin for building one React/Taro codebase for WeChat Mini Program and H5 targets.",
|
|
6
6
|
"type": "module",
|
|
@@ -75,8 +75,8 @@
|
|
|
75
75
|
"rolldown": "1.2.3",
|
|
76
76
|
"tailwindcss": "^4.3.3",
|
|
77
77
|
"weapp-tailwindcss": "^5.2.11",
|
|
78
|
-
"@tarojs/
|
|
79
|
-
"@tarojs/react": "npm:vite-plugin-taro-react@0.5.
|
|
78
|
+
"@tarojs/react": "npm:vite-plugin-taro-react@0.5.6",
|
|
79
|
+
"@tarojs/plugin-framework-react": "npm:vite-plugin-taro-plugin-framework-react@0.5.6"
|
|
80
80
|
},
|
|
81
81
|
"peerDependencies": {
|
|
82
82
|
"react": "^19.0.0",
|
|
@@ -26,18 +26,23 @@ function forward(handler: unknown, receiver: unknown, args: unknown[]): void {
|
|
|
26
26
|
;(handler as LifecycleHandler | undefined)?.apply(receiver, args)
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
/** The
|
|
30
|
-
type
|
|
29
|
+
/** The old native projection retained while DevTools replaces its Page instance. */
|
|
30
|
+
type PageSnapshot = {
|
|
31
31
|
$taroPath: string
|
|
32
32
|
$taroParams: Record<string, unknown>
|
|
33
|
+
data: Record<string, unknown>
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
type NativePage = PageSnapshot & {
|
|
37
|
+
setData(data: Record<string, unknown>): void
|
|
33
38
|
}
|
|
34
39
|
|
|
35
40
|
// DevTools re-executes the page and replays the replacement lifecycle on every edit. Taro's
|
|
36
41
|
// onUnload unmounts the React tree and onLoad mounts a fresh one, destroying state. While
|
|
37
42
|
// the runtime says a patch was just delivered, the pair is intercepted instead: onUnload
|
|
38
|
-
// captures the surviving page identity
|
|
39
|
-
//
|
|
40
|
-
// capsule module is cached across re-executions, so this closure holds the capture.
|
|
43
|
+
// captures the surviving page identity and its current native render data, and onLoad
|
|
44
|
+
// immediately paints that snapshot before rebinding and fully synchronizing the retained
|
|
45
|
+
// tree. The capsule module is cached across re-executions, so this closure holds the capture.
|
|
41
46
|
// Ordinary navigation (no patch) passes through unchanged. The wrappers are regular
|
|
42
47
|
// functions so the native page instance (`this`) reaches the original handlers.
|
|
43
48
|
if (typeof __rolldown_runtime__ !== 'undefined') {
|
|
@@ -45,14 +50,19 @@ if (typeof __rolldown_runtime__ !== 'undefined') {
|
|
|
45
50
|
const originalOnLoad = config.onLoad
|
|
46
51
|
const originalOnShow = config.onShow
|
|
47
52
|
|
|
48
|
-
|
|
53
|
+
// This is the sole cross-instance handoff. It is mutable because DevTools destroys the
|
|
54
|
+
// old native Page before creating its replacement; ordinary navigation never reads it.
|
|
55
|
+
let captured: PageSnapshot | undefined
|
|
49
56
|
|
|
50
57
|
config.onUnload = function (this: unknown, ...args: unknown[]) {
|
|
51
58
|
if (__rolldown_runtime__.isHotReloading()) {
|
|
52
|
-
const instance = this as unknown as
|
|
59
|
+
const instance = this as unknown as NativePage
|
|
53
60
|
captured = {
|
|
54
61
|
$taroPath: instance.$taroPath,
|
|
55
|
-
$taroParams: instance.$taroParams
|
|
62
|
+
$taroParams: instance.$taroParams,
|
|
63
|
+
// WeChat owns this serializable view-model snapshot. Retaining it is cheaper
|
|
64
|
+
// than deep-cloning the complete recursive Taro node tree before every edit.
|
|
65
|
+
data: instance.data
|
|
56
66
|
}
|
|
57
67
|
return
|
|
58
68
|
}
|
|
@@ -60,10 +70,14 @@ if (typeof __rolldown_runtime__ !== 'undefined') {
|
|
|
60
70
|
}
|
|
61
71
|
config.onLoad = function (this: unknown, ...args: unknown[]) {
|
|
62
72
|
if (__rolldown_runtime__.isHotReloading() && captured) {
|
|
73
|
+
const instance = this as unknown as NativePage
|
|
74
|
+
// Paint the last native projection as the first bridge operation. Taro's full
|
|
75
|
+
// performUpdate below runs in a timer, so this direct setData removes most of the
|
|
76
|
+
// empty-page interval without delaying synchronization to the current tree.
|
|
77
|
+
instance.setData(captured.data)
|
|
63
78
|
// Restore the surviving page identity onto the replacement native instance: the
|
|
64
79
|
// re-loaded $taroPath embeds a fresh timestamp, so without this the tree and the
|
|
65
80
|
// native side would disagree on the page key.
|
|
66
|
-
const instance = this as unknown as PageIdentity
|
|
67
81
|
instance.$taroPath = captured.$taroPath
|
|
68
82
|
instance.$taroParams = captured.$taroParams
|
|
69
83
|
// Rebind the retained tree to the replacement receiver and resync the native
|