template.d.ts 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import type { EmittedAsset } from 'rollup';
  2. import type { ElementNode } from '@vue/compiler-core';
  3. type LazyElementFn = (node: ElementNode, context: {
  4. isMiniProgramComponent(name: string): 'plugin' | 'component' | 'dynamicLib' | 'ext' | undefined;
  5. }) => {
  6. [name: string]: {
  7. name: 'on' | 'bind';
  8. arg: string[];
  9. }[] | true;
  10. } | boolean;
  11. export interface MiniProgramCompilerOptions {
  12. /**
  13. * 需要延迟渲染的组件,通常是某个组件的某个事件会立刻触发,需要延迟到首次 render 之后,比如微信 editor 的 ready 事件,快手 switch 的 change
  14. */
  15. lazyElement?: {
  16. [name: string]: {
  17. name: 'on' | 'bind';
  18. arg: string[];
  19. }[] | true;
  20. } | LazyElementFn;
  21. event?: {
  22. key?: boolean;
  23. format?(name: string, opts: {
  24. isCatch?: boolean;
  25. isCapture?: boolean;
  26. isComponent?: boolean;
  27. }): string;
  28. };
  29. class: {
  30. /**
  31. * 是否支持绑定 array 类型
  32. */
  33. array: boolean;
  34. };
  35. slot: {
  36. /**
  37. * 是否支持 $slots.default 访问
  38. */
  39. $slots?: boolean;
  40. /**
  41. * 是否支持后备内容
  42. */
  43. fallbackContent?: boolean;
  44. /**
  45. * 是否支持动态插槽名
  46. */
  47. dynamicSlotNames?: boolean;
  48. };
  49. filter?: {
  50. lang: string;
  51. };
  52. component?: {
  53. /**
  54. * 平台自定义组件目录,如 wxcomponents
  55. */
  56. dir?: string;
  57. /**
  58. * 自定义组件自定义 hidden 属性用于实现 v-show
  59. */
  60. vShow?: string;
  61. /**
  62. * 父组件 setData 后,子组件的 properties 是否可以同步获取,目前仅 mp-weixin,mp-qq,mp-alipay 支持
  63. */
  64. getPropertySync?: boolean;
  65. /**
  66. * 格式化组件名称,比如 wx-btn => weixin-btn (微信不允许以 wx 命名自定义组件)
  67. */
  68. normalizeName?: (name: string) => string;
  69. /**
  70. * 合并虚拟化节点属性(class、style)
  71. */
  72. mergeVirtualHostAttributes?: boolean;
  73. };
  74. directive: string;
  75. emitFile?: (emittedFile: EmittedAsset) => string;
  76. }
  77. export interface MiniProgramFilterOptions {
  78. id: string;
  79. type: string;
  80. name: string;
  81. src?: string;
  82. code: string;
  83. }
  84. type GenFilterFn = (filter: MiniProgramFilterOptions, filename: string) => string | void;
  85. export declare function findMiniProgramTemplateFiles(genFilter?: GenFilterFn): Record<string, string>;
  86. export declare function clearMiniProgramTemplateFiles(): void;
  87. export declare function addMiniProgramTemplateFile(filename: string, code: string): void;
  88. export declare function clearMiniProgramTemplateFilter(filename: string): void;
  89. export declare function addMiniProgramTemplateFilter(filename: string, filter: MiniProgramFilterOptions): void;
  90. export {};