vite-plugin-taro 0.7.8 → 0.7.9

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.
@@ -2,7 +2,7 @@ import type { HmrInfo } from './hmr-protocol.ts';
2
2
  export declare const hmrInfoFileName = "hmr/info.js";
3
3
  /**
4
4
  * Renders immutable CommonJS metadata because App startup must initialize the runtime synchronously before any entry capsule.
5
- * Freezing also prevents application code from accidentally changing the build identity or socket endpoint for the App heap.
5
+ * Freezing also prevents application code from accidentally changing the running App's build identity or socket endpoint.
6
6
  */
7
7
  export declare function renderHmrInfo(info: HmrInfo): string;
8
8
  /**
@@ -10,7 +10,7 @@ export declare function renderHmrInfo(info: HmrInfo): string;
10
10
  *
11
11
  * Imported global CSS can change while the entry remains byte-identical. DevTools may then reuse an older persistent compile
12
12
  * cache after it restarts. Tying this inert comment to the build identity invalidates that cache once per complete build,
13
- * while incremental style updates continue changing only the imported file and therefore preserve the App heap.
13
+ * while incremental style updates continue changing only the imported file and therefore keep the App running.
14
14
  */
15
15
  export declare function renderDevelopmentAppStyle(globalStyleFileName: string, buildId: string): string;
16
16
  /**
@@ -0,0 +1,11 @@
1
+ import type { AstTransformResult } from '../../../utils/transform.ts';
2
+ /**
3
+ * In serve, a native Page may load its original physical capsule after HMR has already installed a newer component factory.
4
+ * Taro captures the component at createPageConfig() time; without this lookup, that Page first mounts with stale source even
5
+ * though the patch was acknowledged. Replace only the component argument, leaving the production capsule untouched.
6
+ */
7
+ export declare function injectDevPageComponent({ capsuleCode, componentId, capsuleId }: {
8
+ capsuleCode: string;
9
+ componentId: string;
10
+ capsuleId: string;
11
+ }): AstTransformResult;
@@ -29,7 +29,7 @@ export declare function createMiniDevelopmentPlugin(contract: MiniContract, styl
29
29
  * but removes the prior physical App stylesheet; recovery builds do not clean. The host publishes the stylesheet once afterward.
30
30
  * Patch modes first reset delivery and publish matching `hmr/info.js`; rebuild mode has no patch state and writes a fresh marker
31
31
  * directly. Incremental HMR never enters this complete-output hook and changes only the imported global stylesheet; rewriting
32
- * the App root would reload the heap while a JavaScript patch is awaiting acknowledgement. The serve-only plugin leaves
32
+ * the App root would reload the runtime while a JavaScript patch is awaiting acknowledgement. The serve-only plugin leaves
33
33
  * production output unchanged.
34
34
  */
35
35
  export declare function removeDevelopmentAppStyle(bundle: Record<string, unknown>, appStyleFileName: string): void;
@@ -1,8 +1,8 @@
1
- /** Host-to-App terminal control over the App heap's authenticated Vite socket. */
1
+ /** Host-to-App terminal control over the authenticated Vite socket owned by the running App. */
2
2
  export declare const runtimeControlEvent = "vpt:mini-hmr:control";
3
3
  /** App-to-host application frontier and rebuild reports over the same socket. */
4
4
  export declare const runtimeReportEvent = "vpt:mini-hmr:report";
5
- /** Build identity and authenticated socket endpoint fixed for one App heap. */
5
+ /** Build identity and authenticated socket endpoint fixed for the lifetime of one running App. */
6
6
  export type HmrInfo = Readonly<{
7
7
  buildId: string;
8
8
  endpoint: string;
@@ -1,4 +1,4 @@
1
- /** Host-to-App terminal control over the App heap's authenticated Vite socket. */
1
+ /** Host-to-App terminal control over the authenticated Vite socket owned by the running App. */
2
2
  export const runtimeControlEvent = 'vpt:mini-hmr:control';
3
3
  /** App-to-host application frontier and rebuild reports over the same socket. */
4
4
  export const runtimeReportEvent = 'vpt:mini-hmr:report';
@@ -1,3 +1,4 @@
1
+ import type { ElementType } from 'react';
1
2
  import type { DevRuntime as RolldownDevRuntime } from 'rolldown/experimental/runtime-types';
2
3
  import { type HmrInfo } from './hmr-protocol.ts';
3
4
  /** Lexical base class injected into the runtime chunk by Rolldown; typed via the contract. */
@@ -55,7 +56,7 @@ export type ConnectMiniSocket = (endpoint: string) => MiniSocketTask;
55
56
  /** Shared Mini Program host mechanics extending the Rolldown contract instead of reimplementing it. */
56
57
  export declare class MiniHmrRuntime extends DevRuntime {
57
58
  /**
58
- * One session for this App heap. Undefined only before the mode-selected entry initializes the runtime; its identity then
59
+ * One session for the running App. Undefined only before the mode-selected entry initializes the runtime; its identity then
59
60
  * stays fixed while appliedSeq records the committed frontier.
60
61
  */
61
62
  private session;
@@ -67,7 +68,7 @@ export declare class MiniHmrRuntime extends DevRuntime {
67
68
  * the new one. Passive contexts are never retained, so space is O(number of boundaries).
68
69
  */
69
70
  private readonly moduleHotContexts;
70
- /** Immutable platform socket constructor retained for the App heap's first initialization. */
71
+ /** Immutable platform socket constructor retained until the running App initializes. */
71
72
  private readonly connectSocket;
72
73
  constructor(connectSocket: ConnectMiniSocket);
73
74
  /**
@@ -76,6 +77,8 @@ export declare class MiniHmrRuntime extends DevRuntime {
76
77
  * calling accept registers the new context after the apply plan captured old callbacks.
77
78
  */
78
79
  createModuleHotContext(moduleId: string): MiniHotContext;
80
+ /** Resolves a cold Page against patches installed before its physical capsule first executed. */
81
+ resolvePageComponent(moduleId: string, baseline: ElementType): ElementType;
79
82
  /** Computes accepting boundaries and every executed module that must be re-armed. */
80
83
  private computeHmrUpdate;
81
84
  /** Walks executed importers until an accepting boundary is found. */
@@ -86,7 +89,7 @@ export declare class MiniHmrRuntime extends DevRuntime {
86
89
  */
87
90
  private applyHmrUpdate;
88
91
  /**
89
- * Initializes exactly once per App heap. Repeated entry evaluation must not replace the identity or reset `appliedSeq`, because
92
+ * Initializes exactly once each time DevTools loads the App. Repeated entry evaluation must not replace the identity or reset `appliedSeq`, because
90
93
  * either change could acknowledge factories against another host client or replay already committed application generations.
91
94
  */
92
95
  initialize(info: HmrInfo): void;
@@ -60,7 +60,7 @@ class MiniHotContext {
60
60
  /** Shared Mini Program host mechanics extending the Rolldown contract instead of reimplementing it. */
61
61
  export class MiniHmrRuntime extends DevRuntime {
62
62
  /**
63
- * One session for this App heap. Undefined only before the mode-selected entry initializes the runtime; its identity then
63
+ * One session for the running App. Undefined only before the mode-selected entry initializes the runtime; its identity then
64
64
  * stays fixed while appliedSeq records the committed frontier.
65
65
  */
66
66
  session;
@@ -73,7 +73,7 @@ export class MiniHmrRuntime extends DevRuntime {
73
73
  * the new one. Passive contexts are never retained, so space is O(number of boundaries).
74
74
  */
75
75
  moduleHotContexts = new Map();
76
- /** Immutable platform socket constructor retained for the App heap's first initialization. */
76
+ /** Immutable platform socket constructor retained until the running App initializes. */
77
77
  connectSocket;
78
78
  constructor(connectSocket) {
79
79
  // The base has no messenger: the engine tracks per-client shipped payloads instead
@@ -94,6 +94,19 @@ export class MiniHmrRuntime extends DevRuntime {
94
94
  this.moduleHotContexts.delete(moduleId);
95
95
  return new MiniHotContext(moduleId, this.moduleHotContexts);
96
96
  }
97
+ /** Resolves a cold Page against patches installed before its physical capsule first executed. */
98
+ resolvePageComponent(moduleId, baseline) {
99
+ if (!this.hasFactory(moduleId)) {
100
+ return baseline;
101
+ }
102
+ // An unopened native Page evaluates its original capsule after the patch has already been ACKed. That capsule
103
+ // registers baseline exports in Rolldown's cache, shadowing the installed patch factory. Only evict that exact
104
+ // baseline reference: an already-refreshed Page's current exports must not be re-executed on every render.
105
+ if (this.isExecuted(moduleId) && this.loadExports(moduleId).default === baseline) {
106
+ this.removeModuleCache(moduleId);
107
+ }
108
+ return this.initModule(moduleId).default;
109
+ }
97
110
  /** Computes accepting boundaries and every executed module that must be re-armed. */
98
111
  computeHmrUpdate(changedIds) {
99
112
  // Mutable traversal accumulators are confined to one synchronous update plan.
@@ -163,7 +176,7 @@ export class MiniHmrRuntime extends DevRuntime {
163
176
  }
164
177
  }
165
178
  /**
166
- * Initializes exactly once per App heap. Repeated entry evaluation must not replace the identity or reset `appliedSeq`, because
179
+ * Initializes exactly once each time DevTools loads the App. Repeated entry evaluation must not replace the identity or reset `appliedSeq`, because
167
180
  * either change could acknowledge factories against another host client or replay already committed application generations.
168
181
  */
169
182
  initialize(info) {
@@ -219,13 +232,13 @@ export class MiniHmrRuntime extends DevRuntime {
219
232
  return;
220
233
  }
221
234
  if (!this.socket) {
222
- // Before OPEN the new heap uses only the disk baseline. Startup requests a rebuild if patches were published;
235
+ // Before OPEN the newly loaded App uses only the disk baseline. Startup requests a rebuild if patches were published;
223
236
  // do not replay their factories early or queue them for later. Closed connections likewise cannot acknowledge updates.
224
237
  return;
225
238
  }
226
239
  if (session.appliedSeq === 0 && payload.patches.length > 0 && payload.patches[0].seq > 1) {
227
240
  // Compile starts from the original bundle, but the physical file can be an ACK-pruned suffix. Do not install it or
228
- // classify an expected new-heap synchronization as patch corruption. OPEN reports startup automatically; if already
241
+ // classify expected startup synchronization as patch corruption. OPEN reports startup automatically; if already
229
242
  // connected, ask the host to rebuild the baseline now.
230
243
  this.sendReport({ kind: 'startup' });
231
244
  return;
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * DevTools adapter injected into the App-global Rolldown runtime chunk. Every Page evaluates the inert `hmr/patches.js` payload
3
- * before its route capsule, while this singleton survives Page JavaScript hot reload in the App heap. That lifetime difference is
3
+ * before its route capsule, while this singleton survives Page JavaScript hot reload as the App keeps running. That lifetime difference is
4
4
  * what allows module and React state to survive repeated native Page registration.
5
5
  */
6
6
  import { MiniHmrRuntime } from '../../mini-hmr-runtime.js';
@@ -2,7 +2,7 @@ import type { HmrInfo } from '../../hmr-protocol.ts';
2
2
  import { type ConnectMiniSocket, MiniHmrRuntime } from '../../mini-hmr-runtime.ts';
3
3
  /** Interprets cumulative patch source received by the shared App-level HMR socket. */
4
4
  declare class InterpreterHmrRuntime extends MiniHmrRuntime {
5
- /** One installer and Sval scope retain interpreted factory closures for this App heap. */
5
+ /** One installer and Sval scope retain interpreted factory closures for the lifetime of the running App. */
6
6
  private readonly installPatch;
7
7
  constructor(connectSocket: ConnectMiniSocket);
8
8
  protected onSocketEvent(info: HmrInfo, event: string, data: unknown): void;
@@ -7,7 +7,7 @@ import { MiniHmrRuntime } from '../../mini-hmr-runtime.js';
7
7
  import { interpreterServerEvent } from './interpreter-protocol.js';
8
8
  /** Interprets cumulative patch source received by the shared App-level HMR socket. */
9
9
  class InterpreterHmrRuntime extends MiniHmrRuntime {
10
- /** One installer and Sval scope retain interpreted factory closures for this App heap. */
10
+ /** One installer and Sval scope retain interpreted factory closures for the lifetime of the running App. */
11
11
  installPatch;
12
12
  constructor(connectSocket) {
13
13
  super(connectSocket);
@@ -37,7 +37,7 @@ systemJSPrototype.import = function (id, parentId, meta) {
37
37
  *
38
38
  * Mini Program placement guarantees that every registration in a synchronous graph uses the main-package transport. Encountering
39
39
  * a thenable therefore indicates a fatal placement invariant violation. No rollback is attempted: rows already published
40
- * to the shared registry remain there and the current runtime heap must not be reused.
40
+ * to the shared registry remain there and the current runtime instance must not be reused.
41
41
  */
42
42
  systemJSPrototype.importSync = function (id) {
43
43
  var loader = this;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-taro",
3
- "version": "0.7.8",
3
+ "version": "0.7.9",
4
4
  "author": "sep2",
5
5
  "description": "Vite 8 plugin for building one React/Taro codebase for WeChat, Alipay, TikTok, and H5 targets.",
6
6
  "type": "module",
@@ -67,7 +67,7 @@
67
67
  "rolldown": "1.2.9",
68
68
  "sval": "0.6.12",
69
69
  "tailwindcss": "^4.3.3",
70
- "vite-plugin-taro-runtime": "0.7.8"
70
+ "vite-plugin-taro-runtime": "0.7.9"
71
71
  },
72
72
  "peerDependencies": {
73
73
  "react": "^19.3.0",
@@ -91,7 +91,7 @@
91
91
  "c8": "^12.0.0",
92
92
  "oxc-walker": "1.1.1",
93
93
  "picocolors": "^1.1.1",
94
- "postcss-pxtrans": "1.0.4",
94
+ "postcss-rule-unit-converter": "0.2.3",
95
95
  "rxjs": "^7.8.2",
96
96
  "typescript": "^7.0.2",
97
97
  "vite": "8.3.0"