vite-plugin-taro 0.6.20 → 0.7.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.
Files changed (104) hide show
  1. package/README.en.md +4 -4
  2. package/README.md +4 -4
  3. package/dist/index.d.ts +1 -1
  4. package/dist/index.js +147 -136
  5. package/dist/node/plugins/mini/dev/dev-host.d.ts +29 -0
  6. package/dist/node/plugins/{wx → mini}/dev/hmr-files.d.ts +1 -3
  7. package/dist/node/plugins/mini/dev/hmr-mode.d.ts +32 -0
  8. package/dist/node/plugins/{wx → mini}/dev/hmr-protocol.d.ts +1 -1
  9. package/dist/node/plugins/{wx/dev/wx-dev-options.d.ts → mini/dev/mini-dev-options.d.ts} +7 -7
  10. package/dist/node/plugins/{wx → mini}/dev/modes/devtools/devtools-hmr-mode.d.ts +4 -3
  11. package/dist/node/plugins/mini/dev/modes/interpreter/interpreter-hmr-mode.d.ts +4 -0
  12. package/dist/node/plugins/mini/dev/modes/rebuild/rebuild-hmr-mode.d.ts +4 -0
  13. package/dist/node/plugins/mini/dev/plugins.d.ts +35 -0
  14. package/dist/node/plugins/{wx → mini}/dev/react-refresh.d.ts +7 -7
  15. package/dist/node/plugins/mini/mini-contract.d.ts +66 -0
  16. package/dist/node/plugins/mini/module/module.d.ts +38 -0
  17. package/dist/node/plugins/{wx → mini}/output/files.d.ts +4 -4
  18. package/dist/node/plugins/{wx → mini}/placer/placement.d.ts +5 -11
  19. package/dist/node/plugins/{wx → mini}/placer/placer.d.ts +14 -11
  20. package/dist/node/plugins/mini/plugins.d.ts +4 -0
  21. package/dist/node/plugins/{wx → mini}/render/capsule.d.ts +5 -5
  22. package/dist/node/plugins/{wx → mini}/render/native.d.ts +6 -4
  23. package/dist/node/plugins/{wx → mini}/render/system-js/string-editor.d.ts +1 -1
  24. package/dist/node/plugins/{wx → mini}/render/system-js/system-js.d.ts +1 -1
  25. package/dist/node/plugins/{wx → mini}/render/transport.d.ts +3 -1
  26. package/dist/node/plugins/{wx → mini}/resolve/resolver.d.ts +3 -3
  27. package/dist/node/plugins/{wx → mini}/resolve/specialize-app-capsule.d.ts +2 -2
  28. package/dist/node/plugins/{wx → mini}/resolve/specialize-page-capsule.d.ts +2 -2
  29. package/dist/node/plugins/mini/skeleton/skeleton-utils.d.ts +33 -0
  30. package/dist/node/plugins/{wx/styles/create-wx-transformer.d.ts → mini/styles/create-mini-transformer.d.ts} +3 -3
  31. package/dist/node/plugins/{wx → mini}/styles/plugins.d.ts +32 -32
  32. package/dist/node/plugins/wx/create-wx-skeleton.d.ts +57 -0
  33. package/dist/node/plugins/wx/plugins.d.ts +5 -2
  34. package/dist/node/plugins/zfb/create-zfb-skeleton.d.ts +59 -0
  35. package/dist/node/plugins/zfb/plugins.d.ts +7 -0
  36. package/dist/node/utils/modules.d.ts +2 -0
  37. package/dist/node/utils/project-config.d.ts +3 -1
  38. package/dist/options.d.ts +44 -26
  39. package/dist/runtime/{wx → mini}/amphibious/bootstrap.js +4 -4
  40. package/dist/runtime/{wx → mini}/capsule/app.js +1 -1
  41. package/dist/runtime/mini/capsule/page.js +18 -0
  42. package/dist/runtime/{wx → mini}/capsule/taro-runtime.d.ts +2 -2
  43. package/dist/runtime/{wx → mini}/capsule/taro-runtime.js +5 -4
  44. package/dist/runtime/{wx/dev/wx-hmr-protocol.d.ts → mini/dev/hmr-protocol.d.ts} +2 -2
  45. package/dist/runtime/{wx/dev/wx-hmr-protocol.js → mini/dev/hmr-protocol.js} +2 -2
  46. package/dist/runtime/{wx/dev/wx-hmr-runtime.d.ts → mini/dev/mini-hmr-runtime.d.ts} +24 -7
  47. package/dist/runtime/{wx/dev/wx-hmr-runtime.js → mini/dev/mini-hmr-runtime.js} +21 -13
  48. package/dist/runtime/mini/dev/modes/devtools/devtools-runtime.d.ts +23 -0
  49. package/dist/runtime/{wx → mini}/dev/modes/devtools/devtools-runtime.js +8 -8
  50. package/dist/runtime/{wx → mini}/dev/modes/devtools/page-hmr.js +5 -5
  51. package/dist/runtime/{wx → mini}/dev/modes/interpreter/interpreter-protocol.d.ts +2 -2
  52. package/dist/runtime/mini/dev/modes/interpreter/interpreter-protocol.js +1 -0
  53. package/dist/runtime/mini/dev/modes/interpreter/interpreter-runtime.d.ts +12 -0
  54. package/dist/runtime/{wx → mini}/dev/modes/interpreter/interpreter-runtime.js +14 -7
  55. package/dist/runtime/mini/dev/polyfill/polyfill-queue-microtask.d.ts +14 -0
  56. package/dist/runtime/mini/dev/polyfill/polyfill-queue-microtask.js +18 -0
  57. package/dist/runtime/{wx → mini}/native/page.js +1 -1
  58. package/dist/runtime/{wx → mini}/systemjs/system-core.js +2 -3
  59. package/dist/runtime/wx/dev/connect-wx-socket.d.ts +3 -0
  60. package/dist/runtime/wx/dev/connect-wx-socket.js +2 -0
  61. package/dist/runtime/wx/dev/devtools-runtime.js +5 -0
  62. package/dist/runtime/wx/dev/interpreter-runtime.js +5 -0
  63. package/dist/runtime/zfb/dev/connect-zfb-socket.d.ts +10 -0
  64. package/dist/runtime/zfb/dev/connect-zfb-socket.js +18 -0
  65. package/dist/runtime/zfb/dev/devtools-runtime.d.ts +1 -0
  66. package/dist/runtime/zfb/dev/devtools-runtime.js +5 -0
  67. package/dist/runtime/zfb/dev/interpreter-runtime.d.ts +1 -0
  68. package/dist/runtime/zfb/dev/interpreter-runtime.js +5 -0
  69. package/package.json +10 -8
  70. package/dist/node/plugins/wx/dev/dev-host.d.ts +0 -29
  71. package/dist/node/plugins/wx/dev/hmr-mode.d.ts +0 -31
  72. package/dist/node/plugins/wx/dev/modes/interpreter/interpreter-hmr-mode.d.ts +0 -3
  73. package/dist/node/plugins/wx/dev/plugins.d.ts +0 -32
  74. package/dist/node/plugins/wx/module/module.d.ts +0 -51
  75. package/dist/node/plugins/wx/output/relative-root.d.ts +0 -2
  76. package/dist/node/plugins/wx/output/templates.d.ts +0 -124
  77. package/dist/runtime/wx/capsule/page.js +0 -18
  78. package/dist/runtime/wx/dev/modes/interpreter/interpreter-protocol.js +0 -1
  79. /package/dist/node/plugins/{wx → mini}/dev/create-hmr-results-stream.d.ts +0 -0
  80. /package/dist/node/plugins/{wx → mini}/dev/host-actions.d.ts +0 -0
  81. /package/dist/node/plugins/{wx → mini}/dev/patch-journal.d.ts +0 -0
  82. /package/dist/node/plugins/{wx → mini}/module/chunk-path.d.ts +0 -0
  83. /package/dist/node/plugins/{wx → mini}/native/compile-native-component-interface.d.ts +0 -0
  84. /package/dist/node/plugins/{wx → mini}/native/create-native-component-output.d.ts +0 -0
  85. /package/dist/node/plugins/{wx → mini}/native/native-component-assets.d.ts +0 -0
  86. /package/dist/node/plugins/{wx → mini}/native/native-component-interface.d.ts +0 -0
  87. /package/dist/runtime/{wx → mini}/amphibious/bootstrap.d.ts +0 -0
  88. /package/dist/runtime/{wx → mini}/amphibious/transport.d.ts +0 -0
  89. /package/dist/runtime/{wx → mini}/amphibious/transport.js +0 -0
  90. /package/dist/runtime/{wx → mini}/capsule/app.d.ts +0 -0
  91. /package/dist/runtime/{wx → mini}/capsule/component.d.ts +0 -0
  92. /package/dist/runtime/{wx → mini}/capsule/component.js +0 -0
  93. /package/dist/runtime/{wx → mini}/capsule/page.d.ts +0 -0
  94. /package/dist/runtime/{wx → mini}/dev/modes/devtools/page-hmr.d.ts +0 -0
  95. /package/dist/runtime/{wx → mini}/native/app.d.ts +0 -0
  96. /package/dist/runtime/{wx → mini}/native/app.js +0 -0
  97. /package/dist/runtime/{wx → mini}/native/component.d.ts +0 -0
  98. /package/dist/runtime/{wx → mini}/native/component.js +0 -0
  99. /package/dist/runtime/{wx → mini}/native/custom-wrapper.d.ts +0 -0
  100. /package/dist/runtime/{wx → mini}/native/custom-wrapper.js +0 -0
  101. /package/dist/runtime/{wx → mini}/native/page.d.ts +0 -0
  102. /package/dist/runtime/{wx → mini}/systemjs/system-core.d.ts +0 -0
  103. /package/dist/runtime/wx/dev/{modes/devtools/devtools-runtime.d.ts → devtools-runtime.d.ts} +0 -0
  104. /package/dist/runtime/wx/dev/{modes/interpreter/interpreter-runtime.d.ts → interpreter-runtime.d.ts} +0 -0
@@ -1,51 +0,0 @@
1
- import { type Rolldown } from 'vite';
2
- /** Identifies Rolldown's generated helper module independently of its unstable output filename. */
3
- export declare const rolldownRuntimeId = "\0rolldown/runtime.js";
4
- /** Resolves the direct React Reconciler dependency without assuming pnpm's layout. */
5
- export declare const reactReconcilerRoot: string;
6
- /** Identifies the amphibious bootstrap that initializes SystemJS and serves every native shell. */
7
- export declare const bootstrapPath: string;
8
- /** Identifies the native transport source materialized before Rolldown finalizes content hashes. */
9
- export declare const transportPath: string;
10
- /** Redirects Vite's injected browser preload helper to the bootstrap identity loader. */
11
- export declare const vitePreloadId = "\0vite/preload-helper.js";
12
- /** Forces the native App shell entry to emit at WeChat's required root path. */
13
- export declare const appShellFileName = "app.js";
14
- /** Identifies the synchronous native App shell source. */
15
- export declare const appShellPath: string;
16
- /** Identifies the App capsule kept behind the native shell boundary. */
17
- export declare const appCapsulePath: string;
18
- /** Forces Taro's recursive native Component entry to emit at its configured root path. */
19
- export declare const componentShellFileName = "comp.js";
20
- /** Identifies the synchronous recursive Component shell source. */
21
- export declare const componentShellPath: string;
22
- /** Identifies the recursive Component capsule shared by generated Taro component shells. */
23
- export declare const componentCapsulePath: string;
24
- /** Forces Taro's CustomWrapper native shell to emit at its configured root path. */
25
- export declare const customWrapperShellFileName = "custom-wrapper.js";
26
- /** Identifies the synchronous CustomWrapper shell source. */
27
- export declare const customWrapperShellPath: string;
28
- /** Resolves the configured Page component from its route-qualified capsule importer. */
29
- export declare const pageComponentId = "\0vpt:page-component";
30
- /** Gives every Page shell one private capsule target that can be resolved using its route. */
31
- export declare const pageCapsuleId = "\0vpt:page-capsule";
32
- /** Provides the Page capsule source specialized through a stable route query. */
33
- export declare const pageCapsulePath: string;
34
- /** Identifies the Taro facade shared by the App, Page, and generated component capsules. */
35
- export declare const taroRuntimePath: string;
36
- /** Identifies the reusable synchronous native Page shell source. */
37
- export declare const pageShellPath: string;
38
- export type WxChunk = Rolldown.PreRenderedChunk | Rolldown.RenderedChunk;
39
- /** Build-graph role of an explicit native lifecycle entry. */
40
- export type WxEntryRole = 'shell' | 'capsule';
41
- /** Runtime domain in which one final wx JavaScript chunk executes. */
42
- export type WxExecutionKind = 'native' | 'capsule' | 'amphibious';
43
- /** Returns the one explicit lifecycle role owned by a chunk. */
44
- export declare function getWxEntryRole(chunk: WxChunk): WxEntryRole | undefined;
45
- /** Tests whether a chunk contains the physical transport implementation. */
46
- export declare function isTransportModule(chunk: WxChunk): boolean;
47
- /**
48
- * Classifies one final output chunk by execution domain. Entry role is deliberately independent: explicit capsule entries
49
- * normally fall through to capsule rendering, but a capsule containing an amphibious runtime executes in both domains.
50
- */
51
- export declare function getWxExecutionKind(chunk: WxChunk): WxExecutionKind;
@@ -1,2 +0,0 @@
1
- /** Creates a Page-relative path to a file emitted at the wx output root. */
2
- export declare function toRootRelativePath(pagePath: string, rootFileName: string): string;
@@ -1,124 +0,0 @@
1
- import type { Rolldown } from 'vite';
2
- import type { VptOptions } from '../../../../options.ts';
3
- import { type GeneratedSubpackage } from '../placer/placement.ts';
4
- type NativeComponentRegistration = {
5
- name: string;
6
- componentPath: string;
7
- fields: readonly string[];
8
- };
9
- /** Creates every JSON, WXML, WXS, and Page WXSS asset owned by Taro's native rendering boundary. */
10
- export declare function createTemplateAssets({ bundle, options, subpackages, nativeComponents, isProduction }: {
11
- bundle: Rolldown.OutputBundle;
12
- options: VptOptions;
13
- subpackages: readonly GeneratedSubpackage[];
14
- nativeComponents: readonly NativeComponentRegistration[];
15
- isProduction: boolean;
16
- }): Rolldown.EmittedAsset[];
17
- /**
18
- * Adapts Taro's stock template builder to the WXML half of WX App wrapping without changing its recursive renderer.
19
- *
20
- * End-to-end contract
21
- * -------------------
22
- * React and Taro retain one in-memory ownership tree:
23
- *
24
- * App React root
25
- * -> App host records
26
- * -> vpt_page_outlet host at App {children}
27
- * -> independently scheduled Taro Page roots
28
- *
29
- * The patched WX document makes the singleton App host a TaroRootElement. App host mutations therefore batch under app.*
30
- * and fan out to every mounted native Page. Each Page root remains its own TaroRootElement and emits only page.*. The React
31
- * host renderer marks the outlet and its App ancestors with an ordinary compact `vo` prop after each commit, while patched
32
- * hydrate() stops at vpt_page_outlet. Page roots remain attached for React Context, lifecycle, events, removal, refs, effects,
33
- * and HMR without entering app data.
34
- *
35
- * Build-time output
36
- * -----------------
37
- * createTemplateAssets asks one builder for shared base.wxml, utils.wxs, comp.wxml, custom-wrapper.wxml, and each Page WXML.
38
- * This adapter specializes the products that own the native join:
39
- *
40
- * - shared base.wxml receives branch-local slot forwarding at comp boundaries plus vpt_fragment and vpt_page_outlet
41
- * template definitions;
42
- * - each Page WXML replaces Taro's root:root entry with one generic comp bound to app and one caller-owned taro_tmpl bound
43
- * to page as that component's default slot.
44
- *
45
- * utils.wxs remains Taro's normal compact-node dispatcher. comp.wxml and custom-wrapper.wxml retain Taro's generic compact
46
- * rendering contracts; their JSON companions register recursive boundaries and native components, while runtime configs
47
- * retain standard event dispatch. CustomWrapper keeps Taro's Page-local ownership model and is not made slot-transparent
48
- * for App wrapping.
49
- * There is one shared template namespace, no Page-specific base file, no App/Page mode property, and no Page object threaded
50
- * through App template data.
51
- *
52
- * First native Page
53
- * -----------------
54
- * createPageConfig starts the native Page with:
55
- *
56
- * app = { nn: 'vpt_fragment', cn: [] }
57
- * page = { cn: [] }
58
- *
59
- * nn lets unchanged comp dispatch one input object even though App JSX may produce one or many root hosts. The record
60
- * is WXML-only rather than a Taro host, so it needs no sid. After React commits the Page root below the outlet, the framework
61
- * queues a lazy hydrate(AppRoot).cn value beside the Page root's already-pending page.* payloads. Taro drains both through the
62
- * native Page's existing first setData, making App wrapping and Page content appear atomically.
63
- *
64
- * Native WXML execution
65
- * ---------------------
66
- * Data/slot ownership and named-template ownership intentionally travel through different scopes:
67
- *
68
- * Page WXML (owns app, page, Page eh, and Page-content light DOM)
69
- * -> <comp i="{{app}}"> (crosses into a virtual custom-component scope)
70
- * -> comp.wxml (owns App eh, imports unchanged utils.wxs and shared base.wxml)
71
- * -> tmpl_0_vpt_fragment (iterates the real App compact roots in app.cn)
72
- * -> stock Taro templates (render App hosts and recurse through their cn arrays)
73
- * -> native recursion boundary <comp ...>
74
- * -> forwards <slot /> only when this compact subtree root has i.vo
75
- * -> tmpl_0_vpt_page_outlet at React's exact {children} position
76
- * -> <slot />
77
- * -> caller-owned <template is="taro_tmpl" data="{{root:page}}" />
78
- * -> stock Taro templates render this native Page's page.cn records
79
- *
80
- * The virtual comp and both private templates add no native layout node. `vo` is part of the existing compact node i, not a
81
- * component property or template context. App events execute through comp.eh; slotted Page events retain the native Page's
82
- * eh. Both resolve the original Taro sid through the same event source.
83
- *
84
- * Named-template scope
85
- * --------------------
86
- * Slots transfer caller-owned light DOM only. They do not transfer the caller's named-template table or WXS modules. App
87
- * dispatch runs inside comp.wxml, so vpt_fragment and vpt_page_outlet must live in base.wxml imported by that component.
88
- * Putting those definitions in buildPageTemplate produces Page WXML that compiles, but component runtime dispatch fails with
89
- * `Template tmpl_0_vpt_fragment not found`. Shared base.wxml makes the names visible in the root and every recursive
90
- * component scope and emits them once rather than once per Page.
91
- *
92
- * Projection-spine ownership
93
- * --------------------------
94
- * React's host renderer runs after the final commit tree exists and caches the outlet-to-root Taro host ancestor array. It
95
- * skips the unchanged root-side suffix, gives old leaf-side nodes the ordinary host prop vo=false, and gives new ones vo=true.
96
- * Taro's existing lazy structural hydration runs later and therefore serializes those props without projection-specific
97
- * scheduler or hydrate behavior. If React replaces the outlet host while moving it, the renderer finds the unique new marker
98
- * once and caches its new ancestor array. At each depth-reset comp boundary, i.vo makes forwarding an O(1) local decision;
99
- * WXML never searches descendants, and Page trees instantiate no unnamed slot.
100
- *
101
- * Steady-state updates and navigation
102
- * -----------------------------------
103
- * A page.* setData updates only the caller-owned Page template inside the slot. app is not passed through that template and
104
- * comp.i does not change, so Page updates cannot invalidate App recursion. Ordinary app.* payloads and outlet-spine marker
105
- * changes remain in Taro's granular batch before it fans out to every retained native Page. Adding or removing a React Page
106
- * root mutates the outlet only in memory, and the runtime suppresses that marker's native child update. A newly pushed Page
107
- * receives the latest complete App snapshot in its initial batch, while existing and hidden Pages require no navigation
108
- * synchronization.
109
- *
110
- * Method responsibilities
111
- * -----------------------
112
- * 1. buildBaseTemplate preserves stock host templates, makes each depth-reset comp boundary slot-transparent through i.vo,
113
- * and adds the two private definitions to the shared namespace.
114
- * 2. buildPageTemplate owns only the Page boundary: app binding, page binding, and the single Page-content slot.
115
- * 3. buildXScript delegates unchanged because routing metadata already travels inside compact node i.
116
- * 4. buildBaseComponentTemplate delegates unchanged so recursive comp remains generic and feature-independent.
117
- * 5. buildCustomComponentTemplate delegates unchanged so CustomWrapper renders compact children in its own native scope.
118
- *
119
- * H5 never calls this WX output builder. Its App continues to receive ordinary Fragment children and none of these native
120
- * data roots, templates, custom-component boundaries, or slot rules enter the browser build.
121
- */
122
- /** Replaces one pinned Taro fragment and rejects absent or duplicated upstream contracts. */
123
- export declare function replaceExactlyOnce(source: string, current: string, replacement: string, description: string): string;
124
- export {};
@@ -1,18 +0,0 @@
1
- // App and Page shells activate independently; make Current.app initialization an explicit prerequisite for Page mount.
2
- import './app.js';
3
- // @ts-expect-error: The wx build replaces this private import with the configured Page component.
4
- import PageComponent from '\0vpt:page-component';
5
- import { createPageConfig } from './taro-runtime.js';
6
- /*
7
- * Generated Page WXML invokes Taro's unchanged recursive comp, whose input contract is one compact node selected by i.nn.
8
- * App JSX does not have that cardinality: it may return one or many top-level hosts, and the private Page outlet may
9
- * occur at any depth within them. vpt_fragment is therefore a WXML-only collection adapter. Its fixed nn selects a
10
- * transparent template that iterates cn while one surrounding comp owns the Page's default slot. Runtime projection markers
11
- * relay that slot only through the App branch containing the outlet. Without the fragment, Page WXML would need one comp—and
12
- * one potential copy of the Page slot—for every App root, or comp would need an App-specific collection mode.
13
- *
14
- * This record is not a Taro host: it has no Fiber, event source, ref, lifecycle, native element, or keyed parent collection.
15
- * It consequently needs no sid. Only cn is seeded and updated; nn remains the stable generic-template discriminator.
16
- */
17
- const config = createPageConfig(PageComponent, __VPT_PAGE_PATH__, { app: { nn: 'vpt_fragment', cn: [] }, page: { cn: [] } }, __VPT_PAGE_CONFIG__);
18
- export default config;
@@ -1 +0,0 @@
1
- export const interpreterServerEvent = 'vpt:wx-interpreter:source';
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes