vite-plugin-taro 0.5.13 → 0.5.16
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/dist/node/plugins/client/client-taro.d.ts +1 -1
- package/dist/node/plugins/client/client-taro.js +2 -1
- package/dist/node/plugins/h5/create-stencil-client-adapter.d.ts +1 -1
- package/dist/node/plugins/h5/create-stencil-client-adapter.js +2 -1
- package/dist/node/plugins/h5/resolver/module-resolver.js +2 -1
- package/dist/node/plugins/wx/dev/create-hmr-results-stream.d.ts +23 -0
- package/dist/node/plugins/wx/dev/create-hmr-results-stream.js +57 -0
- package/dist/node/plugins/wx/dev/create-style-capture.d.ts +54 -0
- package/dist/node/plugins/wx/dev/create-style-capture.js +173 -0
- package/dist/node/plugins/wx/dev/dev-host.d.ts +1 -1
- package/dist/node/plugins/wx/dev/dev-host.js +161 -93
- package/dist/node/plugins/wx/dev/hmr-files.d.ts +1 -0
- package/dist/node/plugins/wx/dev/hmr-files.js +1 -0
- package/dist/node/plugins/wx/dev/host-actions.d.ts +16 -0
- package/dist/node/plugins/wx/dev/host-actions.js +58 -0
- package/dist/node/plugins/wx/dev/patch-publisher.d.ts +2 -2
- package/dist/node/plugins/wx/dev/patch-publisher.js +17 -1
- package/dist/node/plugins/wx/dev/plugins.d.ts +4 -0
- package/dist/node/plugins/wx/dev/plugins.js +24 -8
- package/dist/node/plugins/wx/dev/react-refresh.js +6 -2
- package/dist/node/plugins/wx/dev/runtime-reports.d.ts +27 -0
- package/dist/node/plugins/wx/dev/runtime-reports.js +45 -0
- package/dist/node/plugins/wx/dev/wx-dev-options.d.ts +7 -3
- package/dist/node/plugins/wx/dev/wx-dev-options.js +46 -28
- package/dist/node/plugins/wx/module.d.ts +1 -1
- package/dist/node/plugins/wx/module.js +2 -1
- package/dist/node/plugins/wx/native/compile-native-component-interface.js +2 -1
- package/dist/node/plugins/wx/native/create-native-component-output.js +2 -0
- package/dist/node/plugins/wx/native/native-component-assets.d.ts +1 -1
- package/dist/node/plugins/wx/native/native-component-assets.js +3 -3
- package/dist/node/plugins/wx/native/native-component-interface.js +2 -1
- package/dist/node/plugins/wx/resolve/resolver.js +3 -2
- package/dist/node/plugins/wx/styles/plugins.js +20 -1
- package/dist/node/utils/modules.d.ts +1 -1
- package/dist/node/utils/modules.js +4 -3
- package/dist/node/utils/packages.js +2 -2
- package/package.json +4 -3
- package/src/node/plugins/client/client-taro.ts +2 -2
- package/src/node/plugins/h5/create-stencil-client-adapter.ts +2 -2
- package/src/node/plugins/h5/resolver/module-resolver.ts +2 -1
- package/src/node/plugins/wx/dev/create-hmr-results-stream.ts +71 -0
- package/src/node/plugins/wx/dev/create-style-capture.ts +248 -0
- package/src/node/plugins/wx/dev/dev-host.ts +188 -124
- package/src/node/plugins/wx/dev/hmr-files.ts +1 -0
- package/src/node/plugins/wx/dev/host-actions.ts +88 -0
- package/src/node/plugins/wx/dev/patch-publisher.ts +19 -2
- package/src/node/plugins/wx/dev/plugins.ts +25 -8
- package/src/node/plugins/wx/dev/react-refresh.ts +6 -2
- package/src/node/plugins/wx/dev/runtime-reports.ts +70 -0
- package/src/node/plugins/wx/dev/wx-dev-options.ts +50 -36
- package/src/node/plugins/wx/module.ts +2 -4
- package/src/node/plugins/wx/native/compile-native-component-interface.ts +2 -1
- package/src/node/plugins/wx/native/create-native-component-output.ts +2 -0
- package/src/node/plugins/wx/native/native-component-assets.ts +3 -4
- package/src/node/plugins/wx/native/native-component-interface.ts +2 -1
- package/src/node/plugins/wx/resolve/resolver.ts +3 -2
- package/src/node/plugins/wx/styles/plugins.ts +21 -1
- package/src/node/utils/modules.ts +4 -3
- package/src/node/utils/packages.ts +2 -2
- package/dist/node/plugins/wx/dev/create-wx-dev-mode.d.ts +0 -6
- package/dist/node/plugins/wx/dev/create-wx-dev-mode.js +0 -9
- package/dist/node/plugins/wx/dev/styles/create-style-capture-plugin.d.ts +0 -12
- package/dist/node/plugins/wx/dev/styles/create-style-capture-plugin.js +0 -21
- package/dist/node/plugins/wx/dev/styles/publish-style-hmr.d.ts +0 -27
- package/dist/node/plugins/wx/dev/styles/publish-style-hmr.js +0 -48
- package/dist/node/utils/serialized-task-queue.d.ts +0 -13
- package/dist/node/utils/serialized-task-queue.js +0 -25
- package/src/node/plugins/wx/dev/create-wx-dev-mode.ts +0 -14
- package/src/node/plugins/wx/dev/styles/create-style-capture-plugin.ts +0 -34
- package/src/node/plugins/wx/dev/styles/publish-style-hmr.ts +0 -71
- package/src/node/utils/serialized-task-queue.ts +0 -32
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/** Runs asynchronous tasks in insertion order without letting one failure block later work. */
|
|
2
|
-
export class SerializedTaskQueue {
|
|
3
|
-
/** Mutable promise tail confines ordering state to this queue. */
|
|
4
|
-
tail = Promise.resolve();
|
|
5
|
-
reportError;
|
|
6
|
-
constructor(reportError) {
|
|
7
|
-
this.reportError = reportError;
|
|
8
|
-
}
|
|
9
|
-
/** Schedules a background task and reports its failure. */
|
|
10
|
-
enqueue(operation, task) {
|
|
11
|
-
void this.run(task).catch((error) => {
|
|
12
|
-
this.reportError(operation, error);
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
/** Schedules a task whose result and failure belong to the caller. */
|
|
16
|
-
run(task) {
|
|
17
|
-
const result = this.tail.then(task);
|
|
18
|
-
this.tail = result.then(() => undefined, () => undefined);
|
|
19
|
-
return result;
|
|
20
|
-
}
|
|
21
|
-
/** Waits for every task that was queued when this method was called. */
|
|
22
|
-
async waitForIdle() {
|
|
23
|
-
await this.tail;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { InputOptions } from 'rolldown'
|
|
2
|
-
|
|
3
|
-
type DevMode = NonNullable<NonNullable<InputOptions['experimental']>['devMode']>
|
|
4
|
-
type DevModeOptions = Exclude<DevMode, boolean>
|
|
5
|
-
|
|
6
|
-
/** Installs the custom WX runtime while restoring Rolldown's common runtime base. */
|
|
7
|
-
export function createWxDevMode(devMode: DevMode | undefined, implement: string): DevModeOptions {
|
|
8
|
-
return {
|
|
9
|
-
...(typeof devMode === 'object' ? devMode : {}),
|
|
10
|
-
implement,
|
|
11
|
-
lazy: false,
|
|
12
|
-
skipCommonRuntimeInjection: false
|
|
13
|
-
}
|
|
14
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { GetModuleInfo, Plugin } from 'rolldown'
|
|
2
|
-
import { normalizeModuleId } from '../../../../utils/modules.ts'
|
|
3
|
-
import { extractViteCss, isGlobalStyleRequest } from '../../styles/utils.ts'
|
|
4
|
-
|
|
5
|
-
export type ProcessedStyle = Readonly<{
|
|
6
|
-
css: string
|
|
7
|
-
isTailwindRoot: boolean
|
|
8
|
-
}>
|
|
9
|
-
|
|
10
|
-
type StyleCaptureOptions = Readonly<{
|
|
11
|
-
captureGraph: (getModuleInfo: GetModuleInfo) => void
|
|
12
|
-
captureStyle: (id: string, style: ProcessedStyle) => void
|
|
13
|
-
}>
|
|
14
|
-
|
|
15
|
-
/** Captures Vite's final development CSS and Rolldown's live graph without running the style pipeline twice. */
|
|
16
|
-
export function createStyleCapturePlugin({ captureGraph, captureStyle }: StyleCaptureOptions): Plugin {
|
|
17
|
-
return {
|
|
18
|
-
name: 'vpt:wx-dev-style-capture',
|
|
19
|
-
buildStart() {
|
|
20
|
-
captureGraph((moduleId) => this.getModuleInfo(moduleId))
|
|
21
|
-
},
|
|
22
|
-
transform(code, id) {
|
|
23
|
-
if (!isGlobalStyleRequest(id)) {
|
|
24
|
-
return
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const css = extractViteCss(code, id)
|
|
28
|
-
captureStyle(normalizeModuleId(id), {
|
|
29
|
-
css: css,
|
|
30
|
-
isTailwindRoot: css.includes('weapp-tailwindcss vite-generated-css:')
|
|
31
|
-
})
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { transformWxStyle } from '../../styles/transform-wx-style.ts'
|
|
2
|
-
import { composeGraphStyleCss, createTailwindSidecarId, extractViteCss } from '../../styles/utils.ts'
|
|
3
|
-
import { writeHmrFile } from '../hmr-files.ts'
|
|
4
|
-
import type { ProcessedStyle } from './create-style-capture-plugin.ts'
|
|
5
|
-
|
|
6
|
-
export const globalWxssFileName = 'assets/global.wxss'
|
|
7
|
-
|
|
8
|
-
type StyleHmrOptions = Readonly<{
|
|
9
|
-
styleIds: readonly string[]
|
|
10
|
-
outDir: string
|
|
11
|
-
processedStyles: ReadonlyMap<string, ProcessedStyle>
|
|
12
|
-
publishedWxss: string | undefined
|
|
13
|
-
}>
|
|
14
|
-
|
|
15
|
-
/** Regenerates reachable Tailwind roots concurrently from upstream's current candidate state. */
|
|
16
|
-
export async function refreshTailwindStyles(
|
|
17
|
-
styleIds: readonly string[],
|
|
18
|
-
processedStyles: Map<string, ProcessedStyle>,
|
|
19
|
-
transformRoot: (rootId: string, requestId: string) => Promise<Readonly<{ code: string }> | null>
|
|
20
|
-
): Promise<void> {
|
|
21
|
-
const roots = styleIds.filter((styleId) => requireProcessedStyle(processedStyles, styleId).isTailwindRoot)
|
|
22
|
-
const refreshedStyles = await Promise.all(
|
|
23
|
-
roots.map(async (rootId) => {
|
|
24
|
-
const requestId = createTailwindSidecarId(rootId)
|
|
25
|
-
const result = await transformRoot(rootId, requestId)
|
|
26
|
-
if (!result) {
|
|
27
|
-
throw new Error(`Tailwind sidecar transform produced no result: ${requestId}`)
|
|
28
|
-
}
|
|
29
|
-
return [rootId, { css: extractViteCss(result.code, requestId), isTailwindRoot: true }] as const
|
|
30
|
-
})
|
|
31
|
-
)
|
|
32
|
-
// Commit the cache generation only after every independent root succeeds; a failed sibling cannot leave a mixed snapshot.
|
|
33
|
-
refreshedStyles.forEach(([rootId, style]) => {
|
|
34
|
-
processedStyles.set(rootId, style)
|
|
35
|
-
})
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Materializes one host-owned style snapshot for a completed HMR transaction.
|
|
40
|
-
*
|
|
41
|
-
* Rolldown owns topology but does not retain Vite's final CSS module payload, while `processedStyles` owns those payloads but
|
|
42
|
-
* deliberately retains no topology. The caller supplies the transaction's one ordered graph plan; both Tailwind refresh and
|
|
43
|
-
* this renderer consume that same snapshot, so sidecar generation cannot cause a second topology traversal.
|
|
44
|
-
*
|
|
45
|
-
* Ordinary CSS is never transformed again here: capture already observed it after Vite/PostCSS. The composed stylesheet alone
|
|
46
|
-
* receives the same final WX conversion as complete builds. Byte equality with the host's physical publication frontier skips
|
|
47
|
-
* an atomic rename that would otherwise notify DevTools despite no style change. The returned bytes advance that frontier only
|
|
48
|
-
* after any required write succeeds. The caller awaits this before exposing the corresponding JavaScript patch.
|
|
49
|
-
* Complexity is O(styles + CSS bytes), after the caller's O(V + E) plan traversal.
|
|
50
|
-
*/
|
|
51
|
-
export async function publishStyleHmr({
|
|
52
|
-
styleIds,
|
|
53
|
-
outDir,
|
|
54
|
-
processedStyles,
|
|
55
|
-
publishedWxss
|
|
56
|
-
}: StyleHmrOptions): Promise<string> {
|
|
57
|
-
const css = composeGraphStyleCss(styleIds, (styleId) => requireProcessedStyle(processedStyles, styleId).css)
|
|
58
|
-
const wxss = (await transformWxStyle(css)).css
|
|
59
|
-
if (wxss !== publishedWxss) {
|
|
60
|
-
await writeHmrFile(outDir, globalWxssFileName, wxss)
|
|
61
|
-
}
|
|
62
|
-
return wxss
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function requireProcessedStyle(processedStyles: ReadonlyMap<string, ProcessedStyle>, styleId: string): ProcessedStyle {
|
|
66
|
-
const style = processedStyles.get(styleId)
|
|
67
|
-
if (!style) {
|
|
68
|
-
throw new Error(`WX style plan references uncaptured CSS: ${styleId}`)
|
|
69
|
-
}
|
|
70
|
-
return style
|
|
71
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/** Runs asynchronous tasks in insertion order without letting one failure block later work. */
|
|
2
|
-
export class SerializedTaskQueue {
|
|
3
|
-
/** Mutable promise tail confines ordering state to this queue. */
|
|
4
|
-
private tail: Promise<void> = Promise.resolve()
|
|
5
|
-
private readonly reportError: (operation: string, error: unknown) => void
|
|
6
|
-
|
|
7
|
-
constructor(reportError: (operation: string, error: unknown) => void) {
|
|
8
|
-
this.reportError = reportError
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/** Schedules a background task and reports its failure. */
|
|
12
|
-
enqueue(operation: string, task: () => void | PromiseLike<void>): void {
|
|
13
|
-
void this.run(task).catch((error) => {
|
|
14
|
-
this.reportError(operation, error)
|
|
15
|
-
})
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/** Schedules a task whose result and failure belong to the caller. */
|
|
19
|
-
run<Result>(task: () => Result | PromiseLike<Result>): Promise<Result> {
|
|
20
|
-
const result = this.tail.then(task)
|
|
21
|
-
this.tail = result.then(
|
|
22
|
-
() => undefined,
|
|
23
|
-
() => undefined
|
|
24
|
-
)
|
|
25
|
-
return result
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/** Waits for every task that was queued when this method was called. */
|
|
29
|
-
async waitForIdle(): Promise<void> {
|
|
30
|
-
await this.tail
|
|
31
|
-
}
|
|
32
|
-
}
|