@weapp-vite/web 1.5.6 → 2.0.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 (66) hide show
  1. package/README.md +22 -0
  2. package/dist/css/wxss.mjs +2 -1
  3. package/dist/css/wxss.mjs.map +1 -1
  4. package/dist/index.d.mts +2 -1
  5. package/dist/index.mjs +2 -1
  6. package/dist/plugin/hostTypes.d.mts +74 -0
  7. package/dist/plugin/index.d.mts +2 -74
  8. package/dist/plugin/index.mjs +9 -2
  9. package/dist/plugin/index.mjs.map +1 -1
  10. package/dist/plugin/sfcHmr.mjs +19 -0
  11. package/dist/plugin/sfcHmr.mjs.map +1 -0
  12. package/dist/plugin/vueSfc.mjs +12 -9
  13. package/dist/plugin/vueSfc.mjs.map +1 -1
  14. package/dist/runtime/appStyle.mjs +25 -0
  15. package/dist/runtime/appStyle.mjs.map +1 -0
  16. package/dist/runtime/component/element.mjs +39 -19
  17. package/dist/runtime/component/element.mjs.map +1 -1
  18. package/dist/runtime/component/events.mjs +34 -3
  19. package/dist/runtime/component/events.mjs.map +1 -1
  20. package/dist/runtime/component/publicInstance.mjs +7 -3
  21. package/dist/runtime/component/publicInstance.mjs.map +1 -1
  22. package/dist/runtime/component/state.mjs +7 -0
  23. package/dist/runtime/component/state.mjs.map +1 -1
  24. package/dist/runtime/component/types.d.mts +2 -0
  25. package/dist/runtime/component/utils.mjs +23 -3
  26. package/dist/runtime/component/utils.mjs.map +1 -1
  27. package/dist/runtime/componentEvents.mjs +37 -0
  28. package/dist/runtime/componentEvents.mjs.map +1 -0
  29. package/dist/runtime/eventBinding.mjs +5 -2
  30. package/dist/runtime/eventBinding.mjs.map +1 -1
  31. package/dist/runtime/index.d.mts +2 -1
  32. package/dist/runtime/index.mjs +2 -1
  33. package/dist/runtime/index.mjs.map +1 -1
  34. package/dist/runtime/legacyTemplate/dom.mjs +2 -7
  35. package/dist/runtime/legacyTemplate/dom.mjs.map +1 -1
  36. package/dist/runtime/nativeComponents/canvas/index.mjs +12 -3
  37. package/dist/runtime/nativeComponents/canvas/index.mjs.map +1 -1
  38. package/dist/runtime/polyfill/index.d.mts +2 -1
  39. package/dist/runtime/polyfill/index.mjs +15 -1
  40. package/dist/runtime/polyfill/index.mjs.map +1 -1
  41. package/dist/runtime/polyfill/routeRuntime/dom.mjs +5 -0
  42. package/dist/runtime/polyfill/routeRuntime/dom.mjs.map +1 -1
  43. package/dist/runtime/polyfill/routeRuntime/events.d.mts +29 -0
  44. package/dist/runtime/polyfill/routeRuntime/events.mjs +123 -0
  45. package/dist/runtime/polyfill/routeRuntime/events.mjs.map +1 -0
  46. package/dist/runtime/polyfill/routeRuntime/history.d.mts +3 -1
  47. package/dist/runtime/polyfill/routeRuntime/history.mjs +4 -1
  48. package/dist/runtime/polyfill/routeRuntime/history.mjs.map +1 -1
  49. package/dist/runtime/polyfill/routeRuntime/lifecycle.mjs +9 -0
  50. package/dist/runtime/polyfill/routeRuntime/lifecycle.mjs.map +1 -1
  51. package/dist/runtime/polyfill/routeRuntime/options.mjs.map +1 -1
  52. package/dist/runtime/polyfill/routeRuntime/scroll.mjs +20 -3
  53. package/dist/runtime/polyfill/routeRuntime/scroll.mjs.map +1 -1
  54. package/dist/runtime/polyfill/routeRuntime/stack.mjs +60 -19
  55. package/dist/runtime/polyfill/routeRuntime/stack.mjs.map +1 -1
  56. package/dist/runtime/polyfill/routeRuntime.d.mts +1 -1
  57. package/dist/runtime/polyfill/routeRuntime.mjs +32 -12
  58. package/dist/runtime/polyfill/routeRuntime.mjs.map +1 -1
  59. package/dist/runtime/polyfill.d.mts +2 -1
  60. package/dist/runtime/renderContext.mjs +3 -2
  61. package/dist/runtime/renderContext.mjs.map +1 -1
  62. package/dist/runtime/wevu.mjs +2 -0
  63. package/dist/runtime/wevu.mjs.map +1 -1
  64. package/dist/shared/wxml.mjs +5 -1
  65. package/dist/shared/wxml.mjs.map +1 -1
  66. package/package.json +14 -12
@@ -31,6 +31,11 @@ function createPropertyEntries(component) {
31
31
  function createObservedAttributes(propertyEntries) {
32
32
  return propertyEntries.map(([name]) => hyphenate(name));
33
33
  }
34
+ function inheritsAppStyle(kind, component) {
35
+ if (kind === "page") return true;
36
+ const { styleIsolation, addGlobalClass } = component.options ?? {};
37
+ return styleIsolation === void 0 ? Boolean(addGlobalClass) : styleIsolation !== "isolated";
38
+ }
34
39
  function createComponentRuntimeState(options) {
35
40
  const { component, warnings } = resolveNormalizedComponent(options.component ?? {});
36
41
  const propertyEntries = createPropertyEntries(component);
@@ -39,6 +44,7 @@ function createComponentRuntimeState(options) {
39
44
  id: options.id,
40
45
  templateRef: options.template,
41
46
  styleRef: options.style ?? "",
47
+ inheritAppStyle: inheritsAppStyle(options.kind, component),
42
48
  componentRef: component,
43
49
  observerInitEnabled: Boolean(options.observerInit),
44
50
  propertyEntries,
@@ -56,6 +62,7 @@ function updateComponentRuntimeState(state, options) {
56
62
  state.templateRef = options.template;
57
63
  state.id = options.id;
58
64
  state.styleRef = options.style ?? "";
65
+ state.inheritAppStyle = inheritsAppStyle(options.kind, component);
59
66
  state.componentRef = component;
60
67
  state.observerInitEnabled = Boolean(options.observerInit);
61
68
  state.lifetimes = component.lifetimes ?? {};
@@ -1 +1 @@
1
- {"version":3,"file":"state.mjs","names":[],"sources":["../../../src/runtime/component/state.ts"],"sourcesContent":["import type {\n ComponentOptions,\n DataRecord,\n DefineComponentOptions,\n LifeTimeHooks,\n NormalizedComponentOptions,\n PageLifeTimeHooks,\n PropertyDeclaration,\n PropertyOption,\n} from './types'\nimport { hasOwn } from '../utils/object'\nimport { normalizeBehaviors } from './behavior'\nimport { cloneValue, hyphenate } from './utils'\n\ntype PropertyEntry = [string, PropertyOption]\n\nexport interface ComponentRuntimeState {\n id?: string\n templateRef: DefineComponentOptions['template']\n styleRef: string\n componentRef: NormalizedComponentOptions\n observerInitEnabled: boolean\n propertyEntries: PropertyEntry[]\n observedAttributes: string[]\n defaultPropertyValues: DataRecord\n lifetimes: LifeTimeHooks\n pageLifetimes: PageLifeTimeHooks\n}\n\nfunction normalizePropertyDeclaration(declaration: PropertyDeclaration): PropertyOption {\n if (declaration === null || typeof declaration === 'function') {\n return { type: declaration }\n }\n return declaration\n}\n\nfunction resolveNormalizedComponent(component: ComponentOptions) {\n const normalized = normalizeBehaviors(component)\n const resolved = normalized.component!\n return {\n warnings: normalized.warnings,\n component: {\n ...resolved,\n properties: Object.fromEntries(\n Object.entries(resolved.properties ?? {}).map(([name, declaration]) => [\n name,\n normalizePropertyDeclaration(declaration),\n ]),\n ),\n } satisfies NormalizedComponentOptions,\n }\n}\n\nfunction createDefaultPropertyValues(propertyEntries: PropertyEntry[]) {\n return propertyEntries.reduce<DataRecord>((acc, [name, prop]) => {\n if (prop !== null && typeof prop === 'object' && hasOwn(prop, 'value')) {\n acc[name] = cloneValue(prop.value)\n }\n else {\n acc[name] = undefined\n }\n return acc\n }, {})\n}\n\nfunction createPropertyEntries(component: NormalizedComponentOptions): PropertyEntry[] {\n return Object.entries(component.properties)\n}\n\nfunction createObservedAttributes(propertyEntries: PropertyEntry[]) {\n return propertyEntries.map(([name]) => hyphenate(name))\n}\n\nexport function createComponentRuntimeState(options: DefineComponentOptions) {\n const { component, warnings } = resolveNormalizedComponent(options.component ?? {})\n const propertyEntries = createPropertyEntries(component)\n const state: ComponentRuntimeState = {\n id: options.id,\n templateRef: options.template,\n styleRef: options.style ?? '',\n componentRef: component,\n observerInitEnabled: Boolean(options.observerInit),\n propertyEntries,\n observedAttributes: createObservedAttributes(propertyEntries),\n defaultPropertyValues: createDefaultPropertyValues(propertyEntries),\n lifetimes: component.lifetimes ?? {},\n pageLifetimes: component.pageLifetimes ?? {},\n }\n return {\n state,\n warnings,\n }\n}\n\nexport function updateComponentRuntimeState(state: ComponentRuntimeState, options: DefineComponentOptions) {\n const { component, warnings } = resolveNormalizedComponent(options.component ?? {})\n const propertyEntries = createPropertyEntries(component)\n state.templateRef = options.template\n state.id = options.id\n state.styleRef = options.style ?? ''\n state.componentRef = component\n state.observerInitEnabled = Boolean(options.observerInit)\n state.lifetimes = component.lifetimes ?? {}\n state.pageLifetimes = component.pageLifetimes ?? {}\n state.propertyEntries = propertyEntries\n state.observedAttributes = createObservedAttributes(propertyEntries)\n state.defaultPropertyValues = createDefaultPropertyValues(propertyEntries)\n return {\n warnings,\n nextMethods: component.methods ?? {},\n }\n}\n"],"mappings":";;;;;AA6BA,SAAS,6BAA6B,aAAkD;CACtF,IAAI,gBAAgB,QAAQ,OAAO,gBAAgB,YACjD,OAAO,EAAE,MAAM,YAAY;CAE7B,OAAO;AACT;AAEA,SAAS,2BAA2B,WAA6B;CAC/D,MAAM,aAAa,mBAAmB,SAAS;CAC/C,MAAM,WAAW,WAAW;CAC5B,OAAO;EACL,UAAU,WAAW;EACrB,WAAW;GACT,GAAG;GACH,YAAY,OAAO,YACjB,OAAO,QAAQ,SAAS,cAAc,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,iBAAiB,CACrE,MACA,6BAA6B,WAAW,CAC1C,CAAC,CACH;EACF;CACF;AACF;AAEA,SAAS,4BAA4B,iBAAkC;CACrE,OAAO,gBAAgB,QAAoB,KAAK,CAAC,MAAM,UAAU;EAC/D,IAAI,SAAS,QAAQ,OAAO,SAAS,YAAY,OAAO,MAAM,OAAO,GACnE,IAAI,QAAQ,WAAW,KAAK,KAAK;OAGjC,IAAI,QAAQ;EAEd,OAAO;CACT,GAAG,CAAC,CAAC;AACP;AAEA,SAAS,sBAAsB,WAAwD;CACrF,OAAO,OAAO,QAAQ,UAAU,UAAU;AAC5C;AAEA,SAAS,yBAAyB,iBAAkC;CAClE,OAAO,gBAAgB,KAAK,CAAC,UAAU,UAAU,IAAI,CAAC;AACxD;AAEA,SAAgB,4BAA4B,SAAiC;CAC3E,MAAM,EAAE,WAAW,aAAa,2BAA2B,QAAQ,aAAa,CAAC,CAAC;CAClF,MAAM,kBAAkB,sBAAsB,SAAS;CAavD,OAAO;EACL;GAZA,IAAI,QAAQ;GACZ,aAAa,QAAQ;GACrB,UAAU,QAAQ,SAAS;GAC3B,cAAc;GACd,qBAAqB,QAAQ,QAAQ,YAAY;GACjD;GACA,oBAAoB,yBAAyB,eAAe;GAC5D,uBAAuB,4BAA4B,eAAe;GAClE,WAAW,UAAU,aAAa,CAAC;GACnC,eAAe,UAAU,iBAAiB,CAAC;EAGvC;EACJ;CACF;AACF;AAEA,SAAgB,4BAA4B,OAA8B,SAAiC;CACzG,MAAM,EAAE,WAAW,aAAa,2BAA2B,QAAQ,aAAa,CAAC,CAAC;CAClF,MAAM,kBAAkB,sBAAsB,SAAS;CACvD,MAAM,cAAc,QAAQ;CAC5B,MAAM,KAAK,QAAQ;CACnB,MAAM,WAAW,QAAQ,SAAS;CAClC,MAAM,eAAe;CACrB,MAAM,sBAAsB,QAAQ,QAAQ,YAAY;CACxD,MAAM,YAAY,UAAU,aAAa,CAAC;CAC1C,MAAM,gBAAgB,UAAU,iBAAiB,CAAC;CAClD,MAAM,kBAAkB;CACxB,MAAM,qBAAqB,yBAAyB,eAAe;CACnE,MAAM,wBAAwB,4BAA4B,eAAe;CACzE,OAAO;EACL;EACA,aAAa,UAAU,WAAW,CAAC;CACrC;AACF"}
1
+ {"version":3,"file":"state.mjs","names":[],"sources":["../../../src/runtime/component/state.ts"],"sourcesContent":["import type {\n ComponentOptions,\n DataRecord,\n DefineComponentOptions,\n LifeTimeHooks,\n NormalizedComponentOptions,\n PageLifeTimeHooks,\n PropertyDeclaration,\n PropertyOption,\n} from './types'\nimport { hasOwn } from '../utils/object'\nimport { normalizeBehaviors } from './behavior'\nimport { cloneValue, hyphenate } from './utils'\n\ntype PropertyEntry = [string, PropertyOption]\n\nexport interface ComponentRuntimeState {\n id?: string\n templateRef: DefineComponentOptions['template']\n styleRef: string\n inheritAppStyle: boolean\n componentRef: NormalizedComponentOptions\n observerInitEnabled: boolean\n propertyEntries: PropertyEntry[]\n observedAttributes: string[]\n defaultPropertyValues: DataRecord\n lifetimes: LifeTimeHooks\n pageLifetimes: PageLifeTimeHooks\n}\n\nfunction normalizePropertyDeclaration(declaration: PropertyDeclaration): PropertyOption {\n if (declaration === null || typeof declaration === 'function') {\n return { type: declaration }\n }\n return declaration\n}\n\nfunction resolveNormalizedComponent(component: ComponentOptions) {\n const normalized = normalizeBehaviors(component)\n const resolved = normalized.component!\n return {\n warnings: normalized.warnings,\n component: {\n ...resolved,\n properties: Object.fromEntries(\n Object.entries(resolved.properties ?? {}).map(([name, declaration]) => [\n name,\n normalizePropertyDeclaration(declaration),\n ]),\n ),\n } satisfies NormalizedComponentOptions,\n }\n}\n\nfunction createDefaultPropertyValues(propertyEntries: PropertyEntry[]) {\n return propertyEntries.reduce<DataRecord>((acc, [name, prop]) => {\n if (prop !== null && typeof prop === 'object' && hasOwn(prop, 'value')) {\n acc[name] = cloneValue(prop.value)\n }\n else {\n acc[name] = undefined\n }\n return acc\n }, {})\n}\n\nfunction createPropertyEntries(component: NormalizedComponentOptions): PropertyEntry[] {\n return Object.entries(component.properties)\n}\n\nfunction createObservedAttributes(propertyEntries: PropertyEntry[]) {\n return propertyEntries.map(([name]) => hyphenate(name))\n}\n\nfunction inheritsAppStyle(kind: DefineComponentOptions['kind'], component: NormalizedComponentOptions) {\n if (kind === 'page') {\n return true\n }\n const { styleIsolation, addGlobalClass } = component.options ?? {}\n return styleIsolation === undefined ? Boolean(addGlobalClass) : styleIsolation !== 'isolated'\n}\n\nexport function createComponentRuntimeState(options: DefineComponentOptions) {\n const { component, warnings } = resolveNormalizedComponent(options.component ?? {})\n const propertyEntries = createPropertyEntries(component)\n const state: ComponentRuntimeState = {\n id: options.id,\n templateRef: options.template,\n styleRef: options.style ?? '',\n inheritAppStyle: inheritsAppStyle(options.kind, component),\n componentRef: component,\n observerInitEnabled: Boolean(options.observerInit),\n propertyEntries,\n observedAttributes: createObservedAttributes(propertyEntries),\n defaultPropertyValues: createDefaultPropertyValues(propertyEntries),\n lifetimes: component.lifetimes ?? {},\n pageLifetimes: component.pageLifetimes ?? {},\n }\n return {\n state,\n warnings,\n }\n}\n\nexport function updateComponentRuntimeState(state: ComponentRuntimeState, options: DefineComponentOptions) {\n const { component, warnings } = resolveNormalizedComponent(options.component ?? {})\n const propertyEntries = createPropertyEntries(component)\n state.templateRef = options.template\n state.id = options.id\n state.styleRef = options.style ?? ''\n state.inheritAppStyle = inheritsAppStyle(options.kind, component)\n state.componentRef = component\n state.observerInitEnabled = Boolean(options.observerInit)\n state.lifetimes = component.lifetimes ?? {}\n state.pageLifetimes = component.pageLifetimes ?? {}\n state.propertyEntries = propertyEntries\n state.observedAttributes = createObservedAttributes(propertyEntries)\n state.defaultPropertyValues = createDefaultPropertyValues(propertyEntries)\n return {\n warnings,\n nextMethods: component.methods ?? {},\n }\n}\n"],"mappings":";;;;;AA8BA,SAAS,6BAA6B,aAAkD;CACtF,IAAI,gBAAgB,QAAQ,OAAO,gBAAgB,YACjD,OAAO,EAAE,MAAM,YAAY;CAE7B,OAAO;AACT;AAEA,SAAS,2BAA2B,WAA6B;CAC/D,MAAM,aAAa,mBAAmB,SAAS;CAC/C,MAAM,WAAW,WAAW;CAC5B,OAAO;EACL,UAAU,WAAW;EACrB,WAAW;GACT,GAAG;GACH,YAAY,OAAO,YACjB,OAAO,QAAQ,SAAS,cAAc,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,iBAAiB,CACrE,MACA,6BAA6B,WAAW,CAC1C,CAAC,CACH;EACF;CACF;AACF;AAEA,SAAS,4BAA4B,iBAAkC;CACrE,OAAO,gBAAgB,QAAoB,KAAK,CAAC,MAAM,UAAU;EAC/D,IAAI,SAAS,QAAQ,OAAO,SAAS,YAAY,OAAO,MAAM,OAAO,GACnE,IAAI,QAAQ,WAAW,KAAK,KAAK;OAGjC,IAAI,QAAQ;EAEd,OAAO;CACT,GAAG,CAAC,CAAC;AACP;AAEA,SAAS,sBAAsB,WAAwD;CACrF,OAAO,OAAO,QAAQ,UAAU,UAAU;AAC5C;AAEA,SAAS,yBAAyB,iBAA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rC;AACF"}
@@ -45,6 +45,8 @@ export interface ComponentOptions {
45
45
  }
46
46
  export interface DefineComponentOptions {
47
47
  id?: string;
48
+ /** 注册层提供的样式域;组件仍按 styleIsolation 决定是否接收应用样式。 */
49
+ kind?: 'page' | 'component';
48
50
  template: TemplateRenderer;
49
51
  style?: string;
50
52
  component?: ComponentOptions;
@@ -17,6 +17,19 @@ function cloneValue(value) {
17
17
  if (value && typeof value === "object") return { ...value };
18
18
  return value;
19
19
  }
20
+ function cloneCommittedValue(value, snapshots = /* @__PURE__ */ new WeakMap()) {
21
+ if (value === null || typeof value !== "object") return value;
22
+ if (!Array.isArray(value)) {
23
+ const prototype = Object.getPrototypeOf(value);
24
+ if (prototype !== Object.prototype && prototype !== null) return value;
25
+ }
26
+ const existing = snapshots.get(value);
27
+ if (existing) return existing;
28
+ const snapshot = cloneValue(value);
29
+ snapshots.set(value, snapshot);
30
+ for (const key of Object.keys(snapshot)) snapshot[key] = cloneCommittedValue(snapshot[key], snapshots);
31
+ return snapshot;
32
+ }
20
33
  function parseDataPath(path) {
21
34
  return path.replace(ARRAY_INDEX_PATH_RE, ".$1").split(".").map((segment) => segment.trim()).filter((segment) => segment && !UNSAFE_PATH_SEGMENTS.has(segment));
22
35
  }
@@ -34,13 +47,20 @@ function resolveDataPath(target, segments) {
34
47
  }
35
48
  return current;
36
49
  }
37
- function assignDataPath(target, segments, value) {
50
+ function assignDataPath(target, segments, value, copiedContainers) {
38
51
  if (!segments.length) return;
39
52
  let current = target;
40
53
  for (let index = 0; index < segments.length - 1; index += 1) {
41
54
  const segment = normalizePathSegment(segments[index]);
42
55
  const nextSegment = segments[index + 1];
43
- if (current[segment] == null || typeof current[segment] !== "object") current[segment] = createPathContainer(nextSegment);
56
+ const next = current[segment];
57
+ if (next == null || typeof next !== "object") {
58
+ current[segment] = createPathContainer(nextSegment);
59
+ copiedContainers?.add(current[segment]);
60
+ } else if (!copiedContainers?.has(next)) {
61
+ current[segment] = cloneValue(next);
62
+ copiedContainers?.add(current[segment]);
63
+ }
44
64
  current = current[segment];
45
65
  }
46
66
  current[normalizePathSegment(segments[segments.length - 1])] = value;
@@ -70,5 +90,5 @@ function coerceValue(value, type) {
70
90
  }
71
91
 
72
92
  //#endregion
73
- export { assignDataPath, cloneValue, coerceValue, hyphenate, parseDataPath, resolveDataPath, toCamelCase };
93
+ export { assignDataPath, cloneCommittedValue, cloneValue, coerceValue, hyphenate, parseDataPath, resolveDataPath, toCamelCase };
74
94
  //# sourceMappingURL=utils.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.mjs","names":[],"sources":["../../../src/runtime/component/utils.ts"],"sourcesContent":["import type { PropertyOption } from './types'\n\nconst ARRAY_INDEX_PATH_RE = /\\[(\\d+)\\]/g\nconst ARRAY_INDEX_SEGMENT_RE = /^\\d+$/\nconst UNSAFE_PATH_SEGMENTS = new Set(['__proto__', 'constructor', 'prototype'])\n\nexport function hyphenate(name: string) {\n return name.replace(/([A-Z])/g, (_, char: string) => `-${char.toLowerCase()}`)\n}\n\nexport function toCamelCase(name: string) {\n return name.replace(/-([a-z])/g, (_, char: string) => char.toUpperCase())\n}\n\nexport function cloneValue(value: any) {\n if (Array.isArray(value)) {\n return value.slice()\n }\n if (value && typeof value === 'object') {\n return { ...value }\n }\n return value\n}\n\nexport function parseDataPath(path: string) {\n return path\n .replace(ARRAY_INDEX_PATH_RE, '.$1')\n .split('.')\n .map(segment => segment.trim())\n .filter(segment => segment && !UNSAFE_PATH_SEGMENTS.has(segment))\n}\n\nfunction normalizePathSegment(segment: string) {\n return ARRAY_INDEX_SEGMENT_RE.test(segment) ? Number(segment) : segment\n}\n\nfunction createPathContainer(nextSegment: string | undefined) {\n return nextSegment && ARRAY_INDEX_SEGMENT_RE.test(nextSegment) ? [] : {}\n}\n\nexport function resolveDataPath(target: Record<string, any>, segments: string[]) {\n let current: any = target\n for (const segment of segments) {\n if (current == null) {\n return undefined\n }\n current = current[normalizePathSegment(segment)]\n }\n return current\n}\n\nexport function assignDataPath(target: Record<string, any>, segments: string[], value: unknown) {\n if (!segments.length) {\n return\n }\n let current: any = target\n for (let index = 0; index < segments.length - 1; index += 1) {\n const segment = normalizePathSegment(segments[index]!)\n const nextSegment = segments[index + 1]\n if (current[segment] == null || typeof current[segment] !== 'object') {\n current[segment] = createPathContainer(nextSegment)\n }\n current = current[segment]\n }\n current[normalizePathSegment(segments[segments.length - 1]!)] = value\n}\n\nexport function coerceValue(value: any, type?: PropertyOption['type']) {\n if (type === Boolean) {\n if (value === '' || value === true) {\n return true\n }\n if (value === undefined || value === null || value === false) {\n return false\n }\n if (typeof value === 'string') {\n return value !== 'false'\n }\n return Boolean(value)\n }\n\n if (type === Number) {\n if (value === undefined || value === null) {\n return value\n }\n const numeric = Number(value)\n return Number.isNaN(numeric) ? value : numeric\n }\n\n if (type === Object || type === Array) {\n if (value === undefined || value === null) {\n return value\n }\n if (typeof value === 'string') {\n try {\n return JSON.parse(value)\n }\n catch {\n return value\n }\n }\n return value\n }\n\n return value\n}\n"],"mappings":";AAEA,MAAM,sBAAsB;AAC5B,MAAM,yBAAyB;AAC/B,MAAM,uCAAuB,IAAI,IAAI;CAAC;CAAa;CAAe;AAAW,CAAC;AAE9E,SAAgB,UAAU,MAAc;CACtC,OAAO,KAAK,QAAQ,aAAa,GAAG,SAAiB,IAAI,KAAK,YAAY,GAAG;AAC/E;AAEA,SAAgB,YAAY,MAAc;CACxC,OAAO,KAAK,QAAQ,cAAc,GAAG,SAAiB,KAAK,YAAY,CAAC;AAC1E;AAEA,SAAgB,WAAW,OAAY;CACrC,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,MAAM,MAAM;CAErB,IAAI,SAAS,OAAO,UAAU,UAC5B,OAAO,EAAE,GAAG,MAAM;CAEpB,OAAO;AACT;AAEA,SAAgB,cAAc,MAAc;CAC1C,OAAO,KACJ,QAAQ,qBAAqB,KAAK,CAAC,CACnC,MAAM,GAAG,CAAC,CACV,KAAI,YAAW,QAAQ,KAAK,CAAC,C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EACrC,IAAI,UAAU,UAAa,UAAU,MACnC,OAAO;EAET,IAAI,OAAO,UAAU,UACnB,IAAI;GACF,OAAO,KAAK,MAAM,KAAK;EACzB,QACM;GACJ,OAAO;EACT;EAEF,OAAO;CACT;CAEA,OAAO;AACT"}
1
+ {"version":3,"file":"utils.mjs","names":[],"sources":["../../../src/runtime/component/utils.ts"],"sourcesContent":["import type { PropertyOption } from './types'\n\nconst ARRAY_INDEX_PATH_RE = /\\[(\\d+)\\]/g\nconst ARRAY_INDEX_SEGMENT_RE = /^\\d+$/\nconst UNSAFE_PATH_SEGMENTS = new Set(['__proto__', 'constructor', 'prototype'])\n\nexport function hyphenate(name: string) {\n return name.replace(/([A-Z])/g, (_, char: string) => `-${char.toLowerCase()}`)\n}\n\nexport function toCamelCase(name: string) {\n return name.replace(/-([a-z])/g, (_, char: string) => char.toUpperCase())\n}\n\nexport function cloneValue(value: any) {\n if (Array.isArray(value)) {\n return value.slice()\n }\n if (value && typeof value === 'object') {\n return { ...value }\n }\n return value\n}\n\nexport function cloneCommittedValue(value: unknown, snapshots = new WeakMap<object, Record<string, unknown>>()): unknown {\n if (value === null || typeof value !== 'object') {\n return value\n }\n if (!Array.isArray(value)) {\n const prototype = Object.getPrototypeOf(value)\n if (prototype !== Object.prototype && prototype !== null) {\n return value\n }\n }\n const existing = snapshots.get(value)\n if (existing) {\n return existing\n }\n const snapshot: Record<string, unknown> = cloneValue(value)\n snapshots.set(value, snapshot)\n for (const key of Object.keys(snapshot)) {\n snapshot[key] = cloneCommittedValue(snapshot[key], snapshots)\n }\n return snapshot\n}\n\nexport function parseDataPath(path: string) {\n return path\n .replace(ARRAY_INDEX_PATH_RE, '.$1')\n .split('.')\n .map(segment => segment.trim())\n .filter(segment => segment && !UNSAFE_PATH_SEGMENTS.has(segment))\n}\n\nfunction normalizePathSegment(segment: string) {\n return ARRAY_INDEX_SEGMENT_RE.test(segment) ? Number(segment) : segment\n}\n\nfunction createPathContainer(nextSegment: string | undefined) {\n return nextSegment && ARRAY_INDEX_SEGMENT_RE.test(nextSegment) ? [] : {}\n}\n\nexport function resolveDataPath(target: Record<string, any>, segments: string[]) {\n let current: any = target\n for (const segment of segments) {\n if (current == null) {\n return undefined\n }\n current = current[normalizePathSegment(segment)]\n }\n return current\n}\n\nexport function assignDataPath(target: Record<string, any>, segments: string[], value: unknown, copiedContainers?: WeakSet<object>) {\n if (!segments.length) {\n return\n }\n let current: any = target\n for (let index = 0; index < segments.length - 1; index += 1) {\n const segment = normalizePathSegment(segments[index]!)\n const nextSegment = segments[index + 1]\n const next = current[segment]\n if (next == null || typeof next !== 'object') {\n current[segment] = createPathContainer(nextSegment)\n copiedContainers?.add(current[segment])\n }\n else if (!copiedContainers?.has(next)) {\n // 保留已传给子组件的输入快照,每批只复制一次变更路径上的容器。\n current[segment] = cloneValue(next)\n copiedContainers?.add(current[segment])\n }\n current = current[segment]\n }\n current[normalizePathSegment(segments[segments.length - 1]!)] = value\n}\n\nexport function coerceValue(value: any, type?: PropertyOption['type']) {\n if (type === Boolean) {\n if (value === '' || value === true) {\n return true\n }\n if (value === undefined || value === null || value === false) {\n return false\n }\n if (typeof value === 'string') {\n return value !== 'false'\n }\n return Boolean(value)\n }\n\n if (type === Number) {\n if (value === undefined || value === null) {\n return value\n }\n const numeric = Number(value)\n return Number.isNaN(numeric) ? value : numeric\n }\n\n if (type === Object || type === Array) {\n if (value === undefined || value === null) {\n return value\n }\n if (typeof value === 'string') {\n try {\n return JSON.parse(value)\n }\n catch {\n return value\n }\n }\n return value\n }\n\n return value\n}\n"],"mappings":";AAEA,MAAM,sBAAsB;AAC5B,MAAM,yBAAyB;AAC/B,MAAM,uCAAuB,IAAI,IAAI;CAAC;CAAa;CAAe;AAAW,CAAC;AAE9E,SAAgB,UAAU,MAAc;CACtC,OAAO,KAAK,QAAQ,aAAa,GAAG,SAAiB,IAAI,KAAK,YAAY,GAAG;AAC/E;AAEA,SAAgB,YAAY,MAAc;CACxC,OAAO,KAAK,QAAQ,cAA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componentEvents.ts
4
+ const componentElements = /* @__PURE__ */ new WeakSet();
5
+ const componentEvents = /* @__PURE__ */ new WeakSet();
6
+ const handlerNames = /* @__PURE__ */ new WeakMap();
7
+ function registerComponentEventTarget(element) {
8
+ componentElements.add(element);
9
+ }
10
+ function markComponentEvent(event) {
11
+ componentEvents.add(event);
12
+ return event;
13
+ }
14
+ function nameRuntimeEventHandler(listener, name) {
15
+ handlerNames.set(listener, name);
16
+ return listener;
17
+ }
18
+ /** 保留 DOM 事件的冒泡行为,仅在框架监听入口区分组件 emit 与浏览器原生事件。 */
19
+ function listenRuntimeEvent(element, name, listener, capture = false) {
20
+ const logicalName = handlerNames.get(listener) ?? name;
21
+ const nativeAlias = EVENT_KIND_ALIAS[logicalName];
22
+ const eventNames = /* @__PURE__ */ new Set([nativeAlias ?? name, logicalName]);
23
+ const dispatch = (event) => {
24
+ if (componentEvents.has(event)) {
25
+ if (event.type !== logicalName) return;
26
+ } else if (componentElements.has(element) && !nativeAlias) return;
27
+ listener.call(element, event);
28
+ };
29
+ for (const eventName of eventNames) element.addEventListener(eventName, dispatch, capture);
30
+ return () => {
31
+ for (const eventName of eventNames) element.removeEventListener(eventName, dispatch, capture);
32
+ };
33
+ }
34
+
35
+ //#endregion
36
+ export { listenRuntimeEvent, markComponentEvent, nameRuntimeEventHandler, registerComponentEventTarget };
37
+ //# sourceMappingURL=componentEvents.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"componentEvents.mjs","names":[],"sources":["../../src/runtime/componentEvents.ts"],"sourcesContent":["import { EVENT_KIND_ALIAS } from '../shared/wxml'\n\nconst componentElements = new WeakSet<Element>()\nconst componentEvents = new WeakSet<Event>()\nconst handlerNames = new WeakMap<EventListener, string>()\n\nexport function registerComponentEventTarget(element: Element) {\n componentElements.add(element)\n}\n\nexport function markComponentEvent<T extends Event>(event: T): T {\n componentEvents.add(event)\n return event\n}\n\nexport function nameRuntimeEventHandler(listener: EventListener, name: string) {\n handlerNames.set(listener, name)\n return listener\n}\n\n/** 保留 DOM 事件的冒泡行为,仅在框架监听入口区分组件 emit 与浏览器原生事件。 */\nexport function listenRuntimeEvent(element: Element, name: string, listener: EventListener, capture = false) {\n const logicalName = handlerNames.get(listener) ?? name\n const nativeAlias = EVENT_KIND_ALIAS[logicalName]\n const eventNames = new Set([nativeAlias ?? name, logicalName])\n const dispatch: EventListener = (event) => {\n if (componentEvents.has(event)) {\n if (event.type !== logicalName) {\n return\n }\n }\n else if (componentElements.has(element) && !nativeAlias) {\n return\n }\n listener.call(element, event)\n }\n for (const eventName of eventNames) {\n element.addEventListener(eventName, dispatch, capture)\n }\n return () => {\n for (const eventName of eventNames) {\n element.removeEventListener(eventName, dispatch, capture)\n }\n }\n}\n"],"mappings":";;;AAEA,MAAM,oCAAoB,IAAI,QAAiB;AAC/C,MAAM,kCAAkB,IAAI,QAAe;AAC3C,MAAM,+BAAe,IAAI,QAA+B;AAExD,SAAgB,6BAA6B,SAAkB;CAC7D,kBAAkB,IAAI,OAAO;AAC/B;AAEA,SAAgB,mBAAoC,OAAa;CAC/D,gBAAgB,IAAI,KAAK;CACzB,OAAO;AACT;AAEA,SAAgB,wBAAwB,UAAyB,MAAc;CAC7E,aAAa,IAAI,UAAU,IAAI;CAC/B,OAAO;AACT;;AAGA,SAAgB,mBAAmB,SAAkB,MAAc,UAAyB,UAAU,OAAO;CAC3G,MAAM,cAAc,aAAa,IAAI,QAAQ,KAAK;CAClD,MAAM,cAAc,iBAAiB;CACrC,MAAM,6BAAa,IAAI,IAAI,CAAC,eAAe,MAAM,WAAW,CAAC;CAC7D,MAAM,YAA2B,UAAU;EACzC,IAAI,gBAAgB,IAAI,KAAK,GAC3B;OAAI,MAAM,SAAS,aACjB;EACF,OAEG,IAAI,kBAAkB,IAAI,OAAO,KAAK,CAAC,aAC1C;EAEF,SAAS,KAAK,SAAS,KAAK;CAC9B;CACA,KAAK,MAAM,aAAa,YACtB,QAAQ,iBAAiB,WAAW,UAAU,OAAO;CAEvD,aAAa;EACX,KAAK,MAAM,aAAa,YACtB,QAAQ,oBAAoB,WAAW,UAAU,OAAO;CAE5D;AACF"}
@@ -1,3 +1,4 @@
1
+ import { listenRuntimeEvent } from "./componentEvents.mjs";
1
2
  import { nothing } from "lit";
2
3
  import { AsyncDirective, PartType, directive } from "lit/async-directive.js";
3
4
 
@@ -8,6 +9,7 @@ var RuntimeEventBindingDirective = class extends AsyncDirective {
8
9
  #eventName;
9
10
  #listener;
10
11
  #listening = false;
12
+ #dispose;
11
13
  constructor(partInfo) {
12
14
  super(partInfo);
13
15
  if (partInfo.type !== PartType.ELEMENT) throw new TypeError("Runtime event bindings must be used in an element expression.");
@@ -35,12 +37,13 @@ var RuntimeEventBindingDirective = class extends AsyncDirective {
35
37
  }
36
38
  #addListener() {
37
39
  if (!this.isConnected || this.#listening || !this.#element || !this.#eventName || !this.#listener) return;
38
- this.#element.addEventListener(this.#eventName, this.#listener, this.#capture);
40
+ this.#dispose = listenRuntimeEvent(this.#element, this.#eventName, this.#listener, this.#capture);
39
41
  this.#listening = true;
40
42
  }
41
43
  #removeListener() {
42
44
  if (!this.#listening || !this.#element || !this.#eventName || !this.#listener) return;
43
- this.#element.removeEventListener(this.#eventName, this.#listener, this.#capture);
45
+ this.#dispose?.();
46
+ this.#dispose = void 0;
44
47
  this.#listening = false;
45
48
  }
46
49
  };
@@ -1 +1 @@
1
- {"version":3,"file":"eventBinding.mjs","names":[],"sources":["../../src/runtime/eventBinding.ts"],"sourcesContent":["import type { ElementPart, PartInfo } from 'lit/async-directive.js'\nimport { nothing } from 'lit'\nimport { AsyncDirective, directive, PartType } from 'lit/async-directive.js'\n\ninterface RuntimeEventFlags {\n capture?: boolean\n}\n\nclass RuntimeEventBindingDirective extends AsyncDirective {\n #capture = false\n #element?: Element\n #eventName?: string\n #listener?: EventListener\n #listening = false\n\n constructor(partInfo: PartInfo) {\n super(partInfo)\n if (partInfo.type !== PartType.ELEMENT) {\n throw new TypeError('Runtime event bindings must be used in an element expression.')\n }\n }\n\n render(_eventName: string, _listener: EventListener, _flags?: RuntimeEventFlags) {\n return nothing\n }\n\n update(\n part: ElementPart,\n [eventName, listener, flags]: Parameters<this['render']>,\n ) {\n const capture = Boolean(flags?.capture)\n if (\n part.element !== this.#element\n || eventName !== this.#eventName\n || listener !== this.#listener\n || capture !== this.#capture\n ) {\n this.#removeListener()\n this.#element = part.element\n this.#eventName = eventName\n this.#listener = listener\n this.#capture = capture\n this.#addListener()\n }\n return nothing\n }\n\n protected disconnected() {\n this.#removeListener()\n }\n\n protected reconnected() {\n this.#addListener()\n }\n\n #addListener() {\n if (!this.isConnected || this.#listening || !this.#element || !this.#eventName || !this.#listener) {\n return\n }\n this.#element.addEventListener(this.#eventName, this.#listener, this.#capture)\n this.#listening = true\n }\n\n #removeListener() {\n if (!this.#listening || !this.#element || !this.#eventName || !this.#listener) {\n return\n }\n this.#element.removeEventListener(this.#eventName, this.#listener, this.#capture)\n this.#listening = false\n }\n}\n\nexport const bindRuntimeEvent = directive(RuntimeEventBindingDirective)\n"],"mappings":";;;;AAQA,IAAM,+BAAN,cAA2C,eAAe;CACxD,WAAW;CACX;CACA;CACA;CACA,aAAa;CAEb,YAAY,UAAoB;EAC9B,MAAM,QAAQ;EACd,IAAI,SAAS,SAAS,SAAS,SAC7B,MAAM,IAAI,UAAU,+DAA+D;CAEvF;CAEA,OAAO,YAAoB,WAA0B,QAA4B;EAC/E,OAAO;CACT;CAEA,OACE,MACA,CAAC,WAAW,UAAU,QACtB;EACA,MAAM,UAAU,QAAQ,OAAO,OAAO;EACtC,IACE,KAAK,YAAY,KAAK,YACnB,cAAc,KAAK,cACnB,aAAa,KAAK,aAClB,YAAY,KAAK,UACpB;GACA,KAAK,gBAAgB;GACrB,KAAK,WAAW,KAAK;GACrB,KAAK,aAAa;GAClB,KAAK,YAAY;GACjB,KAAK,WAAW;GAChB,KAAK,aAAa;EACpB;EACA,OAAO;CACT;CAEA,AAAU,eAAe;EACvB,KAAK,gBAAgB;CACvB;CAEA,AAAU,cAAc;EACtB,KAAK,aAAa;CACpB;CAEA,eAAe;EACb,IAAI,CAAC,KAAK,eAAe,KAAK,cAAc,CAAC,KAAK,YAAY,CAAC,KAAK,cAAc,CAAC,KAAK,WACtF;EAEF,KAAK,SAAS,iBAAiB,KAAK,YAAY,KAAK,WAAW,KAAK,QAAQ;EAC7E,KAAK,aAAa;CACpB;CAEA,kBAAkB;EAChB,IAAI,CAAC,KAAK,cAAc,CAAC,KAAK,YAAY,CAAC,KAAK,cAAc,CAAC,KAAK,WAClE;EAEF,KAAK,SAAS,oBAAoB,KAAK,YAAY,KAAK,WAAW,KAAK,QAAQ;EAChF,KAAK,aAAa;CACpB;AACF;AAEA,MAAa,mBAAmB,UAAU,4BAA4B"}
1
+ {"version":3,"file":"eventBinding.mjs","names":[],"sources":["../../src/runtime/eventBinding.ts"],"sourcesContent":["import type { ElementPart, PartInfo } from 'lit/async-directive.js'\nimport { nothing } from 'lit'\nimport { AsyncDirective, directive, PartType } from 'lit/async-directive.js'\nimport { listenRuntimeEvent } from './componentEvents'\n\ninterface RuntimeEventFlags {\n capture?: boolean\n}\n\nclass RuntimeEventBindingDirective extends AsyncDirective {\n #capture = false\n #element?: Element\n #eventName?: string\n #listener?: EventListener\n #listening = false\n #dispose?: () => void\n\n constructor(partInfo: PartInfo) {\n super(partInfo)\n if (partInfo.type !== PartType.ELEMENT) {\n throw new TypeError('Runtime event bindings must be used in an element expression.')\n }\n }\n\n render(_eventName: string, _listener: EventListener, _flags?: RuntimeEventFlags) {\n return nothing\n }\n\n update(\n part: ElementPart,\n [eventName, listener, flags]: Parameters<this['render']>,\n ) {\n const capture = Boolean(flags?.capture)\n if (\n part.element !== this.#element\n || eventName !== this.#eventName\n || listener !== this.#listener\n || capture !== this.#capture\n ) {\n this.#removeListener()\n this.#element = part.element\n this.#eventName = eventName\n this.#listener = listener\n this.#capture = capture\n this.#addListener()\n }\n return nothing\n }\n\n protected disconnected() {\n this.#removeListener()\n }\n\n protected reconnected() {\n this.#addListener()\n }\n\n #addListener() {\n if (!this.isConnected || this.#listening || !this.#element || !this.#eventName || !this.#listener) {\n return\n }\n this.#dispose = listenRuntimeEvent(this.#element, this.#eventName, this.#listener, this.#capture)\n this.#listening = true\n }\n\n #removeListener() {\n if (!this.#listening || !this.#element || !this.#eventName || !this.#listener) {\n return\n }\n this.#dispose?.()\n this.#dispose = undefined\n this.#listening = false\n }\n}\n\nexport const bindRuntimeEvent = directive(RuntimeEventBindingDirective)\n"],"mappings":";;;;;AASA,IAAM,+BAAN,cAA2C,eAAe;CACxD,WAAW;CACX;CACA;CACA;CACA,aAAa;CACb;CAEA,YAAY,UAAoB;EAC9B,MAAM,QAAQ;EACd,IAAI,SAAS,SAAS,SAAS,SAC7B,MAAM,IAAI,UAAU,+DAA+D;CAEvF;CAEA,OAAO,YAAoB,WAA0B,QAA4B;EAC/E,OAAO;CACT;CAEA,OACE,MACA,CAAC,WAAW,UAAU,QACtB;EACA,MAAM,UAAU,QAAQ,OAAO,OAAO;EACtC,IACE,KAAK,YAAY,KAAK,YACnB,cAAc,KAAK,cACnB,aAAa,KAAK,aAClB,YAAY,KAAK,UACpB;GACA,KAAK,gBAAgB;GACrB,KAAK,WAAW,KAAK;GACrB,KAAK,aAAa;GAClB,KAAK,YAAY;GACjB,KAAK,WAAW;GAChB,KAAK,aAAa;EACpB;EACA,OAAO;CACT;CAEA,AAAU,eAAe;EACvB,KAAK,gBAAgB;CACvB;CAEA,AAAU,cAAc;EACtB,KAAK,aAAa;CACpB;CAEA,eAAe;EACb,IAAI,CAAC,KAAK,eAAe,KAAK,cAAc,CAAC,KAAK,YAAY,CAAC,KAAK,cAAc,CAAC,KAAK,WACtF;EAEF,KAAK,WAAW,mBAAmB,KAAK,UAAU,KAAK,YAAY,KAAK,WAAW,KAAK,QAAQ;EAChG,KAAK,aAAa;CACpB;CAEA,kBAAkB;EAChB,IAAI,CAAC,KAAK,cAAc,CAAC,KAAK,YAAY,CAAC,KAAK,cAAc,CAAC,KAAK,WAClE;EAEF,KAAK,WAAW;EAChB,KAAK,WAAW;EAChB,KAAK,aAAa;CACpB;AACF;AAEA,MAAa,mBAAmB,UAAU,4BAA4B"}
@@ -25,6 +25,7 @@ import { authorize, checkSession, getAccountInfoSync, getAppAuthorizeSetting, ge
25
25
  import { ResolvedWebViewportConfig, WebViewportConfig } from "./viewport/types.mjs";
26
26
  import { getWebViewportWidth, resolveWebViewportConfig, setupWebViewport } from "./viewport/index.mjs";
27
27
  import { getEnterOptionsSync, getLaunchOptionsSync, initializePageRoutes, navigateBack, navigateTo, offAppHide, offAppShow, onAppHide, onAppShow, reLaunch, redirectTo, registerApp, registerComponent, registerPage, switchTab } from "./polyfill/routeRuntime.mjs";
28
+ import { AppRouteCallback, AppRouteEvent, AppRouteOpenType, BeforePageUnloadCallback, BeforePageUnloadEvent, offAppRoute, offAppRouteDone, offBeforeAppRoute, offBeforePageUnload, onAppRoute, onAppRouteDone, onBeforeAppRoute, onBeforePageUnload } from "./polyfill/routeRuntime/events.mjs";
28
29
  import { clearStorage, clearStorageSync, createCanvasContext, createSelectorQuery, createVKSession, createVideoContext, createWorker, downloadFile, exitMiniProgram, getFileSystemManager, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, hideKeyboard, loadSubPackage, navigateToMiniProgram, nextTick, pageScrollTo, preloadSubpackage, removeStorage, removeStorageSync, request, setStorage, setStorageSync, startPullDownRefresh, stopPullDownRefresh, uploadFile } from "./polyfill/runtimeDataApi.mjs";
29
30
  import { chooseAddress, chooseFile, chooseImage, chooseLocation, chooseMedia, chooseMessageFile, chooseVideo, compressImage, compressVideo, getClipboardData, getImageInfo, getVideoInfo, hideLoading, hideTabBar, hideTabBarRedDot, makePhoneCall, openCustomerServiceChat, openDocument, openLocation, openVideoEditor, previewImage, previewMedia, removeTabBarBadge, requestPayment, requestSubscribeMessage, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, setClipboardData, setTabBarBadge, setTabBarItem, setTabBarStyle, showActionSheet, showLoading, showModal, showShareMenu, showTabBar, showTabBarRedDot, showToast, updateShareMenu } from "./polyfill/uiMediaApi.mjs";
30
31
  import { canIUse, createInterstitialAd, createRewardedVideoAd, getExtConfig, getExtConfigSync, getLogManager, getUpdateManager, hideNavigationBarLoading, reportAnalytics, setBackgroundColor, setBackgroundTextStyle, setNavigationBarColor, setNavigationBarTitle, showNavigationBarLoading } from "./polyfill/index.mjs";
@@ -34,4 +35,4 @@ import { injectStyle, removeStyle } from "./style.mjs";
34
35
  import { RuntimeWarningLevel, RuntimeWarningOptions, setRuntimeWarningOptions } from "./warning.mjs";
35
36
  import { installWebModuleRegistration, registerWebWevuApp, registerWebWevuComponent, registerWebWevuComponentFactory } from "./wevu.mjs";
36
37
  export * from "wevu/internal-runtime";
37
- export { type AppHideCallback, type AppHideOptions, type AppLaunchOptions, type AppShowCallback, type ButtonFormConfig, type NavigationBarMetrics, type RenderContext, type ResolvedWebRoutingConfig, type ResolvedWebViewportConfig, type RpxConfig, type RuntimeWarningLevel, type RuntimeWarningOptions, type TemplateRenderer, type TemplateScope, type WebPageHead, type WebResourceHint, type WebResourceHintRelation, type WebResourceHintsConfig, type WebRouteHistoryState, type WebRouteTarget, type WebRoutingConfig, type WebRoutingMode, type WebRuntimeClipboard, type WebRuntimeDialogs, type WebRuntimeHost, type WebRuntimeStorage, type WebSeoConfig, type WebTabBarConfig, type WebTabBarItem, type WebViewportConfig, authorize, bindRuntimeEvent, canIUse, checkSession, chooseAddress, chooseFile, chooseImage, chooseLocation, chooseMedia, chooseMessageFile, chooseVideo, clearStorage, clearStorageSync, compressImage, compressVideo, configureWebSeo, createCanvasContext, createInputEventDetail, createInterstitialAd, createRenderContext, createRewardedVideoAd, createScrollEventDetail, createSelectorQuery, createSwitchEventDetail, createTemplate, createTextareaLineChangeDetail, createVKSession, createVideoContext, createVideoProgressDetail, createVideoTimeUpdateDetail, createWorker, defineComponent, disposeWebRouting, downloadFile, ensureButtonDefined, ensureNativeComponentsDefined, exitMiniProgram, getAccountInfoSync, getAppAuthorizeSetting, getAppBaseInfo, getBatteryInfo, getBatteryInfoSync, getClipboardData, getDeviceInfo, getEnterOptionsSync, getExtConfig, getExtConfigSync, getFileSystemManager, getFuzzyLocation, getImageInfo, getLaunchOptionsSync, getLocation, getLogManager, getMenuButtonBoundingClientRect, getNetworkType, getRuntimeClipboard, getRuntimeDialogs, getRuntimeExecutionMode, getRuntimeFetch, getRuntimeStorage, getSetting, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, getSystemInfo, getSystemInfoSync, getSystemSetting, getUpdateManager, getUserInfo, getUserProfile, getVideoInfo, getWebRoutingConfig, getWebRuntimeHost, getWebViewportWidth, getWindowInfo, hideKeyboard, hideLoading, hideNavigationBarLoading, hideTabBar, hideTabBarRedDot, initializePageRoutes, injectStyle, installWebHostGlobals, installWebModuleRegistration, loadSubPackage, login, makePhoneCall, navigateBack, navigateTo, navigateToMiniProgram, nextTick, offAppHide, offAppShow, offNetworkStatusChange, offWindowResize, onAppHide, onAppShow, onNetworkStatusChange, onWindowResize, openAppAuthorizeSetting, openCustomerServiceChat, openDocument, openLocation, openRuntimeUrl, openSetting, openVideoEditor, pageScrollTo, preloadSubpackage, previewImage, previewMedia, reLaunch, redirectTo, registerApp, registerComponent, registerPage, registerWebWevuApp, registerWebWevuComponent, registerWebWevuComponentFactory, removeStorage, removeStorageSync, removeStyle, removeTabBarBadge, renderTemplate, reportAnalytics, request, requestPayment, requestSubscribeMessage, resetWebDocumentHead, resetWebRuntimeHost, resolveImageModeStyle, resolveVideoObjectFit, resolveWebRoutingConfig, resolveWebViewportConfig, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, setBackgroundColor, setBackgroundTextStyle, setButtonFormConfig, setClipboardData, setNavigationBarColor, setNavigationBarMetrics, setNavigationBarTitle, setPageLayout, setRuntimeExecutionMode, setRuntimeWarningOptions, setStorage, setStorageSync, setTabBarBadge, setTabBarItem, setTabBarStyle, setWebRuntimeHost, setupRpx, setupWebResourceHints, setupWebViewport, showActionSheet, showLoading, showModal, showNavigationBarLoading, showShareMenu, showTabBar, showTabBarRedDot, showToast, startPullDownRefresh, stopPullDownRefresh, switchTab, syncWebDocumentHead, updateShareMenu, updateWebDocumentTitle, uploadFile, vibrateShort };
38
+ export { type AppHideCallback, type AppHideOptions, type AppLaunchOptions, type AppRouteCallback, type AppRouteEvent, type AppRouteOpenType, type AppShowCallback, type BeforePageUnloadCallback, type BeforePageUnloadEvent, type ButtonFormConfig, type NavigationBarMetrics, type RenderContext, type ResolvedWebRoutingConfig, type ResolvedWebViewportConfig, type RpxConfig, type RuntimeWarningLevel, type RuntimeWarningOptions, type TemplateRenderer, type TemplateScope, type WebPageHead, type WebResourceHint, type WebResourceHintRelation, type WebResourceHintsConfig, type WebRouteHistoryState, type WebRouteTarget, type WebRoutingConfig, type WebRoutingMode, type WebRuntimeClipboard, type WebRuntimeDialogs, type WebRuntimeHost, type WebRuntimeStorage, type WebSeoConfig, type WebTabBarConfig, type WebTabBarItem, type WebViewportConfig, authorize, bindRuntimeEvent, canIUse, checkSession, chooseAddress, chooseFile, chooseImage, chooseLocation, chooseMedia, chooseMessageFile, chooseVideo, clearStorage, clearStorageSync, compressImage, compressVideo, configureWebSeo, createCanvasContext, createInputEventDetail, createInterstitialAd, createRenderContext, createRewardedVideoAd, createScrollEventDetail, createSelectorQuery, createSwitchEventDetail, createTemplate, createTextareaLineChangeDetail, createVKSession, createVideoContext, createVideoProgressDetail, createVideoTimeUpdateDetail, createWorker, defineComponent, disposeWebRouting, downloadFile, ensureButtonDefined, ensureNativeComponentsDefined, exitMiniProgram, getAccountInfoSync, getAppAuthorizeSetting, getAppBaseInfo, getBatteryInfo, getBatteryInfoSync, getClipboardData, getDeviceInfo, getEnterOptionsSync, getExtConfig, getExtConfigSync, getFileSystemManager, getFuzzyLocation, getImageInfo, getLaunchOptionsSync, getLocation, getLogManager, getMenuButtonBoundingClientRect, getNetworkType, getRuntimeClipboard, getRuntimeDialogs, getRuntimeExecutionMode, getRuntimeFetch, getRuntimeStorage, getSetting, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, getSystemInfo, getSystemInfoSync, getSystemSetting, getUpdateManager, getUserInfo, getUserProfile, getVideoInfo, getWebRoutingConfig, getWebRuntimeHost, getWebViewportWidth, getWindowInfo, hideKeyboard, hideLoading, hideNavigationBarLoading, hideTabBar, hideTabBarRedDot, initializePageRoutes, injectStyle, installWebHostGlobals, installWebModuleRegistration, loadSubPackage, login, makePhoneCall, navigateBack, navigateTo, navigateToMiniProgram, nextTick, offAppHide, offAppRoute, offAppRouteDone, offAppShow, offBeforeAppRoute, offBeforePageUnload, offNetworkStatusChange, offWindowResize, onAppHide, onAppRoute, onAppRouteDone, onAppShow, onBeforeAppRoute, onBeforePageUnload, onNetworkStatusChange, onWindowResize, openAppAuthorizeSetting, openCustomerServiceChat, openDocument, openLocation, openRuntimeUrl, openSetting, openVideoEditor, pageScrollTo, preloadSubpackage, previewImage, previewMedia, reLaunch, redirectTo, registerApp, registerComponent, registerPage, registerWebWevuApp, registerWebWevuComponent, registerWebWevuComponentFactory, removeStorage, removeStorageSync, removeStyle, removeTabBarBadge, renderTemplate, reportAnalytics, request, requestPayment, requestSubscribeMessage, resetWebDocumentHead, resetWebRuntimeHost, resolveImageModeStyle, resolveVideoObjectFit, resolveWebRoutingConfig, resolveWebViewportConfig, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, setBackgroundColor, setBackgroundTextStyle, setButtonFormConfig, setClipboardData, setNavigationBarColor, setNavigationBarMetrics, setNavigationBarTitle, setPageLayout, setRuntimeExecutionMode, setRuntimeWarningOptions, setStorage, setStorageSync, setTabBarBadge, setTabBarItem, setTabBarStyle, setWebRuntimeHost, setupRpx, setupWebResourceHints, setupWebViewport, showActionSheet, showLoading, showModal, showNavigationBarLoading, showShareMenu, showTabBar, showTabBarRedDot, showToast, startPullDownRefresh, stopPullDownRefresh, switchTab, syncWebDocumentHead, updateShareMenu, updateWebDocumentTitle, uploadFile, vibrateShort };
@@ -20,6 +20,7 @@ import { ensureNativeComponentsDefined } from "./nativeComponents/index.mjs";
20
20
  import { setNavigationBarMetrics } from "./navigationBar/index.mjs";
21
21
  import { getWebViewportWidth, resolveWebViewportConfig, setupWebViewport } from "./viewport/index.mjs";
22
22
  import { setupRpx } from "./rpx.mjs";
23
+ import { offAppRoute, offAppRouteDone, offBeforeAppRoute, offBeforePageUnload, onAppRoute, onAppRouteDone, onBeforeAppRoute, onBeforePageUnload } from "./polyfill/routeRuntime/events.mjs";
23
24
  import { disposeWebRouting, getWebRoutingConfig, resolveWebRoutingConfig } from "./polyfill/routeRuntime/history.mjs";
24
25
  import { getEnterOptionsSync, getLaunchOptionsSync, initializePageRoutes, navigateBack, navigateTo, offAppHide, offAppShow, onAppHide, onAppShow, reLaunch, redirectTo, registerApp, registerComponent, registerPage, switchTab } from "./polyfill/routeRuntime.mjs";
25
26
  import { chooseAddress, chooseFile, chooseImage, chooseLocation, chooseMedia, chooseMessageFile, chooseVideo, compressImage, compressVideo, getClipboardData, getImageInfo, getVideoInfo, hideLoading, hideTabBar, hideTabBarRedDot, makePhoneCall, openCustomerServiceChat, openDocument, openLocation, openVideoEditor, previewImage, previewMedia, removeTabBarBadge, requestPayment, requestSubscribeMessage, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, setClipboardData, setTabBarBadge, setTabBarItem, setTabBarStyle, showActionSheet, showLoading, showModal, showShareMenu, showTabBar, showTabBarRedDot, showToast, updateShareMenu } from "./polyfill/uiMediaApi.mjs";
@@ -36,5 +37,5 @@ installWebHostGlobals();
36
37
  installMiniProgramGlobals();
37
38
 
38
39
  //#endregion
39
- export { authorize, bindRuntimeEvent, canIUse, checkSession, chooseAddress, chooseFile, chooseImage, chooseLocation, chooseMedia, chooseMessageFile, chooseVideo, clearStorage, clearStorageSync, compressImage, compressVideo, configureWebSeo, createCanvasContext, createInputEventDetail, createInterstitialAd, createRenderContext, createRewardedVideoAd, createScrollEventDetail, createSelectorQuery, createSwitchEventDetail, createTemplate, createTextareaLineChangeDetail, createVKSession, createVideoContext, createVideoProgressDetail, createVideoTimeUpdateDetail, createWorker, defineComponent, disposeWebRouting, downloadFile, ensureButtonDefined, ensureNativeComponentsDefined, exitMiniProgram, getAccountInfoSync, getAppAuthorizeSetting, getAppBaseInfo, getBatteryInfo, getBatteryInfoSync, getClipboardData, getDeviceInfo, getEnterOptionsSync, getExtConfig, getExtConfigSync, getFileSystemManager, getFuzzyLocation, getImageInfo, getLaunchOptionsSync, getLocation, getLogManager, getMenuButtonBoundingClientRect, getNetworkType, getRuntimeClipboard, getRuntimeDialogs, getRuntimeExecutionMode, getRuntimeFetch, getRuntimeStorage, getSetting, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, getSystemInfo, getSystemInfoSync, getSystemSetting, getUpdateManager, getUserInfo, getUserProfile, getVideoInfo, getWebRoutingConfig, getWebRuntimeHost, getWebViewportWidth, getWindowInfo, hideKeyboard, hideLoading, hideNavigationBarLoading, hideTabBar, hideTabBarRedDot, initializePageRoutes, injectStyle, installWebHostGlobals, installWebModuleRegistration, loadSubPackage, login, makePhoneCall, navigateBack, navigateTo, navigateToMiniProgram, nextTick, offAppHide, offAppShow, offNetworkStatusChange, offWindowResize, onAppHide, onAppShow, onNetworkStatusChange, onWindowResize, openAppAuthorizeSetting, openCustomerServiceChat, openDocument, openLocation, openRuntimeUrl, openSetting, openVideoEditor, pageScrollTo, preloadSubpackage, previewImage, previewMedia, reLaunch, redirectTo, registerApp, registerComponent, registerPage, registerWebWevuApp, registerWebWevuComponent, registerWebWevuComponentFactory, removeStorage, removeStorageSync, removeStyle, removeTabBarBadge, renderTemplate, reportAnalytics, request, requestPayment, requestSubscribeMessage, resetWebDocumentHead, resetWebRuntimeHost, resolveImageModeStyle, resolveVideoObjectFit, resolveWebRoutingConfig, resolveWebViewportConfig, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, setBackgroundColor, setBackgroundTextStyle, setButtonFormConfig, setClipboardData, setNavigationBarColor, setNavigationBarMetrics, setNavigationBarTitle, setPageLayout, setRuntimeExecutionMode, setRuntimeWarningOptions, setStorage, setStorageSync, setTabBarBadge, setTabBarItem, setTabBarStyle, setWebRuntimeHost, setupRpx, setupWebResourceHints, setupWebViewport, showActionSheet, showLoading, showModal, showNavigationBarLoading, showShareMenu, showTabBar, showTabBarRedDot, showToast, startPullDownRefresh, stopPullDownRefresh, switchTab, syncWebDocumentHead, updateShareMenu, updateWebDocumentTitle, uploadFile, vibrateShort };
40
+ export { authorize, bindRuntimeEvent, canIUse, checkSession, chooseAddress, chooseFile, chooseImage, chooseLocation, chooseMedia, chooseMessageFile, chooseVideo, clearStorage, clearStorageSync, compressImage, compressVideo, configureWebSeo, createCanvasContext, createInputEventDetail, createInterstitialAd, createRenderContext, createRewardedVideoAd, createScrollEventDetail, createSelectorQuery, createSwitchEventDetail, createTemplate, createTextareaLineChangeDetail, createVKSession, createVideoContext, createVideoProgressDetail, createVideoTimeUpdateDetail, createWorker, defineComponent, disposeWebRouting, downloadFile, ensureButtonDefined, ensureNativeComponentsDefined, exitMiniProgram, getAccountInfoSync, getAppAuthorizeSetting, getAppBaseInfo, getBatteryInfo, getBatteryInfoSync, getClipboardData, getDeviceInfo, getEnterOptionsSync, getExtConfig, getExtConfigSync, getFileSystemManager, getFuzzyLocation, getImageInfo, getLaunchOptionsSync, getLocation, getLogManager, getMenuButtonBoundingClientRect, getNetworkType, getRuntimeClipboard, getRuntimeDialogs, getRuntimeExecutionMode, getRuntimeFetch, getRuntimeStorage, getSetting, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, getSystemInfo, getSystemInfoSync, getSystemSetting, getUpdateManager, getUserInfo, getUserProfile, getVideoInfo, getWebRoutingConfig, getWebRuntimeHost, getWebViewportWidth, getWindowInfo, hideKeyboard, hideLoading, hideNavigationBarLoading, hideTabBar, hideTabBarRedDot, initializePageRoutes, injectStyle, installWebHostGlobals, installWebModuleRegistration, loadSubPackage, login, makePhoneCall, navigateBack, navigateTo, navigateToMiniProgram, nextTick, offAppHide, offAppRoute, offAppRouteDone, offAppShow, offBeforeAppRoute, offBeforePageUnload, offNetworkStatusChange, offWindowResize, onAppHide, onAppRoute, onAppRouteDone, onAppShow, onBeforeAppRoute, onBeforePageUnload, onNetworkStatusChange, onWindowResize, openAppAuthorizeSetting, openCustomerServiceChat, openDocument, openLocation, openRuntimeUrl, openSetting, openVideoEditor, pageScrollTo, preloadSubpackage, previewImage, previewMedia, reLaunch, redirectTo, registerApp, registerComponent, registerPage, registerWebWevuApp, registerWebWevuComponent, registerWebWevuComponentFactory, removeStorage, removeStorageSync, removeStyle, removeTabBarBadge, renderTemplate, reportAnalytics, request, requestPayment, requestSubscribeMessage, resetWebDocumentHead, resetWebRuntimeHost, resolveImageModeStyle, resolveVideoObjectFit, resolveWebRoutingConfig, resolveWebViewportConfig, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, setBackgroundColor, setBackgroundTextStyle, setButtonFormConfig, setClipboardData, setNavigationBarColor, setNavigationBarMetrics, setNavigationBarTitle, setPageLayout, setRuntimeExecutionMode, setRuntimeWarningOptions, setStorage, setStorageSync, setTabBarBadge, setTabBarItem, setTabBarStyle, setWebRuntimeHost, setupRpx, setupWebResourceHints, setupWebViewport, showActionSheet, showLoading, showModal, showNavigationBarLoading, showShareMenu, showTabBar, showTabBarRedDot, showToast, startPullDownRefresh, stopPullDownRefresh, switchTab, syncWebDocumentHead, updateShareMenu, updateWebDocumentTitle, uploadFile, vibrateShort };
40
41
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../src/runtime/index.ts"],"sourcesContent":["import { installWebHostGlobals } from './hostGlobals'\nimport { installMiniProgramGlobals } from './polyfill'\n\ninstallWebHostGlobals()\ninstallMiniProgramGlobals()\n\nexport type { WebTabBarConfig, WebTabBarItem } from './appShell/tabBar'\nexport { ensureButtonDefined, setButtonFormConfig } from './button'\nexport type { ButtonFormConfig } from './button'\nexport { defineComponent } from './component'\nexport { bindRuntimeEvent } from './eventBinding'\nexport { getRuntimeExecutionMode, setRuntimeExecutionMode } from './execution'\nexport {\n getRuntimeClipboard,\n getRuntimeDialogs,\n getRuntimeFetch,\n getRuntimeStorage,\n getWebRuntimeHost,\n openRuntimeUrl,\n resetWebRuntimeHost,\n setWebRuntimeHost,\n} from './host'\nexport type { WebRuntimeClipboard, WebRuntimeDialogs, WebRuntimeHost, WebRuntimeStorage } from './host'\nexport { installWebHostGlobals } from './hostGlobals'\nexport {\n createInputEventDetail,\n createScrollEventDetail,\n createSwitchEventDetail,\n createTextareaLineChangeDetail,\n createVideoProgressDetail,\n createVideoTimeUpdateDetail,\n ensureNativeComponentsDefined,\n resolveImageModeStyle,\n resolveVideoObjectFit,\n} from './nativeComponents'\nexport { setNavigationBarMetrics } from './navigationBar'\nexport type { NavigationBarMetrics } from './navigationBar'\nexport { setPageLayout } from './pageLayout'\nexport {\n authorize,\n canIUse,\n checkSession,\n chooseAddress,\n chooseFile,\n chooseImage,\n chooseLocation,\n chooseMedia,\n chooseMessageFile,\n chooseVideo,\n clearStorage,\n clearStorageSync,\n compressImage,\n compressVideo,\n createCanvasContext,\n createInterstitialAd,\n createRewardedVideoAd,\n createSelectorQuery,\n createVideoContext,\n createVKSession,\n createWorker,\n downloadFile,\n exitMiniProgram,\n getAccountInfoSync,\n getAppAuthorizeSetting,\n getAppBaseInfo,\n getBatteryInfo,\n getBatteryInfoSync,\n getClipboardData,\n getDeviceInfo,\n getEnterOptionsSync,\n getExtConfig,\n getExtConfigSync,\n getFileSystemManager,\n getFuzzyLocation,\n getImageInfo,\n getLaunchOptionsSync,\n getLocation,\n getLogManager,\n getMenuButtonBoundingClientRect,\n getNetworkType,\n getSetting,\n getStorage,\n getStorageInfo,\n getStorageInfoSync,\n getStorageSync,\n getSystemInfo,\n getSystemInfoSync,\n getSystemSetting,\n getUpdateManager,\n getUserInfo,\n getUserProfile,\n getVideoInfo,\n getWindowInfo,\n hideKeyboard,\n hideLoading,\n hideNavigationBarLoading,\n hideTabBar,\n hideTabBarRedDot,\n initializePageRoutes,\n loadSubPackage,\n login,\n makePhoneCall,\n navigateBack,\n navigateTo,\n navigateToMiniProgram,\n nextTick,\n offAppHide,\n offAppShow,\n offNetworkStatusChange,\n offWindowResize,\n onAppHide,\n onAppShow,\n onNetworkStatusChange,\n onWindowResize,\n openAppAuthorizeSetting,\n openCustomerServiceChat,\n openDocument,\n openLocation,\n openSetting,\n openVideoEditor,\n pageScrollTo,\n preloadSubpackage,\n previewImage,\n previewMedia,\n redirectTo,\n registerApp,\n registerComponent,\n registerPage,\n reLaunch,\n removeStorage,\n removeStorageSync,\n removeTabBarBadge,\n reportAnalytics,\n request,\n requestPayment,\n requestSubscribeMessage,\n saveFile,\n saveFileToDisk,\n saveImageToPhotosAlbum,\n saveVideoToPhotosAlbum,\n scanCode,\n setBackgroundColor,\n setBackgroundTextStyle,\n setClipboardData,\n setNavigationBarColor,\n setNavigationBarTitle,\n setStorage,\n setStorageSync,\n setTabBarBadge,\n setTabBarItem,\n setTabBarStyle,\n showActionSheet,\n showLoading,\n showModal,\n showNavigationBarLoading,\n showShareMenu,\n showTabBar,\n showTabBarRedDot,\n showToast,\n startPullDownRefresh,\n stopPullDownRefresh,\n switchTab,\n updateShareMenu,\n uploadFile,\n vibrateShort,\n} from './polyfill'\nexport type { AppHideCallback, AppHideOptions, AppLaunchOptions, AppShowCallback } from './polyfill'\nexport {\n disposeWebRouting,\n getWebRoutingConfig,\n resolveWebRoutingConfig,\n} from './polyfill/routeRuntime/history'\nexport type {\n ResolvedWebRoutingConfig,\n WebRouteHistoryState,\n WebRouteTarget,\n WebRoutingConfig,\n WebRoutingMode,\n} from './polyfill/routeRuntime/history'\nexport { createRenderContext } from './renderContext'\nexport type { RenderContext } from './renderContext'\nexport { setupRpx } from './rpx'\nexport type { RpxConfig } from './rpx'\nexport {\n configureWebSeo,\n resetWebDocumentHead,\n setupWebResourceHints,\n syncWebDocumentHead,\n updateWebDocumentTitle,\n} from './seo'\nexport type { WebPageHead, WebResourceHint, WebResourceHintRelation, WebResourceHintsConfig, WebSeoConfig } from './seo'\nexport { injectStyle, removeStyle } from './style'\nexport { createTemplate, renderTemplate } from './template'\nexport type { TemplateRenderer, TemplateScope } from './template'\nexport { getWebViewportWidth, resolveWebViewportConfig, setupWebViewport } from './viewport'\nexport type { ResolvedWebViewportConfig, WebViewportConfig } from './viewport'\nexport { setRuntimeWarningOptions } from './warning'\nexport type { RuntimeWarningLevel, RuntimeWarningOptions } from './warning'\nexport {\n installWebModuleRegistration,\n registerWebWevuApp,\n registerWebWevuComponent,\n registerWebWevuComponentFactory,\n} from './wevu'\nexport * from 'wevu/internal-runtime'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,sBAAsB;AACtB,0BAA0B"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../src/runtime/index.ts"],"sourcesContent":["import { installWebHostGlobals } from './hostGlobals'\nimport { installMiniProgramGlobals } from './polyfill'\n\ninstallWebHostGlobals()\ninstallMiniProgramGlobals()\n\nexport type { WebTabBarConfig, WebTabBarItem } from './appShell/tabBar'\nexport { ensureButtonDefined, setButtonFormConfig } from './button'\nexport type { ButtonFormConfig } from './button'\nexport { defineComponent } from './component'\nexport { bindRuntimeEvent } from './eventBinding'\nexport { getRuntimeExecutionMode, setRuntimeExecutionMode } from './execution'\nexport {\n getRuntimeClipboard,\n getRuntimeDialogs,\n getRuntimeFetch,\n getRuntimeStorage,\n getWebRuntimeHost,\n openRuntimeUrl,\n resetWebRuntimeHost,\n setWebRuntimeHost,\n} from './host'\nexport type { WebRuntimeClipboard, WebRuntimeDialogs, WebRuntimeHost, WebRuntimeStorage } from './host'\nexport { installWebHostGlobals } from './hostGlobals'\nexport {\n createInputEventDetail,\n createScrollEventDetail,\n createSwitchEventDetail,\n createTextareaLineChangeDetail,\n createVideoProgressDetail,\n createVideoTimeUpdateDetail,\n ensureNativeComponentsDefined,\n resolveImageModeStyle,\n resolveVideoObjectFit,\n} from './nativeComponents'\nexport { setNavigationBarMetrics } from './navigationBar'\nexport type { NavigationBarMetrics } from './navigationBar'\nexport { setPageLayout } from './pageLayout'\nexport {\n authorize,\n canIUse,\n checkSession,\n chooseAddress,\n chooseFile,\n chooseImage,\n chooseLocation,\n chooseMedia,\n chooseMessageFile,\n chooseVideo,\n clearStorage,\n clearStorageSync,\n compressImage,\n compressVideo,\n createCanvasContext,\n createInterstitialAd,\n createRewardedVideoAd,\n createSelectorQuery,\n createVideoContext,\n createVKSession,\n createWorker,\n downloadFile,\n exitMiniProgram,\n getAccountInfoSync,\n getAppAuthorizeSetting,\n getAppBaseInfo,\n getBatteryInfo,\n getBatteryInfoSync,\n getClipboardData,\n getDeviceInfo,\n getEnterOptionsSync,\n getExtConfig,\n getExtConfigSync,\n getFileSystemManager,\n getFuzzyLocation,\n getImageInfo,\n getLaunchOptionsSync,\n getLocation,\n getLogManager,\n getMenuButtonBoundingClientRect,\n getNetworkType,\n getSetting,\n getStorage,\n getStorageInfo,\n getStorageInfoSync,\n getStorageSync,\n getSystemInfo,\n getSystemInfoSync,\n getSystemSetting,\n getUpdateManager,\n getUserInfo,\n getUserProfile,\n getVideoInfo,\n getWindowInfo,\n hideKeyboard,\n hideLoading,\n hideNavigationBarLoading,\n hideTabBar,\n hideTabBarRedDot,\n initializePageRoutes,\n loadSubPackage,\n login,\n makePhoneCall,\n navigateBack,\n navigateTo,\n navigateToMiniProgram,\n nextTick,\n offAppHide,\n offAppRoute,\n offAppRouteDone,\n offAppShow,\n offBeforeAppRoute,\n offBeforePageUnload,\n offNetworkStatusChange,\n offWindowResize,\n onAppHide,\n onAppRoute,\n onAppRouteDone,\n onAppShow,\n onBeforeAppRoute,\n onBeforePageUnload,\n onNetworkStatusChange,\n onWindowResize,\n openAppAuthorizeSetting,\n openCustomerServiceChat,\n openDocument,\n openLocation,\n openSetting,\n openVideoEditor,\n pageScrollTo,\n preloadSubpackage,\n previewImage,\n previewMedia,\n redirectTo,\n registerApp,\n registerComponent,\n registerPage,\n reLaunch,\n removeStorage,\n removeStorageSync,\n removeTabBarBadge,\n reportAnalytics,\n request,\n requestPayment,\n requestSubscribeMessage,\n saveFile,\n saveFileToDisk,\n saveImageToPhotosAlbum,\n saveVideoToPhotosAlbum,\n scanCode,\n setBackgroundColor,\n setBackgroundTextStyle,\n setClipboardData,\n setNavigationBarColor,\n setNavigationBarTitle,\n setStorage,\n setStorageSync,\n setTabBarBadge,\n setTabBarItem,\n setTabBarStyle,\n showActionSheet,\n showLoading,\n showModal,\n showNavigationBarLoading,\n showShareMenu,\n showTabBar,\n showTabBarRedDot,\n showToast,\n startPullDownRefresh,\n stopPullDownRefresh,\n switchTab,\n updateShareMenu,\n uploadFile,\n vibrateShort,\n} from './polyfill'\nexport type { AppHideCallback, AppHideOptions, AppLaunchOptions, AppShowCallback } from './polyfill'\nexport type { AppRouteCallback, AppRouteEvent, AppRouteOpenType, BeforePageUnloadCallback, BeforePageUnloadEvent } from './polyfill'\nexport {\n disposeWebRouting,\n getWebRoutingConfig,\n resolveWebRoutingConfig,\n} from './polyfill/routeRuntime/history'\nexport type {\n ResolvedWebRoutingConfig,\n WebRouteHistoryState,\n WebRouteTarget,\n WebRoutingConfig,\n WebRoutingMode,\n} from './polyfill/routeRuntime/history'\nexport { createRenderContext } from './renderContext'\nexport type { RenderContext } from './renderContext'\nexport { setupRpx } from './rpx'\nexport type { RpxConfig } from './rpx'\nexport {\n configureWebSeo,\n resetWebDocumentHead,\n setupWebResourceHints,\n syncWebDocumentHead,\n updateWebDocumentTitle,\n} from './seo'\nexport type { WebPageHead, WebResourceHint, WebResourceHintRelation, WebResourceHintsConfig, WebSeoConfig } from './seo'\nexport { injectStyle, removeStyle } from './style'\nexport { createTemplate, renderTemplate } from './template'\nexport type { TemplateRenderer, TemplateScope } from './template'\nexport { getWebViewportWidth, resolveWebViewportConfig, setupWebViewport } from './viewport'\nexport type { ResolvedWebViewportConfig, WebViewportConfig } from './viewport'\nexport { setRuntimeWarningOptions } from './warning'\nexport type { RuntimeWarningLevel, RuntimeWarningOptions } from './warning'\nexport {\n installWebModuleRegistration,\n registerWebWevuApp,\n registerWebWevuComponent,\n registerWebWevuComponentFactory,\n} from './wevu'\nexport * from 'wevu/internal-runtime'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,sBAAsB;AACtB,0BAA0B"}
@@ -1,14 +1,9 @@
1
- import { CONTROL_ATTRS, hasControlAttribute, normalizeAttributeName, resolveControlAttributeValue } from "../../shared/wxml.mjs";
1
+ import { CONTROL_ATTRS, EVENT_KIND_ALIAS, hasControlAttribute, normalizeAttributeName, resolveControlAttributeValue } from "../../shared/wxml.mjs";
2
2
  import { MINI_PROGRAM_EVENT_ATTRIBUTE_PREFIX, MINI_PROGRAM_EVENT_FLAG_ATTRIBUTE_PREFIX, encodeEventAttributeName } from "../component/constants.mjs";
3
3
  import { escapeAttribute, resolveAttributeValue } from "./expression.mjs";
4
4
 
5
5
  //#region src/runtime/legacyTemplate/dom.ts
6
6
  const EVENT_PREFIX_RE = /^(bind|catch|mut-bind|capture-bind|capture-catch)([\w-]+)$/;
7
- const EVENT_KIND_ALIAS = {
8
- tap: "click",
9
- longtap: "contextmenu",
10
- longpress: "contextmenu"
11
- };
12
7
  const EVENT_PREFIX_FLAGS = {
13
8
  "bind": {},
14
9
  "catch": { catch: true },
@@ -61,7 +56,7 @@ function buildAttributeString(attribs, scope) {
61
56
  const eventInfo = parseEventAttribute(name);
62
57
  if (eventInfo) {
63
58
  const normalizedEvent = eventInfo.rawEvent.toLowerCase();
64
- const runtimeEvent = EVENT_KIND_ALIAS[normalizedEvent] ?? eventInfo.rawEvent;
59
+ const runtimeEvent = EVENT_KIND_ALIAS[normalizedEvent] ? normalizedEvent : eventInfo.rawEvent;
65
60
  const encodedEvent = encodeEventAttributeName(runtimeEvent);
66
61
  const handlerName = resolveAttributeValue(rawValue, scope).trim();
67
62
  if (!handlerName) continue;
@@ -1 +1 @@
1
- {"version":3,"file":"dom.mjs","names":[],"sources":["../../../src/runtime/legacyTemplate/dom.ts"],"sourcesContent":["import type { Element, Node } from 'domhandler'\nimport type { ExtractForResult, LegacyTemplateScope } from './types'\nimport {\n CONTROL_ATTRS,\n hasControlAttribute,\n normalizeAttributeName,\n resolveControlAttributeValue,\n} from '../../shared/wxml'\nimport {\n encodeEventAttributeName,\n MINI_PROGRAM_EVENT_ATTRIBUTE_PREFIX,\n MINI_PROGRAM_EVENT_FLAG_ATTRIBUTE_PREFIX,\n} from '../component/constants'\nimport { escapeAttribute, resolveAttributeValue } from './expression'\n\nconst EVENT_PREFIX_RE = /^(bind|catch|mut-bind|capture-bind|capture-catch)([\\w-]+)$/\nconst EVENT_KIND_ALIAS: Record<string, string> = {\n tap: 'click',\n longtap: 'contextmenu',\n longpress: 'contextmenu',\n}\n\nconst EVENT_PREFIX_FLAGS: Record<string, { catch?: boolean, capture?: boolean }> = {\n 'bind': {},\n 'catch': { catch: true },\n 'mut-bind': {},\n 'capture-bind': { capture: true },\n 'capture-catch': { capture: true, catch: true },\n}\n\nfunction parseEventAttribute(name: string) {\n const separatorIndex = name.indexOf(':')\n if (separatorIndex >= 0) {\n const prefix = name.slice(0, separatorIndex)\n const rawEvent = name.slice(separatorIndex + 1)\n if (rawEvent && prefix in EVENT_PREFIX_FLAGS) {\n return { prefix, rawEvent }\n }\n return undefined\n }\n const match = EVENT_PREFIX_RE.exec(name)\n if (!match) {\n return undefined\n }\n return { prefix: match[1]!, rawEvent: match[2]! }\n}\n\nexport function extractFor(attribs: Record<string, string>): ExtractForResult {\n const expr = resolveControlAttributeValue(attribs, 'for')\n const restAttribs: Record<string, string> = {}\n const itemName = resolveControlAttributeValue(attribs, 'for-item')?.trim() || 'item'\n let indexName = resolveControlAttributeValue(attribs, 'for-index')?.trim() || 'index'\n\n for (const [key, val] of Object.entries(attribs)) {\n if (CONTROL_ATTRS.has(key)) {\n continue\n }\n restAttribs[key] = val\n }\n\n if (itemName === indexName) {\n indexName = `${indexName}Index`\n }\n\n return {\n expr,\n itemName,\n indexName,\n restAttribs,\n }\n}\n\nexport function buildAttributeString(\n attribs: Record<string, string>,\n scope: LegacyTemplateScope,\n) {\n let result = ''\n for (const [name, rawValue] of Object.entries(attribs)) {\n if (CONTROL_ATTRS.has(name)) {\n continue\n }\n\n const eventInfo = parseEventAttribute(name)\n if (eventInfo) {\n const normalizedEvent = eventInfo.rawEvent.toLowerCase()\n const aliasedEvent = EVENT_KIND_ALIAS[normalizedEvent]\n const runtimeEvent = aliasedEvent ?? eventInfo.rawEvent\n const encodedEvent = encodeEventAttributeName(runtimeEvent)\n const handlerName = resolveAttributeValue(rawValue, scope).trim()\n if (!handlerName) {\n continue\n }\n const flags = EVENT_PREFIX_FLAGS[eventInfo.prefix]!\n result += ` ${MINI_PROGRAM_EVENT_ATTRIBUTE_PREFIX}${encodedEvent}=\"${escapeAttribute(handlerName)}\"`\n const flagTokens = [\n flags.capture ? 'capture' : '',\n flags.catch ? 'catch' : '',\n ].filter(Boolean)\n if (flagTokens.length) {\n result += ` ${MINI_PROGRAM_EVENT_FLAG_ATTRIBUTE_PREFIX}${encodedEvent}=\"${flagTokens.join(',')}\"`\n }\n continue\n }\n\n const value = resolveAttributeValue(rawValue, scope)\n if (value === '') {\n continue\n }\n const normalizedName = normalizeAttributeName(name)\n result += ` ${normalizedName}=\"${escapeAttribute(value)}\"`\n }\n return result\n}\n\nexport function stripControlAttributes(attribs: Record<string, string>) {\n const result: Record<string, string> = {}\n for (const [name, value] of Object.entries(attribs)) {\n if (!CONTROL_ATTRS.has(name)) {\n result[name] = value\n }\n }\n return result\n}\n\nexport function isConditionalElement(node: Node): node is Element {\n if (node.type !== 'tag') {\n return false\n }\n const attribs = (node as Element).attribs\n return hasControlAttribute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G;EACtD,IAAI,cAAc,IAAI,IAAI,GACxB;EAGF,MAAM,YAAY,oBAAoB,IAAI;EAC1C,IAAI,WAAW;GACb,MAAM,kBAAkB,UAAU,SAAS,YAAY;GAEvD,MAAM,eADe,iBAAiB,oBACD,UAAU;GAC/C,MAAM,eAAe,yBAAyB,YAAY;GAC1D,MAAM,cAAc,sBAAsB,UAAU,KAAK,CAAC,CAAC,KAAK;GAChE,IAAI,CAAC,aACH;GAEF,MAAM,QAAQ,mBAAmB,UAAU;GAC3C,UAAU,IAAI,sCAAsC,aAAa,IAAI,gBAAgB,WAAW,EAAE;GAClG,MAAM,aAAa,CACjB,MAAM,UAAU,YAAY,IAC5B,MAAM,QAAQ,UAAU,EAC1B,CAAC,CAAC,OAAO,OAAO;GAChB,IAAI,WAAW,QACb,UAAU,IAAI,2CAA2C,aAAa,IAAI,WAAW,KAAK,GAAG,EAAE;GAEjG;EACF;EAEA,MAAM,QAAQ,sBAAsB,UAAU,KAAK;EACnD,IAAI,UAAU,IACZ;EAEF,MAAM,iBAAiB,uBAAuB,IAAI;EAClD,UAAU,IAAI,eAAe,IAAI,gBAAgB,KAAK,EAAE;CAC1D;CACA,OAAO;AACT;AAEA,SAAgB,uBAAuB,SAAiC;CACtE,MAAM,SAAiC,CAAC;CACxC,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,OAAO,GAChD,IAAI,CAAC,cAAc,IAAI,IAAI,GACzB,OAAO,QAAQ;CAGnB,OAAO;AACT;AAEA,SAAgB,qBAAqB,MAA6B;CAChE,IAAI,KAAK,SAAS,OAChB,OAAO;CAET,MAAM,UAAW,KAAiB;CAClC,OAAO,oBAAoB,SAAS,IAAI,KACnC,oBAAoB,SAAS,MAAM,KACnC,oBAAoB,SAAS,MAAM;AAC1C"}
1
+ {"version":3,"file":"dom.mjs","names":[],"sources":["../../../src/runtime/legacyTemplate/dom.ts"],"sourcesContent":["import type { Element, Node } from 'domhandler'\nimport type { ExtractForResult, LegacyTemplateScope } from './types'\nimport {\n CONTROL_ATTRS,\n EVENT_KIND_ALIAS,\n hasControlAttribute,\n normalizeAttributeName,\n resolveControlAttributeValue,\n} from '../../shared/wxml'\nimport {\n encodeEventAttributeName,\n MINI_PROGRAM_EVENT_ATTRIBUTE_PREFIX,\n MINI_PROGRAM_EVENT_FLAG_ATTRIBUTE_PREFIX,\n} from '../component/constants'\nimport { escapeAttribute, resolveAttributeValue } from './expression'\n\nconst EVENT_PREFIX_RE = /^(bind|catch|mut-bind|capture-bind|capture-catch)([\\w-]+)$/\nconst EVENT_PREFIX_FLAGS: Record<string, { catch?: boolean, capture?: boolean }> = {\n 'bind': {},\n 'catch': { catch: true },\n 'mut-bind': {},\n 'capture-bind': { capture: true },\n 'capture-catch': { capture: true, catch: true },\n}\n\nfunction parseEventAttribute(name: string) {\n const separatorIndex = name.indexOf(':')\n if (separatorIndex >= 0) {\n const prefix = name.slice(0, separatorIndex)\n const rawEvent = name.slice(separatorIndex + 1)\n if (rawEvent && prefix in EVENT_PREFIX_FLAGS) {\n return { prefix, rawEvent }\n }\n return undefined\n }\n const match = EVENT_PREFIX_RE.exec(name)\n if (!match) {\n return undefined\n }\n return { prefix: match[1]!, rawEvent: match[2]! }\n}\n\nexport function extractFor(attribs: Record<string, string>): ExtractForResult {\n const expr = resolveControlAttributeValue(attribs, 'for')\n const restAttribs: Record<string, string> = {}\n const itemName = resolveControlAttributeValue(attribs, 'for-item')?.trim() || 'item'\n let indexName = resolveControlAttributeValue(attribs, 'for-index')?.trim() || 'index'\n\n for (const [key, val] of Object.entries(attribs)) {\n if (CONTROL_ATTRS.has(key)) {\n continue\n }\n restAttribs[key] = val\n }\n\n if (itemName === indexName) {\n indexName = `${indexName}Index`\n }\n\n return {\n expr,\n itemName,\n indexName,\n restAttribs,\n }\n}\n\nexport function buildAttributeString(\n attribs: Record<string, string>,\n scope: LegacyTemplateScope,\n) {\n let result = ''\n for (const [name, rawValue] of Object.entries(attribs)) {\n if (CONTROL_ATTRS.has(name)) {\n continue\n }\n\n const eventInfo = parseEventAttribute(name)\n if (eventInfo) {\n const normalizedEvent = eventInfo.rawEvent.toLowerCase()\n const aliasedEvent = EVENT_KIND_ALIAS[normalizedEvent]\n const runtimeEvent = aliasedEvent ? normalizedEvent : eventInfo.rawEvent\n const encodedEvent = encodeEventAttributeName(runtimeEvent)\n const handlerName = resolveAttributeValue(rawValue, scope).trim()\n if (!handlerName) {\n continue\n }\n const flags = EVENT_PREFIX_FLAGS[eventInfo.prefix]!\n result += ` ${MINI_PROGRAM_EVENT_ATTRIBUTE_PREFIX}${encodedEvent}=\"${escapeAttribute(handlerName)}\"`\n const flagTokens = [\n flags.capture ? 'capture' : '',\n flags.catch ? 'catch' : '',\n ].filter(Boolean)\n if (flagTokens.length) {\n result += ` ${MINI_PROGRAM_EVENT_FLAG_ATTRIBUTE_PREFIX}${encodedEvent}=\"${flagTokens.join(',')}\"`\n }\n continue\n }\n\n const value = resolveAttributeValue(rawValue, scope)\n if (value === '') {\n continue\n }\n const normalizedName = normalizeAttributeName(name)\n result += ` ${normalizedName}=\"${escapeAttribute(value)}\"`\n }\n return result\n}\n\nexport function stripControlAttributes(attribs: Record<string, string>) {\n const result: Record<string, string> = {}\n for (const [name, value] of Object.entries(attribs)) {\n if (!CONTROL_ATTRS.has(name)) {\n result[name] = value\n }\n }\n return result\n}\n\nexport function isConditionalElement(node: Node): node is Element {\n if (node.type !== 'tag') {\n return false\n }\n const attribs = (node as Element).attribs\n return hasControlAttribute(attribs, 'if')\n || hasControlAttribute(attribs, 'elif')\n || hasControlAttribute(attribs, 'else')\n}\n"],"mappings":";;;;;AAgBA,MAAM,kBAAkB;AACxB,MAAM,qBAA6E;CACjF,QAAQ,CAAC;CACT,SAAS,EAAE,OAAO,KAAK;CACvB,YAAY,CAAC;CACb,gBAAgB,EAAE,SAAS,KAAK;CAChC,iBAAiB;EAAE,SAAS;EAAM,OAAO;CAAK;AAChD;AAEA,SAAS,oBAAoB,MAAc;CACzC,MAAM,iBAAiB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EAAE;GAClG,MAAM,aAAa,CACjB,MAAM,UAAU,YAAY,IAC5B,MAAM,QAAQ,UAAU,EAC1B,CAAC,CAAC,OAAO,OAAO;GAChB,IAAI,WAAW,QACb,UAAU,IAAI,2CAA2C,aAAa,IAAI,WAAW,KAAK,GAAG,EAAE;GAEjG;EACF;EAEA,MAAM,QAAQ,sBAAsB,UAAU,KAAK;EACnD,IAAI,UAAU,IACZ;EAEF,MAAM,iBAAiB,uBAAuB,IAAI;EAClD,UAAU,IAAI,eAAe,IAAI,gBAAgB,KAAK,EAAE;CAC1D;CACA,OAAO;AACT;AAEA,SAAgB,uBAAuB,SAAiC;CACtE,MAAM,SAAiC,CAAC;CACxC,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,OAAO,GAChD,IAAI,CAAC,cAAc,IAAI,IAAI,GACzB,OAAO,QAAQ;CAGnB,OAAO;AACT;AAEA,SAAgB,qBAAqB,MAA6B;CAChE,IAAI,KAAK,SAAS,OAChB,OAAO;CAET,MAAM,UAAW,KAAiB;CAClC,OAAO,oBAAoB,SAAS,IAAI,KACnC,oBAAoB,SAAS,MAAM,KACnC,oBAAoB,SAAS,MAAM;AAC1C"}
@@ -23,7 +23,9 @@ var WeappCanvas = class extends BaseElement {
23
23
  disconnectedCallback() {
24
24
  if (this.#canvas) unregisterNativeMediaElement(this.#canvas);
25
25
  }
26
- attributeChangedCallback() {
26
+ attributeChangedCallback(name, previous, current) {
27
+ if (previous === current) return;
28
+ if (name === "width" || name === "height") this.#syncSize(name);
27
29
  this.#syncAttributes();
28
30
  }
29
31
  #ensureStructure() {
@@ -37,12 +39,19 @@ var WeappCanvas = class extends BaseElement {
37
39
  const canvas = document.createElement("canvas");
38
40
  root.append(style, canvas);
39
41
  this.#canvas = canvas;
42
+ this.#syncSize();
43
+ }
44
+ #syncSize(dimension) {
45
+ const canvas = this.#canvas;
46
+ if (!canvas) return;
47
+ for (const name of dimension ? [dimension] : ["width", "height"]) {
48
+ const size = resolveCanvasSize(this.getAttribute(name), name === "width" ? 300 : 150);
49
+ if (canvas[name] !== size) canvas[name] = size;
50
+ }
40
51
  }
41
52
  #syncAttributes() {
42
53
  const canvas = this.#canvas;
43
54
  if (!canvas) return;
44
- canvas.width = resolveCanvasSize(this.getAttribute("width"), 300);
45
- canvas.height = resolveCanvasSize(this.getAttribute("height"), 150);
46
55
  canvas.style.touchAction = readBooleanAttribute(this, "disable-scroll") ? "none" : "";
47
56
  registerNativeMediaElement("canvas", [this.getAttribute("canvas-id"), this.getAttribute("id")], canvas);
48
57
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/runtime/nativeComponents/canvas/index.ts"],"sourcesContent":["import { getNativeComponentDescriptor } from '../../../shared/nativeComponents'\nimport { readBooleanAttribute, resolveContainingShadowRoot } from '../helpers'\nimport { registerNativeMediaElement, unregisterNativeMediaElement } from '../mediaRegistry'\nimport { ensureNativeComponentStyle } from '../style'\n\nconst BaseElement = (globalThis.HTMLElement ?? class {}) as typeof HTMLElement\n\nfunction resolveCanvasSize(value: string | null, fallback: number) {\n const size = Number(value)\n return Number.isInteger(size) && size > 0 ? size : fallback\n}\n\nexport class WeappCanvas extends BaseElement {\n static observedAttributes = [...getNativeComponentDescriptor('canvas')!.attributes]\n\n #canvas?: HTMLCanvasElement\n\n get canvasElement() {\n return this.#canvas\n }\n\n connectedCallback() {\n ensureNativeComponentStyle(resolveContainingShadowRoot(this))\n this.#ensureStructure()\n this.#syncAttributes()\n }\n\n disconnectedCallback() {\n if (this.#canvas) {\n unregisterNativeMediaElement(this.#canvas)\n }\n }\n\n attributeChangedCallback() {\n this.#syncAttributes()\n }\n\n #ensureStructure() {\n if (this.#canvas || typeof document === 'undefined') {\n return\n }\n const root = this.shadowRoot ?? this.attachShadow({ mode: 'open' })\n const style = document.createElement('style')\n style.textContent = `\n :host { position: relative; }\n canvas { display: block; }\n `\n const canvas = document.createElement('canvas')\n root.append(style, canvas)\n this.#canvas = canvas\n }\n\n #syncAttributes() {\n const canvas = this.#canvas\n if (!canvas) {\n return\n }\n canvas.width = resolveCanvasSize(this.getAttribute('width'), 300)\n canvas.height = resolveCanvasSize(this.getAttribute('height'), 150)\n canvas.style.touchAction = readBooleanAttribute(this, 'disable-scroll') ? 'none' : ''\n registerNativeMediaElement('canvas', [\n this.getAttribute('canvas-id'),\n this.getAttribute('id'),\n ], canvas)\n }\n}\n"],"mappings":";;;;;;AAKA,MAAM,cAAe,WAAW,eAAe,MAAM,CAAC;AAEtD,SAAS,kBAAkB,OAAsB,UAAkB;CACjE,MAAM,OAAO,OAAO,KAAK;CACzB,OAAO,OAAO,UAAU,IAAI,KAAK,OAAO,IAAI,OAAO;AACrD;AAEA,IAAa,cAAb,cAAiC,YAAY;CAC3C,OAAO,qBAAqB,CAAC,GAAG,6BAA6B,QAAQ,CAAC,CAAE,UAAU;CAElF;CAEA,IAAI,gBAAgB;EAClB,OAAO,KAAK;CACd;CAEA,oBAAoB;EAClB,2BAA2B,4BAA4B,IAAI,CAAC;EAC5D,KAAK,iBAAiB;EACtB,KAAK,gBAAgB;CACvB;CAEA,uBAAuB;EACrB,IAAI,KAAK,SACP,6BAA6B,KAAK,OAAO;CAE7C;CAEA,2BAA2B;EACzB,KAAK,gBAAgB;CACvB;CAEA,mBAAmB;EACjB,IAAI,KAAK,WAAW,OAAO,aAAa,aACtC;EAEF,MAAM,OAAO,KAAK,cAAc,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;EAClE,MAAM,QAAQ,SAAS,cAAc,OAAO;EAC5C,MAAM,cAAc;;;;EAIpB,MAAM,SAAS,SAAS,cAAc,QAAQ;EAC9C,KAAK,OAAO,OAAO,MAAM;EACzB,KAAK,UAAU;CACjB;CAEA,kBAAkB;EAChB,MAAM,SAAS,KAAK;EACpB,IAAI,CAAC,QACH;EAEF,OAAO,QAAQ,kBAAkB,KAAK,aAAa,OAAO,GAAG,GAAG;EAChE,OAAO,SAAS,kBAAkB,KAAK,aAAa,QAAQ,GAAG,GAAG;EAClE,OAAO,MAAM,cAAc,qBAAqB,MAAM,gBAAgB,IAAI,SAAS;EACnF,2BAA2B,UAAU,CACnC,KAAK,aAAa,WAAW,GAC7B,KAAK,aAAa,IAAI,CACxB,GAAG,MAAM;CACX;AACF"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/runtime/nativeComponents/canvas/index.ts"],"sourcesContent":["import { getNativeComponentDescriptor } from '../../../shared/nativeComponents'\nimport { readBooleanAttribute, resolveContainingShadowRoot } from '../helpers'\nimport { registerNativeMediaElement, unregisterNativeMediaElement } from '../mediaRegistry'\nimport { ensureNativeComponentStyle } from '../style'\n\nconst BaseElement = (globalThis.HTMLElement ?? class {}) as typeof HTMLElement\n\nfunction resolveCanvasSize(value: string | null, fallback: number) {\n const size = Number(value)\n return Number.isInteger(size) && size > 0 ? size : fallback\n}\n\nexport class WeappCanvas extends BaseElement {\n static observedAttributes = [...getNativeComponentDescriptor('canvas')!.attributes]\n\n #canvas?: HTMLCanvasElement\n\n get canvasElement() {\n return this.#canvas\n }\n\n connectedCallback() {\n ensureNativeComponentStyle(resolveContainingShadowRoot(this))\n this.#ensureStructure()\n this.#syncAttributes()\n }\n\n disconnectedCallback() {\n if (this.#canvas) {\n unregisterNativeMediaElement(this.#canvas)\n }\n }\n\n attributeChangedCallback(name: string, previous: string | null, current: string | null) {\n if (previous === current) {\n return\n }\n if (name === 'width' || name === 'height') {\n this.#syncSize(name)\n }\n this.#syncAttributes()\n }\n\n #ensureStructure() {\n if (this.#canvas || typeof document === 'undefined') {\n return\n }\n const root = this.shadowRoot ?? this.attachShadow({ mode: 'open' })\n const style = document.createElement('style')\n style.textContent = `\n :host { position: relative; }\n canvas { display: block; }\n `\n const canvas = document.createElement('canvas')\n root.append(style, canvas)\n this.#canvas = canvas\n this.#syncSize()\n }\n\n #syncSize(dimension?: 'width' | 'height') {\n const canvas = this.#canvas\n if (!canvas) {\n return\n }\n // 相同尺寸赋值也会清空位图和绘图状态;尺寸只归对应宿主属性的实际变化所有。\n for (const name of dimension ? [dimension] : ['width', 'height'] as const) {\n const size = resolveCanvasSize(this.getAttribute(name), name === 'width' ? 300 : 150)\n if (canvas[name] !== size) {\n canvas[name] = size\n }\n }\n }\n\n #syncAttributes() {\n const canvas = this.#canvas\n if (!canvas) {\n return\n }\n canvas.style.touchAction = readBooleanAttribute(this, 'disable-scroll') ? 'none' : ''\n registerNativeMediaElement('canvas', [\n this.getAttribute('canvas-id'),\n this.getAttribute('id'),\n ], canvas)\n }\n}\n"],"mappings":";;;;;;AAKA,MAAM,cAAe,WAAW,eAAe,MAAM,CAAC;AAEtD,SAAS,kBAAkB,OAAsB,UAAkB;CACjE,MAAM,OAAO,OAAO,KAAK;CACzB,OAAO,OAAO,UAAU,IAAI,KAAK,OAAO,IAAI,OAAO;AACrD;AAEA,IAAa,cAAb,cAAiC,YAAY;CAC3C,OAAO,qBAAqB,CAAC,GAAG,6BAA6B,QAAQ,CAAC,CAAE,UAAU;CAElF;CAEA,IAAI,gBAAgB;EAClB,OAAO,KAAK;CACd;CAEA,oBAAoB;EAClB,2BAA2B,4BAA4B,IAAI,CAAC;EAC5D,KAAK,iBAAiB;EACtB,KAAK,gBAAgB;CACvB;CAEA,uBAAuB;EACrB,IAAI,KAAK,SACP,6BAA6B,KAAK,OAAO;CAE7C;CAEA,yBAAyB,MAAc,UAAyB,SAAwB;EACtF,IAAI,aAAa,SACf;EAEF,IAAI,SAAS,WAAW,SAAS,UAC/B,KAAK,UAAU,IAAI;EAErB,KAAK,gBAAgB;CACvB;CAEA,mBAAmB;EACjB,IAAI,KAAK,WAAW,OAAO,aAAa,aACtC;EAEF,MAAM,OAAO,KAAK,cAAc,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;EAClE,MAAM,QAAQ,SAAS,cAAc,OAAO;EAC5C,MAAM,cAAc;;;;EAIpB,MAAM,SAAS,SAAS,cAAc,QAAQ;EAC9C,KAAK,OAAO,OAAO,MAAM;EACzB,KAAK,UAAU;EACf,KAAK,UAAU;CACjB;CAEA,UAAU,WAAgC;EACxC,MAAM,SAAS,KAAK;EACpB,IAAI,CAAC,QACH;EAGF,KAAK,MAAM,QAAQ,YAAY,CAAC,SAAS,IAAI,CAAC,SAAS,QAAQ,GAAY;GACzE,MAAM,OAAO,kBAAkB,KAAK,aAAa,IAAI,GAAG,SAAS,UAAU,MAAM,GAAG;GACpF,IAAI,OAAO,UAAU,MACnB,OAAO,QAAQ;EAEnB;CACF;CAEA,kBAAkB;EAChB,MAAM,SAAS,KAAK;EACpB,IAAI,CAAC,QACH;EAEF,OAAO,MAAM,cAAc,qBAAqB,MAAM,gBAAgB,IAAI,SAAS;EACnF,2BAA2B,UAAU,CACnC,KAAK,aAAa,WAAW,GAC7B,KAAK,aAAa,IAAI,CACxB,GAAG,MAAM;CACX;AACF"}
@@ -3,6 +3,7 @@ import { AdBaseOptions, GetExtConfigOptions, InterstitialAd, RewardedVideoAd } f
3
3
  import { AppHideCallback, AppHideOptions, AppLaunchOptions, AppShowCallback } from "./routeRuntime/options.mjs";
4
4
  import { authorize, checkSession, getAccountInfoSync, getAppAuthorizeSetting, getAppBaseInfo, getBatteryInfo, getBatteryInfoSync, getDeviceInfo, getFuzzyLocation, getLocation, getMenuButtonBoundingClientRect, getNetworkType, getSetting, getSystemInfo, getSystemInfoSync, getSystemSetting, getUserInfo, getUserProfile, getWindowInfo, login, offNetworkStatusChange, offWindowResize, onNetworkStatusChange, onWindowResize, openAppAuthorizeSetting, openSetting, vibrateShort } from "./deviceAuthSystemApi.mjs";
5
5
  import { getEnterOptionsSync, getLaunchOptionsSync, initializePageRoutes, navigateBack, navigateTo, offAppHide, offAppShow, onAppHide, onAppShow, reLaunch, redirectTo, registerApp, registerComponent, registerPage, switchTab } from "./routeRuntime.mjs";
6
+ import { AppRouteCallback, AppRouteEvent, AppRouteOpenType, BeforePageUnloadCallback, BeforePageUnloadEvent, offAppRoute, offAppRouteDone, offBeforeAppRoute, offBeforePageUnload, onAppRoute, onAppRouteDone, onBeforeAppRoute, onBeforePageUnload } from "./routeRuntime/events.mjs";
6
7
  import { clearStorage, clearStorageSync, createCanvasContext, createSelectorQuery, createVKSession, createVideoContext, createWorker, downloadFile, exitMiniProgram, getFileSystemManager, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, hideKeyboard, loadSubPackage, navigateToMiniProgram, nextTick, pageScrollTo, preloadSubpackage, removeStorage, removeStorageSync, request, setStorage, setStorageSync, startPullDownRefresh, stopPullDownRefresh, uploadFile } from "./runtimeDataApi.mjs";
7
8
  import { chooseAddress, chooseFile, chooseImage, chooseLocation, chooseMedia, chooseMessageFile, chooseVideo, compressImage, compressVideo, getClipboardData, getImageInfo, getVideoInfo, hideLoading, hideTabBar, hideTabBarRedDot, makePhoneCall, openCustomerServiceChat, openDocument, openLocation, openVideoEditor, previewImage, previewMedia, removeTabBarBadge, requestPayment, requestSubscribeMessage, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, setClipboardData, setTabBarBadge, setTabBarItem, setTabBarStyle, showActionSheet, showLoading, showModal, showShareMenu, showTabBar, showTabBarRedDot, showToast, updateShareMenu } from "./uiMediaApi.mjs";
8
9
  //#region src/runtime/polyfill/index.d.ts
@@ -36,5 +37,5 @@ export declare function getUpdateManager(): UpdateManager;
36
37
  export declare function getLogManager(options?: LogManagerOptions): LogManager;
37
38
  export declare function reportAnalytics(eventName: string, data?: Record<string, unknown>): void;
38
39
  //#endregion
39
- export { type AppHideCallback, type AppHideOptions, type AppLaunchOptions, type AppShowCallback, authorize, checkSession, chooseAddress, chooseFile, chooseImage, chooseLocation, chooseMedia, chooseMessageFile, chooseVideo, clearStorage, clearStorageSync, compressImage, compressVideo, createCanvasContext, createSelectorQuery, createVKSession, createVideoContext, createWorker, downloadFile, exitMiniProgram, getAccountInfoSync, getAppAuthorizeSetting, getAppBaseInfo, getBatteryInfo, getBatteryInfoSync, getClipboardData, getDeviceInfo, getEnterOptionsSync, getFileSystemManager, getFuzzyLocation, getImageInfo, getLaunchOptionsSync, getLocation, getMenuButtonBoundingClientRect, getNetworkType, getSetting, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, getSystemInfo, getSystemInfoSync, getSystemSetting, getUserInfo, getUserProfile, getVideoInfo, getWindowInfo, hideKeyboard, hideLoading, hideTabBar, hideTabBarRedDot, initializePageRoutes, loadSubPackage, login, makePhoneCall, navigateBack, navigateTo, navigateToMiniProgram, nextTick, offAppHide, offAppShow, offNetworkStatusChange, offWindowResize, onAppHide, onAppShow, onNetworkStatusChange, onWindowResize, openAppAuthorizeSetting, openCustomerServiceChat, openDocument, openLocation, openSetting, openVideoEditor, pageScrollTo, preloadSubpackage, previewImage, previewMedia, reLaunch, redirectTo, registerApp, registerComponent, registerPage, removeStorage, removeStorageSync, removeTabBarBadge, request, requestPayment, requestSubscribeMessage, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, setClipboardData, setStorage, setStorageSync, setTabBarBadge, setTabBarItem, setTabBarStyle, showActionSheet, showLoading, showModal, showShareMenu, showTabBar, showTabBarRedDot, showToast, startPullDownRefresh, stopPullDownRefresh, switchTab, updateShareMenu, uploadFile, vibrateShort };
40
+ export { type AppHideCallback, type AppHideOptions, type AppLaunchOptions, type AppRouteCallback, type AppRouteEvent, type AppRouteOpenType, type AppShowCallback, type BeforePageUnloadCallback, type BeforePageUnloadEvent, authorize, checkSession, chooseAddress, chooseFile, chooseImage, chooseLocation, chooseMedia, chooseMessageFile, chooseVideo, clearStorage, clearStorageSync, compressImage, compressVideo, createCanvasContext, createSelectorQuery, createVKSession, createVideoContext, createWorker, downloadFile, exitMiniProgram, getAccountInfoSync, getAppAuthorizeSetting, getAppBaseInfo, getBatteryInfo, getBatteryInfoSync, getClipboardData, getDeviceInfo, getEnterOptionsSync, getFileSystemManager, getFuzzyLocation, getImageInfo, getLaunchOptionsSync, getLocation, getMenuButtonBoundingClientRect, getNetworkType, getSetting, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, getSystemInfo, getSystemInfoSync, getSystemSetting, getUserInfo, getUserProfile, getVideoInfo, getWindowInfo, hideKeyboard, hideLoading, hideTabBar, hideTabBarRedDot, initializePageRoutes, loadSubPackage, login, makePhoneCall, navigateBack, navigateTo, navigateToMiniProgram, nextTick, offAppHide, offAppRoute, offAppRouteDone, offAppShow, offBeforeAppRoute, offBeforePageUnload, offNetworkStatusChange, offWindowResize, onAppHide, onAppRoute, onAppRouteDone, onAppShow, onBeforeAppRoute, onBeforePageUnload, onNetworkStatusChange, onWindowResize, openAppAuthorizeSetting, openCustomerServiceChat, openDocument, openLocation, openSetting, openVideoEditor, pageScrollTo, preloadSubpackage, previewImage, previewMedia, reLaunch, redirectTo, registerApp, registerComponent, registerPage, removeStorage, removeStorageSync, removeTabBarBadge, request, requestPayment, requestSubscribeMessage, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, setClipboardData, setStorage, setStorageSync, setTabBarBadge, setTabBarItem, setTabBarStyle, showActionSheet, showLoading, showModal, showShareMenu, showTabBar, showTabBarRedDot, showToast, startPullDownRefresh, stopPullDownRefresh, switchTab, updateShareMenu, uploadFile, vibrateShort };
40
41
  //# sourceMappingURL=index.d.mts.map
@@ -11,10 +11,13 @@ import { loadFontFace } from "./font.mjs";
11
11
  import { getLocale } from "./locale.mjs";
12
12
  import { createNavigationBarRuntimeBridge } from "./navigationBarRuntime.mjs";
13
13
  import { createInterstitialAdBridge, createRewardedVideoAdBridge, getExtConfigBridge, getExtConfigSyncBridge, getLogManagerBridge, getUpdateManagerBridge, reportAnalyticsBridge } from "./platformApi.mjs";
14
+ import { claimPageScrollRestoration } from "./routeRuntime/scroll.mjs";
14
15
  import { clearStorage, clearStorageSync, createCanvasContext, createIntersectionObserver, createSelectorQuery, createVKSession, createVideoContext, createWorker, downloadFile, exitMiniProgram, getFileSystemManager, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, hideKeyboard, loadSubPackage, navigateToMiniProgram, nextTick, pageScrollTo, preloadSubpackage, removeStorage, removeStorageSync, request, runtimeDataApi_exports, setStorage, setStorageSync, startPullDownRefresh, stopPullDownRefresh, uploadFile } from "./runtimeDataApi.mjs";
16
+ import { offAppRoute, offAppRouteDone, offBeforeAppRoute, offBeforePageUnload, onAppRoute, onAppRouteDone, onBeforeAppRoute, onBeforePageUnload } from "./routeRuntime/events.mjs";
15
17
  import { getAppInstance, getCurrentPagesInternal, getEnterOptionsSync, getLaunchOptionsSync, initializePageRoutes, navigateBack, navigateTo, offAppHide, offAppShow, onAppHide, onAppShow, reLaunch, redirectTo, registerApp, registerComponent, registerPage, switchTab } from "./routeRuntime.mjs";
16
18
  import { chooseAddress, chooseFile, chooseImage, chooseLocation, chooseMedia, chooseMessageFile, chooseVideo, compressImage, compressVideo, getClipboardData, getImageInfo, getVideoInfo, hideLoading, hideTabBar, hideTabBarRedDot, makePhoneCall, openCustomerServiceChat, openDocument, openLocation, openVideoEditor, previewImage, previewMedia, removeTabBarBadge, requestPayment, requestSubscribeMessage, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, setClipboardData, setTabBarBadge, setTabBarItem, setTabBarStyle, showActionSheet, showLoading, showModal, showShareMenu, showTabBar, showTabBarRedDot, showToast, uiMediaApi_exports, updateShareMenu } from "./uiMediaApi.mjs";
17
19
  import { getDefaultMiniProgramRuntimeGlobalKey, getMiniProgramRuntimeGlobalKeys } from "@weapp-core/shared/platforms/runtime";
20
+ import { WEVU_PAGE_SCROLL_EVENT_CONTRACT_KEY, WEVU_PAGE_SCROLL_RESTORATION_OWNER_KEY, WEVU_ROUTE_EVENT_CONTRACT_KEY } from "@weapp-core/constants";
18
21
 
19
22
  //#region src/runtime/polyfill/index.ts
20
23
  const MINI_PROGRAM_GLOBAL_KEYS = getMiniProgramRuntimeGlobalKeys();
@@ -85,6 +88,17 @@ function installMiniProgramGlobals() {
85
88
  offAppShow,
86
89
  onAppHide,
87
90
  onAppShow,
91
+ offAppRoute,
92
+ offAppRouteDone,
93
+ offBeforeAppRoute,
94
+ offBeforePageUnload,
95
+ onAppRoute,
96
+ onAppRouteDone,
97
+ onBeforeAppRoute,
98
+ onBeforePageUnload,
99
+ [WEVU_PAGE_SCROLL_RESTORATION_OWNER_KEY]: claimPageScrollRestoration,
100
+ [WEVU_ROUTE_EVENT_CONTRACT_KEY]: 1,
101
+ [WEVU_PAGE_SCROLL_EVENT_CONTRACT_KEY]: 1,
88
102
  ...runtimeDataApi_exports,
89
103
  setNavigationBarTitle,
90
104
  setNavigationBarColor,
@@ -117,5 +131,5 @@ function installMiniProgramGlobals() {
117
131
  }
118
132
 
119
133
  //#endregion
120
- export { $emit, $off, $on, $once, authorize, canIUse, checkSession, chooseAddress, chooseFile, chooseImage, chooseLocation, chooseMedia, chooseMessageFile, chooseVideo, clearStorage, clearStorageSync, compressImage, compressVideo, createCanvasContext, createIntersectionObserver, createInterstitialAd, createRewardedVideoAd, createSelectorQuery, createVKSession, createVideoContext, createWorker, downloadFile, exitMiniProgram, getAccountInfoSync, getAppAuthorizeSetting, getAppBaseInfo, getBatteryInfo, getBatteryInfoSync, getClipboardData, getDeviceInfo, getEnterOptionsSync, getExtConfig, getExtConfigSync, getFileSystemManager, getFuzzyLocation, getImageInfo, getLaunchOptionsSync, getLocation, getLogManager, getMenuButtonBoundingClientRect, getNetworkType, getSetting, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, getSystemInfo, getSystemInfoSync, getSystemSetting, getUpdateManager, getUserInfo, getUserProfile, getVideoInfo, getWindowInfo, hideKeyboard, hideLoading, hideNavigationBarLoading, hideTabBar, hideTabBarRedDot, initializePageRoutes, installMiniProgramGlobals, loadSubPackage, login, makePhoneCall, navigateBack, navigateTo, navigateToMiniProgram, nextTick, offAppHide, offAppShow, offNetworkStatusChange, offWindowResize, onAppHide, onAppShow, onNetworkStatusChange, onWindowResize, openAppAuthorizeSetting, openCustomerServiceChat, openDocument, openLocation, openSetting, openVideoEditor, pageScrollTo, preloadSubpackage, previewImage, previewMedia, reLaunch, redirectTo, registerApp, registerComponent, registerPage, removeStorage, removeStorageSync, removeTabBarBadge, reportAnalytics, request, requestPayment, requestSubscribeMessage, rpx2px, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, setBackgroundColor, setBackgroundTextStyle, setClipboardData, setNavigationBarColor, setNavigationBarTitle, setStorage, setStorageSync, setTabBarBadge, setTabBarItem, setTabBarStyle, showActionSheet, showLoading, showModal, showNavigationBarLoading, showShareMenu, showTabBar, showTabBarRedDot, showToast, startPullDownRefresh, stopPullDownRefresh, switchTab, updateShareMenu, uploadFile, upx2px, vibrateShort };
134
+ export { $emit, $off, $on, $once, authorize, canIUse, checkSession, chooseAddress, chooseFile, chooseImage, chooseLocation, chooseMedia, chooseMessageFile, chooseVideo, clearStorage, clearStorageSync, compressImage, compressVideo, createCanvasContext, createIntersectionObserver, createInterstitialAd, createRewardedVideoAd, createSelectorQuery, createVKSession, createVideoContext, createWorker, downloadFile, exitMiniProgram, getAccountInfoSync, getAppAuthorizeSetting, getAppBaseInfo, getBatteryInfo, getBatteryInfoSync, getClipboardData, getDeviceInfo, getEnterOptionsSync, getExtConfig, getExtConfigSync, getFileSystemManager, getFuzzyLocation, getImageInfo, getLaunchOptionsSync, getLocation, getLogManager, getMenuButtonBoundingClientRect, getNetworkType, getSetting, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, getSystemInfo, getSystemInfoSync, getSystemSetting, getUpdateManager, getUserInfo, getUserProfile, getVideoInfo, getWindowInfo, hideKeyboard, hideLoading, hideNavigationBarLoading, hideTabBar, hideTabBarRedDot, initializePageRoutes, installMiniProgramGlobals, loadSubPackage, login, makePhoneCall, navigateBack, navigateTo, navigateToMiniProgram, nextTick, offAppHide, offAppRoute, offAppRouteDone, offAppShow, offBeforeAppRoute, offBeforePageUnload, offNetworkStatusChange, offWindowResize, onAppHide, onAppRoute, onAppRouteDone, onAppShow, onBeforeAppRoute, onBeforePageUnload, onNetworkStatusChange, onWindowResize, openAppAuthorizeSetting, openCustomerServiceChat, openDocument, openLocation, openSetting, openVideoEditor, pageScrollTo, preloadSubpackage, previewImage, previewMedia, reLaunch, redirectTo, registerApp, registerComponent, registerPage, removeStorage, removeStorageSync, removeTabBarBadge, reportAnalytics, request, requestPayment, requestSubscribeMessage, rpx2px, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, setBackgroundColor, setBackgroundTextStyle, setClipboardData, setNavigationBarColor, setNavigationBarTitle, setStorage, setStorageSync, setTabBarBadge, setTabBarItem, setTabBarStyle, showActionSheet, showLoading, showModal, showNavigationBarLoading, showShareMenu, showTabBar, showTabBarRedDot, showToast, startPullDownRefresh, stopPullDownRefresh, switchTab, updateShareMenu, uploadFile, upx2px, vibrateShort };
121
135
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["runtimeDataApi","uiMediaApi","deviceAuthSystemApi","eventBusApi"],"sources":["../../../src/runtime/polyfill/index.ts"],"sourcesContent":["import type {\n AdBaseOptions,\n CloudBridge,\n GetExtConfigOptions,\n InterstitialAd,\n LogManager,\n LogManagerOptions,\n MiniProgramAsyncOptions,\n MiniProgramBaseResult,\n RewardedVideoAd,\n SetBackgroundColorOptions,\n SetBackgroundTextStyleOptions,\n UpdateManager,\n} from './types'\nimport { getDefaultMiniProgramRuntimeGlobalKey, getMiniProgramRuntimeGlobalKeys } from '@weapp-core/shared/platforms/runtime'\nimport { emitRuntimeWarning } from '../warning'\nimport { createAnimation } from './animation'\nimport {\n callMiniProgramAsyncFailure,\n callMiniProgramAsyncSuccess,\n} from './async'\nimport {\n setBackgroundColorBridge,\n setBackgroundTextStyleBridge,\n} from './background'\nimport { createCloudBridge } from './cloud'\nimport * as deviceAuthSystemApi from './deviceAuthSystemApi'\nimport * as eventBusApi from './eventBus'\nimport { WEB_USER_DATA_PATH } from './files'\nimport { loadFontFace } from './font'\nimport { getLocale } from './locale'\nimport { createNavigationBarRuntimeBridge } from './navigationBarRuntime'\nimport {\n createInterstitialAdBridge,\n createRewardedVideoAdBridge,\n getExtConfigBridge,\n getExtConfigSyncBridge,\n getLogManagerBridge,\n getUpdateManagerBridge,\n reportAnalyticsBridge,\n} from './platformApi'\nimport {\n getAppInstance,\n getCurrentPagesInternal,\n getEnterOptionsSync,\n getLaunchOptionsSync,\n navigateBack,\n navigateTo,\n offAppHide,\n offAppShow,\n onAppHide,\n onAppShow,\n redirectTo,\n reLaunch,\n switchTab,\n} from './routeRuntime'\nimport {\n canIUseBridge,\n} from './runtimeCapabilityApi'\nimport * as runtimeDataApi from './runtimeDataApi'\nimport * as uiMediaApi from './uiMediaApi'\n\nexport { createAnimation } from './animation'\nexport * from './deviceAuthSystemApi'\nexport * from './eventBus'\nexport { loadFontFace } from './font'\nexport { getLocale } from './locale'\n\nexport {\n getEnterOptionsSync,\n getLaunchOptionsSync,\n initializePageRoutes,\n navigateBack,\n navigateTo,\n offAppHide,\n offAppShow,\n onAppHide,\n onAppShow,\n redirectTo,\n registerApp,\n registerComponent,\n registerPage,\n reLaunch,\n switchTab,\n} from './routeRuntime'\n\nexport type { AppHideCallback, AppHideOptions, AppLaunchOptions, AppShowCallback } from './routeRuntime/options'\n\nexport * from './runtimeDataApi'\nexport * from './uiMediaApi'\n\nconst MINI_PROGRAM_GLOBAL_KEYS = getMiniProgramRuntimeGlobalKeys()\nconst DEFAULT_MINI_PROGRAM_GLOBAL_KEY = getDefaultMiniProgramRuntimeGlobalKey()\nconst globalTarget = globalThis as Record<string, unknown>\n\nfunction resolveMiniProgramBridge() {\n for (const runtimeGlobalKey of MINI_PROGRAM_GLOBAL_KEYS) {\n const candidate = globalTarget[runtimeGlobalKey]\n if (candidate && typeof candidate === 'object') {\n return candidate as Record<string, unknown>\n }\n }\n return undefined\n}\n\nconst navigationBarRuntimeBridge = createNavigationBarRuntimeBridge(\n () => getCurrentPagesInternal() as Array<HTMLElement & { renderRoot?: ShadowRoot | HTMLElement }>,\n emitRuntimeWarning,\n)\n\nexport function setNavigationBarTitle(options: { title: string }) {\n return navigationBarRuntimeBridge.setNavigationBarTitle(options)\n}\n\nexport function setNavigationBarColor(options: {\n frontColor?: string\n backgroundColor?: string\n animation?: { duration?: number, timingFunction?: string }\n}) {\n return navigationBarRuntimeBridge.setNavigationBarColor(options)\n}\n\nexport function showNavigationBarLoading() {\n return navigationBarRuntimeBridge.showNavigationBarLoading()\n}\n\nexport function hideNavigationBarLoading() {\n return navigationBarRuntimeBridge.hideNavigationBarLoading()\n}\n\nexport function setBackgroundColor(options?: SetBackgroundColorOptions) {\n return setBackgroundColorBridge(options)\n}\n\nexport function setBackgroundTextStyle(options?: SetBackgroundTextStyleOptions) {\n return setBackgroundTextStyleBridge(options)\n}\n\nexport function canIUse(schema: string) {\n return canIUseBridge(resolveMiniProgramBridge(), schema)\n}\n\nconst cloudBridge: CloudBridge = createCloudBridge(\n (options, result) => callMiniProgramAsyncSuccess(\n options as unknown as MiniProgramAsyncOptions<MiniProgramBaseResult> | undefined,\n result as MiniProgramBaseResult,\n ),\n (options, errMsg) => callMiniProgramAsyncFailure(\n options as unknown as MiniProgramAsyncOptions<MiniProgramBaseResult> | undefined,\n errMsg,\n ),\n) as CloudBridge\n\nexport function createRewardedVideoAd(options?: AdBaseOptions): RewardedVideoAd {\n return createRewardedVideoAdBridge(options)\n}\n\nexport function createInterstitialAd(options?: AdBaseOptions): InterstitialAd {\n return createInterstitialAdBridge(options)\n}\n\nexport function getExtConfigSync() {\n return getExtConfigSyncBridge()\n}\n\nexport function getExtConfig(options?: GetExtConfigOptions) {\n return getExtConfigBridge(options)\n}\n\nexport function getUpdateManager(): UpdateManager {\n return getUpdateManagerBridge()\n}\n\nexport function getLogManager(options?: LogManagerOptions): LogManager {\n return getLogManagerBridge(options)\n}\n\nexport function reportAnalytics(eventName: string, data?: Record<string, unknown>) {\n reportAnalyticsBridge(eventName, data)\n}\n\n/** 由公开运行时入口显式安装,确保拆分发布后的子模块不被摇树优化移除。 */\nexport function installMiniProgramGlobals(): void {\n const miniProgramBridge = (globalTarget[DEFAULT_MINI_PROGRAM_GLOBAL_KEY] as Record<string, unknown> | undefined) ?? {}\n Object.assign(miniProgramBridge, {\n navigateTo,\n navigateBack,\n redirectTo,\n switchTab,\n reLaunch,\n getLaunchOptionsSync,\n getEnterOptionsSync,\n offAppHide,\n offAppShow,\n onAppHide,\n onAppShow,\n ...runtimeDataApi,\n setNavigationBarTitle,\n setNavigationBarColor,\n setBackgroundColor,\n setBackgroundTextStyle,\n showNavigationBarLoading,\n hideNavigationBarLoading,\n ...uiMediaApi,\n ...deviceAuthSystemApi,\n ...eventBusApi,\n loadFontFace,\n getLocale,\n createAnimation,\n createRewardedVideoAd,\n createInterstitialAd,\n getExtConfigSync,\n getExtConfig,\n getUpdateManager,\n getLogManager,\n reportAnalytics,\n canIUse,\n cloud: cloudBridge,\n })\n const miniProgramEnv = (miniProgramBridge.env as Record<string, unknown> | undefined) ?? {}\n if (typeof miniProgramEnv.USER_DATA_PATH !== 'string' || !miniProgramEnv.USER_DATA_PATH.trim()) {\n miniProgramEnv.USER_DATA_PATH = WEB_USER_DATA_PATH\n }\n miniProgramBridge.env = miniProgramEnv\n for (const runtimeGlobalKey of MINI_PROGRAM_GLOBAL_KEYS) {\n globalTarget[runtimeGlobalKey] = miniProgramBridge\n }\n if (typeof globalTarget.getApp !== 'function') {\n globalTarget.getApp = getAppInstance\n }\n if (typeof globalTarget.getCurrentPages !== 'function') {\n globalTarget.getCurrentPages = getCurrentPagesInternal\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA2FA,MAAM,2BAA2B,gCAAgC;AACjE,MAAM,kCAAkC,sCAAsC;AAC9E,MAAM,eAAe;AAErB,SAAS,2BAA2B;CAClC,KAAK,MAAM,oBAAoB,0BAA0B;EACvD,MAAM,YAAY,aAAa;EAC/B,IAAI,aAAa,OAAO,cAAc,UACpC,OAAO;CAEX;AAEF;A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;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,OAAO;CACT,CAAC;CACD,MAAM,iBAAkB,kBAAkB,OAA+C,CAAC;CAC1F,IAAI,OAAO,eAAe,mBAAmB,YAAY,CAAC,eAAe,eAAe,KAAK,GAC3F,eAAe,iBAAiB;CAElC,kBAAkB,MAAM;CACxB,KAAK,MAAM,oBAAoB,0BAC7B,aAAa,oBAAoB;CAEnC,IAAI,OAAO,aAAa,WAAW,YACjC,aAAa,SAAS;CAExB,IAAI,OAAO,aAAa,oBAAoB,YAC1C,aAAa,kBAAkB;AAEnC"}
1
+ {"version":3,"file":"index.mjs","names":["runtimeDataApi","uiMediaApi","deviceAuthSystemApi","eventBusApi"],"sources":["../../../src/runtime/polyfill/index.ts"],"sourcesContent":["import type {\n AdBaseOptions,\n CloudBridge,\n GetExtConfigOptions,\n InterstitialAd,\n LogManager,\n LogManagerOptions,\n MiniProgramAsyncOptions,\n MiniProgramBaseResult,\n RewardedVideoAd,\n SetBackgroundColorOptions,\n SetBackgroundTextStyleOptions,\n UpdateManager,\n} from './types'\nimport { WEVU_PAGE_SCROLL_EVENT_CONTRACT_KEY, WEVU_PAGE_SCROLL_RESTORATION_OWNER_KEY, WEVU_ROUTE_EVENT_CONTRACT_KEY } from '@weapp-core/constants'\nimport { getDefaultMiniProgramRuntimeGlobalKey, getMiniProgramRuntimeGlobalKeys } from '@weapp-core/shared/platforms/runtime'\nimport { emitRuntimeWarning } from '../warning'\nimport { createAnimation } from './animation'\nimport {\n callMiniProgramAsyncFailure,\n callMiniProgramAsyncSuccess,\n} from './async'\nimport {\n setBackgroundColorBridge,\n setBackgroundTextStyleBridge,\n} from './background'\nimport { createCloudBridge } from './cloud'\nimport * as deviceAuthSystemApi from './deviceAuthSystemApi'\nimport * as eventBusApi from './eventBus'\nimport { WEB_USER_DATA_PATH } from './files'\nimport { loadFontFace } from './font'\nimport { getLocale } from './locale'\nimport { createNavigationBarRuntimeBridge } from './navigationBarRuntime'\nimport {\n createInterstitialAdBridge,\n createRewardedVideoAdBridge,\n getExtConfigBridge,\n getExtConfigSyncBridge,\n getLogManagerBridge,\n getUpdateManagerBridge,\n reportAnalyticsBridge,\n} from './platformApi'\nimport {\n getAppInstance,\n getCurrentPagesInternal,\n getEnterOptionsSync,\n getLaunchOptionsSync,\n navigateBack,\n navigateTo,\n offAppHide,\n offAppShow,\n onAppHide,\n onAppShow,\n redirectTo,\n reLaunch,\n switchTab,\n} from './routeRuntime'\nimport {\n offAppRoute,\n offAppRouteDone,\n offBeforeAppRoute,\n offBeforePageUnload,\n onAppRoute,\n onAppRouteDone,\n onBeforeAppRoute,\n onBeforePageUnload,\n} from './routeRuntime/events'\nimport { claimPageScrollRestoration } from './routeRuntime/scroll'\nimport {\n canIUseBridge,\n} from './runtimeCapabilityApi'\nimport * as runtimeDataApi from './runtimeDataApi'\nimport * as uiMediaApi from './uiMediaApi'\n\nexport { createAnimation } from './animation'\nexport * from './deviceAuthSystemApi'\nexport * from './eventBus'\nexport { loadFontFace } from './font'\nexport { getLocale } from './locale'\n\nexport {\n getEnterOptionsSync,\n getLaunchOptionsSync,\n initializePageRoutes,\n navigateBack,\n navigateTo,\n offAppHide,\n offAppShow,\n onAppHide,\n onAppShow,\n redirectTo,\n registerApp,\n registerComponent,\n registerPage,\n reLaunch,\n switchTab,\n} from './routeRuntime'\n\nexport {\n offAppRoute,\n offAppRouteDone,\n offBeforeAppRoute,\n offBeforePageUnload,\n onAppRoute,\n onAppRouteDone,\n onBeforeAppRoute,\n onBeforePageUnload,\n} from './routeRuntime/events'\nexport type { AppRouteCallback, AppRouteEvent, AppRouteOpenType, BeforePageUnloadCallback, BeforePageUnloadEvent } from './routeRuntime/events'\n\nexport type { AppHideCallback, AppHideOptions, AppLaunchOptions, AppShowCallback } from './routeRuntime/options'\n\nexport * from './runtimeDataApi'\nexport * from './uiMediaApi'\n\nconst MINI_PROGRAM_GLOBAL_KEYS = getMiniProgramRuntimeGlobalKeys()\nconst DEFAULT_MINI_PROGRAM_GLOBAL_KEY = getDefaultMiniProgramRuntimeGlobalKey()\nconst globalTarget = globalThis as Record<string, unknown>\n\nfunction resolveMiniProgramBridge() {\n for (const runtimeGlobalKey of MINI_PROGRAM_GLOBAL_KEYS) {\n const candidate = globalTarget[runtimeGlobalKey]\n if (candidate && typeof candidate === 'object') {\n return candidate as Record<string, unknown>\n }\n }\n return undefined\n}\n\nconst navigationBarRuntimeBridge = createNavigationBarRuntimeBridge(\n () => getCurrentPagesInternal() as Array<HTMLElement & { renderRoot?: ShadowRoot | HTMLElement }>,\n emitRuntimeWarning,\n)\n\nexport function setNavigationBarTitle(options: { title: string }) {\n return navigationBarRuntimeBridge.setNavigationBarTitle(options)\n}\n\nexport function setNavigationBarColor(options: {\n frontColor?: string\n backgroundColor?: string\n animation?: { duration?: number, timingFunction?: string }\n}) {\n return navigationBarRuntimeBridge.setNavigationBarColor(options)\n}\n\nexport function showNavigationBarLoading() {\n return navigationBarRuntimeBridge.showNavigationBarLoading()\n}\n\nexport function hideNavigationBarLoading() {\n return navigationBarRuntimeBridge.hideNavigationBarLoading()\n}\n\nexport function setBackgroundColor(options?: SetBackgroundColorOptions) {\n return setBackgroundColorBridge(options)\n}\n\nexport function setBackgroundTextStyle(options?: SetBackgroundTextStyleOptions) {\n return setBackgroundTextStyleBridge(options)\n}\n\nexport function canIUse(schema: string) {\n return canIUseBridge(resolveMiniProgramBridge(), schema)\n}\n\nconst cloudBridge: CloudBridge = createCloudBridge(\n (options, result) => callMiniProgramAsyncSuccess(\n options as unknown as MiniProgramAsyncOptions<MiniProgramBaseResult> | undefined,\n result as MiniProgramBaseResult,\n ),\n (options, errMsg) => callMiniProgramAsyncFailure(\n options as unknown as MiniProgramAsyncOptions<MiniProgramBaseResult> | undefined,\n errMsg,\n ),\n) as CloudBridge\n\nexport function createRewardedVideoAd(options?: AdBaseOptions): RewardedVideoAd {\n return createRewardedVideoAdBridge(options)\n}\n\nexport function createInterstitialAd(options?: AdBaseOptions): InterstitialAd {\n return createInterstitialAdBridge(options)\n}\n\nexport function getExtConfigSync() {\n return getExtConfigSyncBridge()\n}\n\nexport function getExtConfig(options?: GetExtConfigOptions) {\n return getExtConfigBridge(options)\n}\n\nexport function getUpdateManager(): UpdateManager {\n return getUpdateManagerBridge()\n}\n\nexport function getLogManager(options?: LogManagerOptions): LogManager {\n return getLogManagerBridge(options)\n}\n\nexport function reportAnalytics(eventName: string, data?: Record<string, unknown>) {\n reportAnalyticsBridge(eventName, data)\n}\n\n/** 由公开运行时入口显式安装,确保拆分发布后的子模块不被摇树优化移除。 */\nexport function installMiniProgramGlobals(): void {\n const miniProgramBridge = (globalTarget[DEFAULT_MINI_PROGRAM_GLOBAL_KEY] as Record<string, unknown> | undefined) ?? {}\n Object.assign(miniProgramBridge, {\n navigateTo,\n navigateBack,\n redirectTo,\n switchTab,\n reLaunch,\n getLaunchOptionsSync,\n getEnterOptionsSync,\n offAppHide,\n offAppShow,\n onAppHide,\n onAppShow,\n offAppRoute,\n offAppRouteDone,\n offBeforeAppRoute,\n offBeforePageUnload,\n onAppRoute,\n onAppRouteDone,\n onBeforeAppRoute,\n onBeforePageUnload,\n [WEVU_PAGE_SCROLL_RESTORATION_OWNER_KEY]: claimPageScrollRestoration,\n [WEVU_ROUTE_EVENT_CONTRACT_KEY]: 1,\n [WEVU_PAGE_SCROLL_EVENT_CONTRACT_KEY]: 1,\n ...runtimeDataApi,\n setNavigationBarTitle,\n setNavigationBarColor,\n setBackgroundColor,\n setBackgroundTextStyle,\n showNavigationBarLoading,\n hideNavigationBarLoading,\n ...uiMediaApi,\n ...deviceAuthSystemApi,\n ...eventBusApi,\n loadFontFace,\n getLocale,\n createAnimation,\n createRewardedVideoAd,\n createInterstitialAd,\n getExtConfigSync,\n getExtConfig,\n getUpdateManager,\n getLogManager,\n reportAnalytics,\n canIUse,\n cloud: cloudBridge,\n })\n const miniProgramEnv = (miniProgramBridge.env as Record<string, unknown> | undefined) ?? {}\n if (typeof miniProgramEnv.USER_DATA_PATH !== 'string' || !miniProgramEnv.USER_DATA_PATH.trim()) {\n miniProgramEnv.USER_DATA_PATH = WEB_USER_DATA_PATH\n }\n miniProgramBridge.env = miniProgramEnv\n for (const runtimeGlobalKey of MINI_PROGRAM_GLOBAL_KEYS) {\n globalTarget[runtimeGlobalKey] = miniProgramBridge\n }\n if (typeof globalTarget.getApp !== 'function') {\n globalTarget.getApp = getAppInstance\n }\n if (typeof globalTarget.getCurrentPages !== 'function') {\n globalTarget.getCurrentPages = getCurrentPagesInternal\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAmHA,MAAM,2BAA2B,gCAAgC;AACjE,MAAM,kCAAkC,sCAAsC;AAC9E,MAAM,eAAe;AAErB,SAAS,2BAA2B;CAClC,KAAK,MAAM,oBAAoB,0BAA0B;EACvD,MAAM,YAAY,aAAa;EAC/B,IAAI,aAAa,OAAO,cAAc,UACpC,OAAO;CAEX;AAEF;AAEA,MAAM,6BAA6B,uCAC3B,wBAAwB,GAC9B,kBACF;AAEA,SAAgB,sBAAsB,SAA4B;CAChE,OAAO,2BAA2B,sBAAsB,OAAO;AACjE;AAEA,SAAgB,sBAAsB,SAInC;CACD,OAAO,2BAA2B,sBAAsB,OAAO;AACjE;AAEA,SAAgB,2BAA2B;CACzC,OAAO,2BAA2B,yBAAyB;AAC7D;AAEA,SAAgB,2BAA2B;CACzC,OAAO,2BAA2B,yBAAyB;AAC7D;AAEA,SAAgB,mBAAmB,SAAqC;CACtE,OAAO,yBAAyB,OAAO;AACzC;AAEA,SAAgB,uBAAuB,SAAyC;CAC9E,OAAO,6BAA6B,OAAO;AAC7C;AAEA,SAAgB,QAAQ,QAAgB;CACtC,OAAO,cAAc,yBAAyB,GAAG,MAAM;AACzD;AAEA,MAAM,cAA2B,mBAC9B,SAAS,WAAW,4BACnB,SACA,MACF,IACC,SAAS,WAAW,4BACnB,SACA,MACF,CACF;AAEA,SAAgB,sBAAsB,SAA0C;CAC9E,OAAO,4BAA4B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