@weapp-vite/web 1.4.21 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/compiler/wxml/attributes.mjs +5 -3
- package/dist/compiler/wxml/attributes.mjs.map +1 -1
- package/dist/compiler/wxml/compile.mjs +6 -1
- package/dist/compiler/wxml/compile.mjs.map +1 -1
- package/dist/index.d.mts +5 -3
- package/dist/index.mjs +4 -3
- package/dist/plugin/constants.mjs +2 -1
- package/dist/plugin/constants.mjs.map +1 -1
- package/dist/plugin/index.mjs +7 -2
- package/dist/plugin/index.mjs.map +1 -1
- package/dist/plugin/register.mjs +20 -5
- package/dist/plugin/register.mjs.map +1 -1
- package/dist/runtime/component/constants.mjs +9 -1
- package/dist/runtime/component/constants.mjs.map +1 -1
- package/dist/runtime/component/element.mjs +24 -4
- package/dist/runtime/component/element.mjs.map +1 -1
- package/dist/runtime/component/events.mjs +6 -4
- package/dist/runtime/component/events.mjs.map +1 -1
- package/dist/runtime/eventBinding.d.mts +16 -0
- package/dist/runtime/eventBinding.mjs +51 -0
- package/dist/runtime/eventBinding.mjs.map +1 -0
- package/dist/runtime/index.d.mts +5 -3
- package/dist/runtime/index.mjs +4 -3
- package/dist/runtime/index.mjs.map +1 -1
- package/dist/runtime/inputHandlerResult.mjs +22 -0
- package/dist/runtime/inputHandlerResult.mjs.map +1 -0
- package/dist/runtime/legacyTemplate/dom.mjs +27 -9
- package/dist/runtime/legacyTemplate/dom.mjs.map +1 -1
- package/dist/runtime/nativeComponents/input.mjs +3 -1
- package/dist/runtime/nativeComponents/input.mjs.map +1 -1
- package/dist/runtime/nativeComponents/scrollView.mjs +21 -12
- package/dist/runtime/nativeComponents/scrollView.mjs.map +1 -1
- package/dist/runtime/polyfill/index.d.mts +3 -2
- package/dist/runtime/polyfill/index.mjs +6 -2
- package/dist/runtime/polyfill/index.mjs.map +1 -1
- package/dist/runtime/polyfill/routeRuntime/appLifecycle.mjs +53 -7
- package/dist/runtime/polyfill/routeRuntime/appLifecycle.mjs.map +1 -1
- package/dist/runtime/polyfill/routeRuntime/options.d.mts +6 -1
- package/dist/runtime/polyfill/routeRuntime/options.mjs.map +1 -1
- package/dist/runtime/polyfill/routeRuntime.d.mts +6 -1
- package/dist/runtime/polyfill/routeRuntime.mjs +13 -1
- package/dist/runtime/polyfill/routeRuntime.mjs.map +1 -1
- package/dist/runtime/polyfill.d.mts +3 -2
- package/dist/runtime/renderContext.mjs +2 -1
- package/dist/runtime/renderContext.mjs.map +1 -1
- package/dist/runtime/wevu.d.mts +4 -0
- package/dist/runtime/wevu.mjs +13 -2
- package/dist/runtime/wevu.mjs.map +1 -1
- package/package.json +36 -17
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.mjs","names":[],"sources":["../../../src/runtime/component/constants.ts"],"sourcesContent":["export const supportsLit = typeof document !== 'undefined'\n && typeof document.createComment === 'function'\n && typeof document.createTreeWalker === 'function'\n\nexport const FallbackElement = class {}\n\nexport const MINI_PROGRAM_EVENT_ATTRIBUTE_PREFIX = 'data-mp-on-'\nexport const MINI_PROGRAM_EVENT_FLAG_ATTRIBUTE_PREFIX = 'data-mp-on-flags-'\n\nexport const WECHAT_LEGACY_EVENT_ATTRIBUTE_PREFIX = 'data-wx-on-'\nexport const WECHAT_LEGACY_EVENT_FLAG_ATTRIBUTE_PREFIX = 'data-wx-on-flags-'\n\nexport const LEGACY_EVENT_ATTRIBUTE_PREFIX = WECHAT_LEGACY_EVENT_ATTRIBUTE_PREFIX\nexport const LEGACY_EVENT_FLAG_ATTRIBUTE_PREFIX = WECHAT_LEGACY_EVENT_FLAG_ATTRIBUTE_PREFIX\n\nexport const EVENT_ATTRIBUTE_PREFIXES = [\n MINI_PROGRAM_EVENT_ATTRIBUTE_PREFIX,\n WECHAT_LEGACY_EVENT_ATTRIBUTE_PREFIX,\n] as const\n\nexport const EVENT_FLAG_ATTRIBUTE_PREFIXES = [\n MINI_PROGRAM_EVENT_FLAG_ATTRIBUTE_PREFIX,\n WECHAT_LEGACY_EVENT_FLAG_ATTRIBUTE_PREFIX,\n] as const\n"],"mappings":";AAAA,MAAa,cAAc,OAAO,aAAa,eAC1C,OAAO,SAAS,kBAAkB,cAClC,OAAO,SAAS,qBAAqB;AAE1C,MAAa,kBAAkB,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"constants.mjs","names":[],"sources":["../../../src/runtime/component/constants.ts"],"sourcesContent":["export const supportsLit = typeof document !== 'undefined'\n && typeof document.createComment === 'function'\n && typeof document.createTreeWalker === 'function'\n\nexport const FallbackElement = class {}\n\n// HTML 会折叠属性名大小写,因此用小写安全后缀保存自定义事件名。\nconst EVENT_ATTRIBUTE_NAME_ESCAPE_RE = /[A-Z_]/g\nconst EVENT_ATTRIBUTE_NAME_UNESCAPE_RE = /_([a-z_])/g\n\nexport function encodeEventAttributeName(eventName: string) {\n return eventName.replace(\n EVENT_ATTRIBUTE_NAME_ESCAPE_RE,\n character => character === '_' ? '__' : `_${character.toLowerCase()}`,\n )\n}\n\nexport function decodeEventAttributeName(attributeName: string) {\n return attributeName.replace(\n EVENT_ATTRIBUTE_NAME_UNESCAPE_RE,\n (_match, character: string) => character === '_' ? '_' : character.toUpperCase(),\n )\n}\n\nexport const MINI_PROGRAM_EVENT_ATTRIBUTE_PREFIX = 'data-mp-on-'\nexport const MINI_PROGRAM_EVENT_FLAG_ATTRIBUTE_PREFIX = 'data-mp-on-flags-'\n\nexport const WECHAT_LEGACY_EVENT_ATTRIBUTE_PREFIX = 'data-wx-on-'\nexport const WECHAT_LEGACY_EVENT_FLAG_ATTRIBUTE_PREFIX = 'data-wx-on-flags-'\n\nexport const LEGACY_EVENT_ATTRIBUTE_PREFIX = WECHAT_LEGACY_EVENT_ATTRIBUTE_PREFIX\nexport const LEGACY_EVENT_FLAG_ATTRIBUTE_PREFIX = WECHAT_LEGACY_EVENT_FLAG_ATTRIBUTE_PREFIX\n\nexport const EVENT_ATTRIBUTE_PREFIXES = [\n MINI_PROGRAM_EVENT_ATTRIBUTE_PREFIX,\n WECHAT_LEGACY_EVENT_ATTRIBUTE_PREFIX,\n] as const\n\nexport const EVENT_FLAG_ATTRIBUTE_PREFIXES = [\n MINI_PROGRAM_EVENT_FLAG_ATTRIBUTE_PREFIX,\n WECHAT_LEGACY_EVENT_FLAG_ATTRIBUTE_PREFIX,\n] as const\n"],"mappings":";AAAA,MAAa,cAAc,OAAO,aAAa,eAC1C,OAAO,SAAS,kBAAkB,cAClC,OAAO,SAAS,qBAAqB;AAE1C,MAAa,kBAAkB,MAAM,CAAC;AAGtC,MAAM,iCAAiC;AACvC,MAAM,mCAAmC;AAEzC,SAAgB,yBAAyB,WAAmB;CAC1D,OAAO,UAAU,QACf,iCACA,cAAa,cAAc,MAAM,OAAO,IAAI,UAAU,YAAY,GACpE;AACF;AAEA,SAAgB,yBAAyB,eAAuB;CAC9D,OAAO,cAAc,QACnB,mCACC,QAAQ,cAAsB,cAAc,MAAM,MAAM,UAAU,YAAY,CACjF;AACF;AAEA,MAAa,sCAAsC;AACnD,MAAa,2CAA2C;AAExD,MAAa,uCAAuC;AACpD,MAAa,4CAA4C;AAKzD,MAAa,2BAA2B,CACtC,qCACA,oCACF;AAEA,MAAa,gCAAgC,CAC3C,0CACA,yCACF"}
|
|
@@ -11,6 +11,7 @@ import { createWebSlotsProxy } from "./slots.mjs";
|
|
|
11
11
|
import { assignDataPath, cloneValue, coerceValue, parseDataPath, resolveDataPath, toCamelCase } from "./utils.mjs";
|
|
12
12
|
import { clearVirtualHostClasses, clearVirtualHostParts, syncVirtualHostClasses, syncVirtualHostParts } from "./virtualHost.mjs";
|
|
13
13
|
import { html } from "lit";
|
|
14
|
+
import { WEVU_HOST_COMMIT_PROMISE_KEY } from "@weapp-core/constants";
|
|
14
15
|
import { unsafeHTML } from "lit/directives/unsafe-html.js";
|
|
15
16
|
|
|
16
17
|
//#region src/runtime/component/element.ts
|
|
@@ -45,6 +46,9 @@ function createComponentElementClass({ BaseElement, runtimeState, instances }) {
|
|
|
45
46
|
#virtualHostClassTokens = /* @__PURE__ */ new Set();
|
|
46
47
|
#virtualHostPartTokens = /* @__PURE__ */ new Set();
|
|
47
48
|
#virtualHostRootElement;
|
|
49
|
+
#needsSetDataRecovery = false;
|
|
50
|
+
#hostCommitPromise;
|
|
51
|
+
#hostCommitUpdate;
|
|
48
52
|
data;
|
|
49
53
|
properties;
|
|
50
54
|
constructor() {
|
|
@@ -88,11 +92,27 @@ function createComponentElementClass({ BaseElement, runtimeState, instances }) {
|
|
|
88
92
|
instances.add(this);
|
|
89
93
|
runtimeState.lifetimes.created?.call(this.#publicInstance);
|
|
90
94
|
}
|
|
95
|
+
get [WEVU_HOST_COMMIT_PROMISE_KEY]() {
|
|
96
|
+
if (!supportsLit) return;
|
|
97
|
+
const update = this.updateComplete;
|
|
98
|
+
return this.#hostCommitUpdate === update ? this.#hostCommitPromise : update;
|
|
99
|
+
}
|
|
91
100
|
setData(patch, callback) {
|
|
92
101
|
const changed = this.#applyDataPatch(patch);
|
|
93
|
-
if (supportsLit && changed
|
|
94
|
-
|
|
95
|
-
|
|
102
|
+
if (supportsLit && (changed || this.#needsSetDataRecovery)) {
|
|
103
|
+
if (!changed) this.requestUpdate();
|
|
104
|
+
const update = this.updateComplete;
|
|
105
|
+
const commitPromise = update.then(() => {
|
|
106
|
+
this.#needsSetDataRecovery = false;
|
|
107
|
+
callback?.();
|
|
108
|
+
}, (cause) => {
|
|
109
|
+
this.#needsSetDataRecovery = true;
|
|
110
|
+
throw cause;
|
|
111
|
+
});
|
|
112
|
+
this.#hostCommitPromise = commitPromise;
|
|
113
|
+
this.#hostCommitUpdate = update;
|
|
114
|
+
return commitPromise;
|
|
115
|
+
}
|
|
96
116
|
callback?.();
|
|
97
117
|
}
|
|
98
118
|
triggerEvent(name, detail, options = {}) {
|
|
@@ -185,7 +205,7 @@ function createComponentElementClass({ BaseElement, runtimeState, instances }) {
|
|
|
185
205
|
for (const [path, value] of Object.entries(patch)) {
|
|
186
206
|
const segments = parseDataPath(path);
|
|
187
207
|
const topKey = segments[0];
|
|
188
|
-
if (!topKey || Object.is(resolveDataPath(this.#state, segments), value)) continue;
|
|
208
|
+
if (!topKey || topKey === "$slots" || Object.is(resolveDataPath(this.#state, segments), value)) continue;
|
|
189
209
|
if (hasOwn(this.#properties, topKey) && !hasOwn(previousProperties, topKey)) previousProperties[topKey] = this.#properties[topKey];
|
|
190
210
|
assignDataPath(this.#state, segments, value);
|
|
191
211
|
if (hasOwn(this.#properties, topKey)) this.#properties[topKey] = this.#state[topKey];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"element.mjs","names":[],"sources":["../../../src/runtime/component/element.ts"],"sourcesContent":["import type {\n CreateComponentElementClassOptions,\n WeappComponentInstance,\n} from './elementTypes'\nimport type {\n ComponentOptions,\n ComponentPublicInstance,\n DataRecord,\n PageLifeTimeHooks,\n TriggerEventOptions,\n} from './types'\nimport type { ClassAttributeElement } from './virtualHost'\nimport { html } from 'lit'\nimport { unsafeHTML } from 'lit/directives/unsafe-html.js'\nimport { createIntersectionObserverBridge } from '../polyfill/intersectionObserver'\nimport { createRenderContext } from '../renderContext'\nimport { hasOwn } from '../utils/object'\nimport { supportsLit } from './constants'\nimport {\n createScopedSelectorQuery,\n resolveRenderRoot,\n selectRuntimeComponent,\n selectRuntimeComponents,\n} from './dom'\nimport { bindRuntimeEvents } from './events'\nimport { runComponentObservers } from './observers'\nimport { createComponentPublicInstance } from './publicInstance'\nimport { resolveRelationNodes } from './relations'\nimport { createWebSlotsProxy } from './slots'\nimport { assignDataPath, cloneValue, coerceValue, parseDataPath, resolveDataPath, toCamelCase } from './utils'\nimport {\n clearVirtualHostClasses,\n clearVirtualHostParts,\n syncVirtualHostClasses,\n syncVirtualHostParts,\n} from './virtualHost'\n\nexport type { WeappComponentInstance } from './elementTypes'\nexport type WeappComponentElementClass = typeof HTMLElement & {\n new (): WeappComponentInstance\n}\n\nfunction resolveComposedParent(node: Node): Node | undefined {\n const assignedSlot = (node as Element).assignedSlot\n if (assignedSlot) {\n return assignedSlot\n }\n if (node.parentNode) {\n return node.parentNode\n }\n const root = node.getRootNode?.()\n return root instanceof ShadowRoot ? root.host : undefined\n}\n\nfunction isWeappComponentInstance(value: unknown): value is WeappComponentInstance {\n return Boolean(\n value\n && typeof value === 'object'\n && typeof (value as WeappComponentInstance).__weappSync === 'function',\n )\n}\n\nexport function createComponentElementClass({\n BaseElement,\n runtimeState,\n instances,\n}: CreateComponentElementClassOptions): WeappComponentElementClass {\n const RuntimeBaseElement = BaseElement as typeof HTMLElement & {\n readonly observedAttributes?: string[]\n }\n class WeappWebComponent extends RuntimeBaseElement implements WeappComponentInstance {\n static get observedAttributes() {\n const inherited = super.observedAttributes ?? []\n return Array.from(new Set([...inherited, ...runtimeState.observedAttributes]))\n }\n\n #state: DataRecord\n #properties: DataRecord\n #methods: Record<string, (event: any) => any> = {}\n #publicInstance: ComponentPublicInstance\n #exposedMethodNames = new Set<string>()\n #isMounted = false\n #renderContext = createRenderContext(this, {})\n #usesLegacyTemplate = false\n #readyFired = false\n #observerInitDone = false\n #observedKeys = new Set<string>()\n #virtualHostClassTokens = new Set<string>()\n #virtualHostPartTokens = new Set<string>()\n #virtualHostRootElement: ClassAttributeElement | undefined\n readonly data!: DataRecord\n readonly properties!: DataRecord\n\n constructor() {\n super()\n const dataOption = runtimeState.componentRef.data ?? {}\n this.#properties = { ...runtimeState.defaultPropertyValues }\n this.#state = { ...cloneValue(this.#properties), ...cloneValue(dataOption) }\n Object.defineProperty(this.#state, '$slots', {\n configurable: true,\n enumerable: true,\n value: createWebSlotsProxy(() => this.#state.vueSlots),\n })\n Object.defineProperties(this, {\n data: {\n configurable: true,\n enumerable: true,\n get: () => this.#state,\n },\n properties: {\n configurable: true,\n enumerable: true,\n get: () => this.#properties,\n },\n })\n this.#publicInstance = createComponentPublicInstance(\n this,\n WeappWebComponent.prototype,\n key => typeof key === 'string' ? this.#methods[key] : undefined,\n )\n for (const [propName] of runtimeState.propertyEntries) {\n Object.defineProperty(this, propName, {\n configurable: true,\n enumerable: true,\n get: () => this.#state[propName],\n set: value => this.#setProperty(propName, value),\n })\n }\n this.#syncMethods(runtimeState.componentRef.methods ?? {})\n if (!supportsLit) {\n const host = this as unknown as HTMLElement\n if (!host.shadowRoot && typeof host.attachShadow === 'function') {\n host.attachShadow({ mode: 'open' })\n }\n ;(this as any).renderRoot = host.shadowRoot ?? host\n }\n instances.add(this)\n runtimeState.lifetimes.created?.call(this.#publicInstance)\n }\n\n setData(patch: DataRecord, callback?: () => void) {\n const changed = this.#applyDataPatch(patch)\n if (supportsLit && changed) {\n const updateComplete = (this as unknown as { updateComplete: Promise<boolean> }).updateComplete\n return updateComplete.then(() => {\n callback?.()\n })\n }\n callback?.()\n }\n\n triggerEvent(name: string, detail?: any, options: TriggerEventOptions = {}) {\n this.dispatchEvent(new CustomEvent(name, {\n detail,\n bubbles: options.bubbles ?? false,\n composed: options.composed ?? false,\n }))\n }\n\n createSelectorQuery() {\n return createScopedSelectorQuery(this)\n }\n\n createIntersectionObserver(options?: {\n initialRatio?: number\n observeAll?: boolean\n thresholds?: number[]\n }) {\n return createIntersectionObserverBridge(this, options)\n }\n\n selectComponent(selector: string) {\n return selectRuntimeComponent(this, selector)\n }\n\n selectAllComponents(selector: string) {\n return selectRuntimeComponents(this, selector)\n }\n\n getRelationNodes(relationPath: string) {\n const relation = runtimeState.componentRef.relations?.[relationPath]\n return relation\n ? resolveRelationNodes(this, runtimeState.id, relationPath, relation.type)\n : []\n }\n\n selectOwnerComponent() {\n let current = resolveComposedParent(this)\n while (current) {\n if (isWeappComponentInstance(current)) {\n return current\n }\n current = resolveComposedParent(current)\n }\n return undefined\n }\n\n connectedCallback() {\n const superConnected = (BaseElement.prototype as { connectedCallback?: () => void }).connectedCallback\n if (supportsLit && typeof superConnected === 'function') {\n superConnected.call(this)\n }\n this.#applyAttributes()\n if (runtimeState.observerInitEnabled) {\n this.#runInitialObservers()\n }\n runtimeState.lifetimes.attached?.call(this.#publicInstance)\n this.#isMounted = true\n if (!supportsLit) {\n this.#renderLegacy()\n }\n }\n\n disconnectedCallback() {\n const superDisconnected = (BaseElement.prototype as { disconnectedCallback?: () => void }).disconnectedCallback\n if (supportsLit && typeof superDisconnected === 'function') {\n superDisconnected.call(this)\n }\n this.#isMounted = false\n instances.delete(this)\n runtimeState.lifetimes.detached?.call(this.#publicInstance)\n }\n\n attributeChangedCallback(attrName: string, oldValue: string | null, newValue: string | null) {\n const superAttributeChanged = (BaseElement.prototype as {\n attributeChangedCallback?: (name: string, oldValue: string | null, newValue: string | null) => void\n }).attributeChangedCallback\n if (supportsLit && typeof superAttributeChanged === 'function') {\n superAttributeChanged.call(this, attrName, oldValue, newValue)\n }\n const propName = toCamelCase(attrName)\n if (!hasOwn(this.#properties, propName)) {\n return\n }\n const propOption = runtimeState.componentRef.properties?.[propName]\n this.#setProperty(propName, coerceValue(newValue, propOption?.type))\n }\n\n firstUpdated() {\n runtimeState.lifetimes.ready?.call(this.#publicInstance)\n this.#readyFired = true\n }\n\n updated() {\n this.#syncVirtualHostClasses()\n if (this.#usesLegacyTemplate) {\n bindRuntimeEvents(resolveRenderRoot(this), this.#methods, this)\n }\n }\n\n render() {\n const result = runtimeState.templateRef(this.#state, this.#renderContext)\n const styleMarkup = runtimeState.styleRef\n ? html`<style>${runtimeState.styleRef}</style>`\n : null\n if (typeof result === 'string') {\n this.#usesLegacyTemplate = true\n return html`${styleMarkup}${unsafeHTML(result)}`\n }\n this.#usesLegacyTemplate = false\n if (styleMarkup) {\n return html`${styleMarkup}${result as any}`\n }\n return result\n }\n\n requestUpdate(name?: PropertyKey, oldValue?: unknown, options?: unknown) {\n const superRequestUpdate = (BaseElement.prototype as any).requestUpdate\n if (supportsLit && typeof superRequestUpdate === 'function') {\n return superRequestUpdate.call(this, name, oldValue, options)\n }\n if (this.#isMounted) {\n this.#renderLegacy()\n }\n return undefined\n }\n\n #applyAttributes() {\n if (!this.attributes || typeof this.attributes[Symbol.iterator] !== 'function') {\n return\n }\n for (const attr of this.attributes) {\n this.attributeChangedCallback(attr.name, null, attr.value)\n }\n }\n\n #applyDataPatch(patch: DataRecord) {\n if (!patch || typeof patch !== 'object') {\n return false\n }\n let changed = false\n const changedKeys: string[] = []\n const previousProperties: DataRecord = {}\n for (const [path, value] of Object.entries(patch)) {\n const segments = parseDataPath(path)\n const topKey = segments[0]\n if (!topKey || Object.is(resolveDataPath(this.#state, segments), value)) {\n continue\n }\n if (hasOwn(this.#properties, topKey) && !hasOwn(previousProperties, topKey)) {\n previousProperties[topKey] = this.#properties[topKey]\n }\n assignDataPath(this.#state, segments, value)\n if (hasOwn(this.#properties, topKey)) {\n this.#properties[topKey] = this.#state[topKey]\n }\n changedKeys.push(path)\n changed = true\n }\n if (changed) {\n this.requestUpdate()\n runComponentObservers(runtimeState.componentRef, this.#publicInstance, changedKeys, previousProperties)\n for (const key of changedKeys) {\n if (runtimeState.componentRef.properties?.[key]?.observer) {\n this.#observedKeys.add(key)\n }\n }\n }\n return changed\n }\n\n #setProperty(name: string, value: any) {\n const propOption = runtimeState.componentRef.properties?.[name]\n const coerced = coerceValue(value, propOption?.type)\n const oldValue = this.#properties[name]\n if (oldValue === coerced) {\n return\n }\n this.#properties[name] = coerced\n this.#state[name] = coerced\n if (this.#isMounted) {\n this.requestUpdate()\n }\n runComponentObservers(runtimeState.componentRef, this.#publicInstance, [name], { [name]: oldValue })\n if (propOption?.observer) {\n this.#observedKeys.add(name)\n }\n }\n\n #runInitialObservers() {\n if (this.#observerInitDone) {\n return\n }\n this.#observerInitDone = true\n for (const [propName, propOption] of runtimeState.propertyEntries) {\n if (!propOption.observer || this.#observedKeys.has(propName)) {\n continue\n }\n const value = this.#state[propName]\n propOption.observer.call(this.#publicInstance, value, undefined)\n this.#observedKeys.add(propName)\n }\n }\n\n #syncMethods(nextMethods: ComponentOptions['methods']) {\n const resolved = nextMethods ?? {}\n const bound: Record<string, (event: any) => any> = {}\n for (const [name, fn] of Object.entries(resolved)) {\n if (typeof fn === 'function') {\n bound[name] = fn.bind(this.#publicInstance)\n }\n }\n for (const name of this.#exposedMethodNames) {\n if (name in bound) {\n continue\n }\n const descriptor = Object.getOwnPropertyDescriptor(this, name)\n if (descriptor?.configurable && descriptor.value === this.#methods[name]) {\n delete (this as unknown as Record<string, unknown>)[name]\n }\n this.#exposedMethodNames.delete(name)\n }\n for (const key of Object.keys(this.#methods)) {\n if (!(key in bound)) {\n delete this.#methods[key]\n }\n }\n for (const [key, fn] of Object.entries(bound)) {\n this.#methods[key] = fn\n if (!this.#exposedMethodNames.has(key) && key in this) {\n continue\n }\n Object.defineProperty(this, key, {\n configurable: true,\n enumerable: false,\n writable: true,\n value: fn,\n })\n this.#exposedMethodNames.add(key)\n }\n this.#renderContext = createRenderContext(this, this.#methods)\n }\n\n __weappSync(nextMethods: ComponentOptions['methods']) {\n this.#syncMethods(nextMethods)\n this.requestUpdate()\n }\n\n __weappInvokePageLifetime(type: keyof PageLifeTimeHooks) {\n const hook = runtimeState.pageLifetimes[type]\n if (typeof hook === 'function') {\n hook.call(this.#publicInstance)\n }\n }\n\n #renderLegacy() {\n const result = runtimeState.templateRef(this.#state, this.#renderContext)\n const root = resolveRenderRoot(this)\n const styleMarkup = runtimeState.styleRef ? `<style>${runtimeState.styleRef}</style>` : ''\n if (typeof result === 'string') {\n root.innerHTML = `${styleMarkup}${result}`\n bindRuntimeEvents(root as ShadowRoot, this.#methods, this)\n }\n else if (result == null) {\n root.innerHTML = styleMarkup\n }\n else {\n root.innerHTML = `${styleMarkup}${String(result)}`\n }\n this.#syncVirtualHostClasses()\n if (!this.#readyFired) {\n runtimeState.lifetimes.ready?.call(this.#publicInstance)\n this.#readyFired = true\n }\n }\n\n #syncVirtualHostClasses() {\n const host = this as unknown as ClassAttributeElement\n if (!runtimeState.componentRef.options?.virtualHost) {\n clearVirtualHostClasses(host, this.#virtualHostClassTokens)\n clearVirtualHostParts(this.#virtualHostRootElement, this.#virtualHostPartTokens)\n this.#virtualHostRootElement = undefined\n return\n }\n const root = resolveRenderRoot(this)\n syncVirtualHostClasses(host, root, this.#virtualHostClassTokens)\n this.#virtualHostRootElement = syncVirtualHostParts(\n root,\n this.#virtualHostRootElement,\n this.#virtualHostPartTokens,\n )\n }\n }\n\n return WeappWebComponent as WeappComponentElementClass\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA0CA,SAAS,sBAAsB,MAA8B;CAC3D,MAAM,eAAgB,KAAiB;CACvC,IAAI,cACF,OAAO;CAET,IAAI,KAAK,YACP,OAAO,KAAK;CAEd,MAAM,OAAO,KAAK,cAAc;CAChC,OAAO,gBAAgB,aAAa,KAAK,OAAO;AAClD;AAEA,SAAS,yBAAyB,OAAiD;CACjF,OAAO,QACL,SACG,OAAO,UAAU,YACjB,OAAQ,MAAiC,gBAAgB,UAC9D;AACF;AAEA,SAAgB,4BAA4B,EAC1C,aACA,cACA,aACiE;CACjE,MAAM,qBAAqB;CAG3B,MAAM,0BAA0B,mBAAqD;EACnF,WAAW,qBAAqB;GAC9B,MAAM,YAAY,MAAM,sBAAsB,CAAC;GAC/C,OAAO,MAAM,qBAAK,IAAI,IAAI,CAAC,GAAG,WAAW,GAAG,aAAa,kBAAkB,CAAC,CAAC;EAC/E;EAEA;EACA;EACA,WAAgD,CAAC;EACjD;EACA,sCAAsB,IAAI,IAAY;EACtC,aAAa;EACb,iBAAiB,oBAAoB,MAAM,CAAC,CAAC;EAC7C,sBAAsB;EACtB,cAAc;EACd,oBAAoB;EACpB,gCAAgB,IAAI,IAAY;EAChC,0CAA0B,IAAI,IAAY;EAC1C,yCAAyB,IAAI,IAAY;EACzC;EACA,AAAS;EACT,AAAS;EAET,cAAc;GACZ,MAAM;GACN,MAAM,aAAa,aAAa,aAAa,QAAQ,CAAC;GACtD,KAAK,cAAc,EAAE,GAAG,aAAa,sBAAsB;GAC3D,KAAK,SAAS;IAAE,GAAG,WAAW,KAAK,WAAW;IAAG,GAAG,WAAW,U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Ac,OAAO,MAAM;GAEjD,KAAK,wBAAwB;GAC7B,IAAI,CAAC,KAAK,aAAa;IACrB,aAAa,UAAU,OAAO,KAAK,KAAK,eAAe;IACvD,KAAK,cAAc;GACrB;EACF;EAEA,0BAA0B;GACxB,MAAM,OAAO;GACb,IAAI,CAAC,aAAa,aAAa,SAAS,aAAa;IACnD,wBAAwB,MAAM,KAAK,uBAAuB;IAC1D,sBAAsB,KAAK,yBAAyB,KAAK,sBAAsB;IAC/E,KAAK,0BAA0B;IAC/B;GACF;GACA,MAAM,OAAO,kBAAkB,IAAI;GACnC,uBAAuB,MAAM,MAAM,KAAK,uBAAuB;GAC/D,KAAK,0BAA0B,qBAC7B,MACA,KAAK,yBACL,KAAK,sBACP;EACF;CACF;CAEA,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"element.mjs","names":[],"sources":["../../../src/runtime/component/element.ts"],"sourcesContent":["import type {\n CreateComponentElementClassOptions,\n WeappComponentInstance,\n} from './elementTypes'\nimport type {\n ComponentOptions,\n ComponentPublicInstance,\n DataRecord,\n PageLifeTimeHooks,\n TriggerEventOptions,\n} from './types'\nimport type { ClassAttributeElement } from './virtualHost'\nimport { WEVU_HOST_COMMIT_PROMISE_KEY } from '@weapp-core/constants'\nimport { html } from 'lit'\nimport { unsafeHTML } from 'lit/directives/unsafe-html.js'\nimport { createIntersectionObserverBridge } from '../polyfill/intersectionObserver'\nimport { createRenderContext } from '../renderContext'\nimport { hasOwn } from '../utils/object'\nimport { supportsLit } from './constants'\nimport {\n createScopedSelectorQuery,\n resolveRenderRoot,\n selectRuntimeComponent,\n selectRuntimeComponents,\n} from './dom'\nimport { bindRuntimeEvents } from './events'\nimport { runComponentObservers } from './observers'\nimport { createComponentPublicInstance } from './publicInstance'\nimport { resolveRelationNodes } from './relations'\nimport { createWebSlotsProxy } from './slots'\nimport { assignDataPath, cloneValue, coerceValue, parseDataPath, resolveDataPath, toCamelCase } from './utils'\nimport {\n clearVirtualHostClasses,\n clearVirtualHostParts,\n syncVirtualHostClasses,\n syncVirtualHostParts,\n} from './virtualHost'\n\nexport type { WeappComponentInstance } from './elementTypes'\nexport type WeappComponentElementClass = typeof HTMLElement & {\n new (): WeappComponentInstance\n}\n\nfunction resolveComposedParent(node: Node): Node | undefined {\n const assignedSlot = (node as Element).assignedSlot\n if (assignedSlot) {\n return assignedSlot\n }\n if (node.parentNode) {\n return node.parentNode\n }\n const root = node.getRootNode?.()\n return root instanceof ShadowRoot ? root.host : undefined\n}\n\nfunction isWeappComponentInstance(value: unknown): value is WeappComponentInstance {\n return Boolean(\n value\n && typeof value === 'object'\n && typeof (value as WeappComponentInstance).__weappSync === 'function',\n )\n}\n\nexport function createComponentElementClass({\n BaseElement,\n runtimeState,\n instances,\n}: CreateComponentElementClassOptions): WeappComponentElementClass {\n const RuntimeBaseElement = BaseElement as typeof HTMLElement & {\n readonly observedAttributes?: string[]\n }\n class WeappWebComponent extends RuntimeBaseElement implements WeappComponentInstance {\n static get observedAttributes() {\n const inherited = super.observedAttributes ?? []\n return Array.from(new Set([...inherited, ...runtimeState.observedAttributes]))\n }\n\n #state: DataRecord\n #properties: DataRecord\n #methods: Record<string, (event: any) => any> = {}\n #publicInstance: ComponentPublicInstance\n #exposedMethodNames = new Set<string>()\n #isMounted = false\n #renderContext = createRenderContext(this, {})\n #usesLegacyTemplate = false\n #readyFired = false\n #observerInitDone = false\n #observedKeys = new Set<string>()\n #virtualHostClassTokens = new Set<string>()\n #virtualHostPartTokens = new Set<string>()\n #virtualHostRootElement: ClassAttributeElement | undefined\n #needsSetDataRecovery = false\n #hostCommitPromise: Promise<void> | undefined\n #hostCommitUpdate: Promise<boolean> | undefined\n readonly data!: DataRecord\n readonly properties!: DataRecord\n\n constructor() {\n super()\n const dataOption = runtimeState.componentRef.data ?? {}\n this.#properties = { ...runtimeState.defaultPropertyValues }\n this.#state = { ...cloneValue(this.#properties), ...cloneValue(dataOption) }\n Object.defineProperty(this.#state, '$slots', {\n configurable: true,\n enumerable: true,\n value: createWebSlotsProxy(() => this.#state.vueSlots),\n })\n Object.defineProperties(this, {\n data: {\n configurable: true,\n enumerable: true,\n get: () => this.#state,\n },\n properties: {\n configurable: true,\n enumerable: true,\n get: () => this.#properties,\n },\n })\n this.#publicInstance = createComponentPublicInstance(\n this,\n WeappWebComponent.prototype,\n key => typeof key === 'string' ? this.#methods[key] : undefined,\n )\n for (const [propName] of runtimeState.propertyEntries) {\n Object.defineProperty(this, propName, {\n configurable: true,\n enumerable: true,\n get: () => this.#state[propName],\n set: value => this.#setProperty(propName, value),\n })\n }\n this.#syncMethods(runtimeState.componentRef.methods ?? {})\n if (!supportsLit) {\n const host = this as unknown as HTMLElement\n if (!host.shadowRoot && typeof host.attachShadow === 'function') {\n host.attachShadow({ mode: 'open' })\n }\n ;(this as any).renderRoot = host.shadowRoot ?? host\n }\n instances.add(this)\n runtimeState.lifetimes.created?.call(this.#publicInstance)\n }\n\n get [WEVU_HOST_COMMIT_PROMISE_KEY]() {\n // 回调异常属于当前提交;后续属性更新或 HMR 必须等待自己的 Lit 提交。\n if (!supportsLit) {\n return undefined\n }\n // 动态 Lit 基类不会在静态声明中暴露 updateComplete。\n const litElement = this as unknown as { updateComplete: Promise<boolean> }\n const update = litElement.updateComplete\n return this.#hostCommitUpdate === update ? this.#hostCommitPromise : update\n }\n\n setData(patch: DataRecord, callback?: () => void) {\n const changed = this.#applyDataPatch(patch)\n if (supportsLit && (changed || this.#needsSetDataRecovery)) {\n if (!changed) {\n this.requestUpdate()\n }\n // 动态 Lit 基类不会在静态声明中暴露 updateComplete。\n const litElement = this as unknown as { updateComplete: Promise<boolean> }\n const update = litElement.updateComplete\n const commitPromise = update.then(\n () => {\n this.#needsSetDataRecovery = false\n callback?.()\n },\n (cause) => {\n this.#needsSetDataRecovery = true\n throw cause\n },\n )\n this.#hostCommitPromise = commitPromise\n this.#hostCommitUpdate = update\n return commitPromise\n }\n callback?.()\n }\n\n triggerEvent(name: string, detail?: any, options: TriggerEventOptions = {}) {\n this.dispatchEvent(new CustomEvent(name, {\n detail,\n bubbles: options.bubbles ?? false,\n composed: options.composed ?? false,\n }))\n }\n\n createSelectorQuery() {\n return createScopedSelectorQuery(this)\n }\n\n createIntersectionObserver(options?: {\n initialRatio?: number\n observeAll?: boolean\n thresholds?: number[]\n }) {\n return createIntersectionObserverBridge(this, options)\n }\n\n selectComponent(selector: string) {\n return selectRuntimeComponent(this, selector)\n }\n\n selectAllComponents(selector: string) {\n return selectRuntimeComponents(this, selector)\n }\n\n getRelationNodes(relationPath: string) {\n const relation = runtimeState.componentRef.relations?.[relationPath]\n return relation\n ? resolveRelationNodes(this, runtimeState.id, relationPath, relation.type)\n : []\n }\n\n selectOwnerComponent() {\n let current = resolveComposedParent(this)\n while (current) {\n if (isWeappComponentInstance(current)) {\n return current\n }\n current = resolveComposedParent(current)\n }\n return undefined\n }\n\n connectedCallback() {\n const superConnected = (BaseElement.prototype as { connectedCallback?: () => void }).connectedCallback\n if (supportsLit && typeof superConnected === 'function') {\n superConnected.call(this)\n }\n this.#applyAttributes()\n if (runtimeState.observerInitEnabled) {\n this.#runInitialObservers()\n }\n runtimeState.lifetimes.attached?.call(this.#publicInstance)\n this.#isMounted = true\n if (!supportsLit) {\n this.#renderLegacy()\n }\n }\n\n disconnectedCallback() {\n const superDisconnected = (BaseElement.prototype as { disconnectedCallback?: () => void }).disconnectedCallback\n if (supportsLit && typeof superDisconnected === 'function') {\n superDisconnected.call(this)\n }\n this.#isMounted = false\n instances.delete(this)\n runtimeState.lifetimes.detached?.call(this.#publicInstance)\n }\n\n attributeChangedCallback(attrName: string, oldValue: string | null, newValue: string | null) {\n const superAttributeChanged = (BaseElement.prototype as {\n attributeChangedCallback?: (name: string, oldValue: string | null, newValue: string | null) => void\n }).attributeChangedCallback\n if (supportsLit && typeof superAttributeChanged === 'function') {\n superAttributeChanged.call(this, attrName, oldValue, newValue)\n }\n const propName = toCamelCase(attrName)\n if (!hasOwn(this.#properties, propName)) {\n return\n }\n const propOption = runtimeState.componentRef.properties?.[propName]\n this.#setProperty(propName, coerceValue(newValue, propOption?.type))\n }\n\n firstUpdated() {\n runtimeState.lifetimes.ready?.call(this.#publicInstance)\n this.#readyFired = true\n }\n\n updated() {\n this.#syncVirtualHostClasses()\n if (this.#usesLegacyTemplate) {\n bindRuntimeEvents(resolveRenderRoot(this), this.#methods, this)\n }\n }\n\n render() {\n const result = runtimeState.templateRef(this.#state, this.#renderContext)\n const styleMarkup = runtimeState.styleRef\n ? html`<style>${runtimeState.styleRef}</style>`\n : null\n if (typeof result === 'string') {\n this.#usesLegacyTemplate = true\n return html`${styleMarkup}${unsafeHTML(result)}`\n }\n this.#usesLegacyTemplate = false\n if (styleMarkup) {\n return html`${styleMarkup}${result as any}`\n }\n return result\n }\n\n requestUpdate(name?: PropertyKey, oldValue?: unknown, options?: unknown) {\n const superRequestUpdate = (BaseElement.prototype as any).requestUpdate\n if (supportsLit && typeof superRequestUpdate === 'function') {\n return superRequestUpdate.call(this, name, oldValue, options)\n }\n if (this.#isMounted) {\n this.#renderLegacy()\n }\n return undefined\n }\n\n #applyAttributes() {\n if (!this.attributes || typeof this.attributes[Symbol.iterator] !== 'function') {\n return\n }\n for (const attr of this.attributes) {\n this.attributeChangedCallback(attr.name, null, attr.value)\n }\n }\n\n #applyDataPatch(patch: DataRecord) {\n if (!patch || typeof patch !== 'object') {\n return false\n }\n let changed = false\n const changedKeys: string[] = []\n const previousProperties: DataRecord = {}\n for (const [path, value] of Object.entries(patch)) {\n const segments = parseDataPath(path)\n const topKey = segments[0]\n if (!topKey || topKey === '$slots' || Object.is(resolveDataPath(this.#state, segments), value)) {\n continue\n }\n if (hasOwn(this.#properties, topKey) && !hasOwn(previousProperties, topKey)) {\n previousProperties[topKey] = this.#properties[topKey]\n }\n assignDataPath(this.#state, segments, value)\n if (hasOwn(this.#properties, topKey)) {\n this.#properties[topKey] = this.#state[topKey]\n }\n changedKeys.push(path)\n changed = true\n }\n if (changed) {\n this.requestUpdate()\n runComponentObservers(runtimeState.componentRef, this.#publicInstance, changedKeys, previousProperties)\n for (const key of changedKeys) {\n if (runtimeState.componentRef.properties?.[key]?.observer) {\n this.#observedKeys.add(key)\n }\n }\n }\n return changed\n }\n\n #setProperty(name: string, value: any) {\n const propOption = runtimeState.componentRef.properties?.[name]\n const coerced = coerceValue(value, propOption?.type)\n const oldValue = this.#properties[name]\n if (oldValue === coerced) {\n return\n }\n this.#properties[name] = coerced\n this.#state[name] = coerced\n if (this.#isMounted) {\n this.requestUpdate()\n }\n runComponentObservers(runtimeState.componentRef, this.#publicInstance, [name], { [name]: oldValue })\n if (propOption?.observer) {\n this.#observedKeys.add(name)\n }\n }\n\n #runInitialObservers() {\n if (this.#observerInitDone) {\n return\n }\n this.#observerInitDone = true\n for (const [propName, propOption] of runtimeState.propertyEntries) {\n if (!propOption.observer || this.#observedKeys.has(propName)) {\n continue\n }\n const value = this.#state[propName]\n propOption.observer.call(this.#publicInstance, value, undefined)\n this.#observedKeys.add(propName)\n }\n }\n\n #syncMethods(nextMethods: ComponentOptions['methods']) {\n const resolved = nextMethods ?? {}\n const bound: Record<string, (event: any) => any> = {}\n for (const [name, fn] of Object.entries(resolved)) {\n if (typeof fn === 'function') {\n bound[name] = fn.bind(this.#publicInstance)\n }\n }\n for (const name of this.#exposedMethodNames) {\n if (name in bound) {\n continue\n }\n const descriptor = Object.getOwnPropertyDescriptor(this, name)\n if (descriptor?.configurable && descriptor.value === this.#methods[name]) {\n delete (this as unknown as Record<string, unknown>)[name]\n }\n this.#exposedMethodNames.delete(name)\n }\n for (const key of Object.keys(this.#methods)) {\n if (!(key in bound)) {\n delete this.#methods[key]\n }\n }\n for (const [key, fn] of Object.entries(bound)) {\n this.#methods[key] = fn\n if (!this.#exposedMethodNames.has(key) && key in this) {\n continue\n }\n Object.defineProperty(this, key, {\n configurable: true,\n enumerable: false,\n writable: true,\n value: fn,\n })\n this.#exposedMethodNames.add(key)\n }\n this.#renderContext = createRenderContext(this, this.#methods)\n }\n\n __weappSync(nextMethods: ComponentOptions['methods']) {\n this.#syncMethods(nextMethods)\n this.requestUpdate()\n }\n\n __weappInvokePageLifetime(type: keyof PageLifeTimeHooks) {\n const hook = runtimeState.pageLifetimes[type]\n if (typeof hook === 'function') {\n hook.call(this.#publicInstance)\n }\n }\n\n #renderLegacy() {\n const result = runtimeState.templateRef(this.#state, this.#renderContext)\n const root = resolveRenderRoot(this)\n const styleMarkup = runtimeState.styleRef ? `<style>${runtimeState.styleRef}</style>` : ''\n if (typeof result === 'string') {\n root.innerHTML = `${styleMarkup}${result}`\n bindRuntimeEvents(root as ShadowRoot, this.#methods, this)\n }\n else if (result == null) {\n root.innerHTML = styleMarkup\n }\n else {\n root.innerHTML = `${styleMarkup}${String(result)}`\n }\n this.#syncVirtualHostClasses()\n if (!this.#readyFired) {\n runtimeState.lifetimes.ready?.call(this.#publicInstance)\n this.#readyFired = true\n }\n }\n\n #syncVirtualHostClasses() {\n const host = this as unknown as ClassAttributeElement\n if (!runtimeState.componentRef.options?.virtualHost) {\n clearVirtualHostClasses(host, this.#virtualHostClassTokens)\n clearVirtualHostParts(this.#virtualHostRootElement, this.#virtualHostPartTokens)\n this.#virtualHostRootElement = undefined\n return\n }\n const root = resolveRenderRoot(this)\n syncVirtualHostClasses(host, root, this.#virtualHostClassTokens)\n this.#virtualHostRootElement = syncVirtualHostParts(\n root,\n this.#virtualHostRootElement,\n this.#virtualHostPartTokens,\n )\n }\n }\n\n return WeappWebComponent as WeappComponentElementClass\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA2CA,SAAS,sBAAsB,MAA8B;CAC3D,MAAM,eAAgB,KAAiB;CACvC,IAAI,cACF,OAAO;CAET,IAAI,KAAK,YACP,OAAO,KAAK;CAEd,MAAM,OAAO,KAAK,cAAc;CAChC,OAAO,gBAAgB,aAAa,KAAK,OAAO;AAClD;AAEA,SAAS,yBAAyB,OAAiD;CACjF,OAAO,QACL,SACG,OAAO,UAAU,YACjB,OAAQ,MAAiC,gBAAgB,UAC9D;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AO;GACb,IAAI,CAAC,aAAa,aAAa,SAAS,aAAa;IACnD,wBAAwB,MAAM,KAAK,uBAAuB;IAC1D,sBAAsB,KAAK,yBAAyB,KAAK,sBAAsB;IAC/E,KAAK,0BAA0B;IAC/B;GACF;GACA,MAAM,OAAO,kBAAkB,IAAI;GACnC,uBAAuB,MAAM,MAAM,KAAK,uBAAuB;GAC/D,KAAK,0BAA0B,qBAC7B,MACA,KAAK,yBACL,KAAK,sBACP;EACF;CACF;CAEA,OAAO;AACT"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { EVENT_ATTRIBUTE_PREFIXES, EVENT_FLAG_ATTRIBUTE_PREFIXES } from "./constants.mjs";
|
|
1
|
+
import { EVENT_ATTRIBUTE_PREFIXES, EVENT_FLAG_ATTRIBUTE_PREFIXES, decodeEventAttributeName } from "./constants.mjs";
|
|
2
|
+
import { invokeMiniProgramEventHandler } from "../inputHandlerResult.mjs";
|
|
2
3
|
|
|
3
4
|
//#region src/runtime/component/events.ts
|
|
4
5
|
function parseEventFlags(value) {
|
|
@@ -25,8 +26,9 @@ function bindRuntimeEvents(root, methods, instance) {
|
|
|
25
26
|
if (!handlerName) continue;
|
|
26
27
|
const handler = methods[handlerName];
|
|
27
28
|
if (!handler) continue;
|
|
28
|
-
const
|
|
29
|
-
const
|
|
29
|
+
const encodedEventName = attribute.slice(matchedPrefix.length);
|
|
30
|
+
const eventName = decodeEventAttributeName(encodedEventName);
|
|
31
|
+
const flags = parseEventFlags(EVENT_FLAG_ATTRIBUTE_PREFIXES.map((prefix) => element.getAttribute(`${prefix}${encodedEventName}`)).find((value) => value !== null) ?? null);
|
|
30
32
|
element.addEventListener(eventName, (nativeEvent) => {
|
|
31
33
|
if (flags.catch) nativeEvent.stopPropagation();
|
|
32
34
|
const dataset = { ...element.dataset };
|
|
@@ -38,7 +40,7 @@ function bindRuntimeEvents(root, methods, instance) {
|
|
|
38
40
|
currentTarget: { dataset },
|
|
39
41
|
originalEvent: nativeEvent
|
|
40
42
|
};
|
|
41
|
-
handler
|
|
43
|
+
invokeMiniProgramEventHandler(handler, instance, syntheticEvent, nativeEvent);
|
|
42
44
|
}, flags.capture);
|
|
43
45
|
}
|
|
44
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.mjs","names":[],"sources":["../../../src/runtime/component/events.ts"],"sourcesContent":["import type { ComponentPublicInstance } from './types'\nimport {\n EVENT_ATTRIBUTE_PREFIXES,\n EVENT_FLAG_ATTRIBUTE_PREFIXES,\n} from './constants'\n\nfunction parseEventFlags(value: string | null) {\n if (!value) {\n return { catch: false, capture: false }\n }\n const tokens = value.split(',').map(token => token.trim()).filter(Boolean)\n const tokenSet = new Set(tokens)\n return {\n catch: tokenSet.has('catch'),\n capture: tokenSet.has('capture'),\n }\n}\n\nexport function bindRuntimeEvents(\n root: HTMLElement | ShadowRoot,\n methods: Record<string, (event: any) => any>,\n instance: ComponentPublicInstance,\n) {\n if (typeof document === 'undefined') {\n return\n }\n const walker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT)\n while (walker.nextNode()) {\n const element = walker.currentNode as HTMLElement\n for (const attribute of element.getAttributeNames()) {\n const matchedPrefix = EVENT_ATTRIBUTE_PREFIXES.find(prefix => attribute.startsWith(prefix))\n if (!matchedPrefix || EVENT_FLAG_ATTRIBUTE_PREFIXES.some(prefix => attribute.startsWith(prefix))) {\n continue\n }\n const handlerName = element.getAttribute(attribute)\n if (!handlerName) {\n continue\n }\n const handler = methods[handlerName]\n if (!handler) {\n continue\n }\n const
|
|
1
|
+
{"version":3,"file":"events.mjs","names":[],"sources":["../../../src/runtime/component/events.ts"],"sourcesContent":["import type { ComponentPublicInstance } from './types'\nimport { invokeMiniProgramEventHandler } from '../inputHandlerResult'\nimport {\n decodeEventAttributeName,\n EVENT_ATTRIBUTE_PREFIXES,\n EVENT_FLAG_ATTRIBUTE_PREFIXES,\n} from './constants'\n\nfunction parseEventFlags(value: string | null) {\n if (!value) {\n return { catch: false, capture: false }\n }\n const tokens = value.split(',').map(token => token.trim()).filter(Boolean)\n const tokenSet = new Set(tokens)\n return {\n catch: tokenSet.has('catch'),\n capture: tokenSet.has('capture'),\n }\n}\n\nexport function bindRuntimeEvents(\n root: HTMLElement | ShadowRoot,\n methods: Record<string, (event: any) => any>,\n instance: ComponentPublicInstance,\n) {\n if (typeof document === 'undefined') {\n return\n }\n const walker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT)\n while (walker.nextNode()) {\n const element = walker.currentNode as HTMLElement\n for (const attribute of element.getAttributeNames()) {\n const matchedPrefix = EVENT_ATTRIBUTE_PREFIXES.find(prefix => attribute.startsWith(prefix))\n if (!matchedPrefix || EVENT_FLAG_ATTRIBUTE_PREFIXES.some(prefix => attribute.startsWith(prefix))) {\n continue\n }\n const handlerName = element.getAttribute(attribute)\n if (!handlerName) {\n continue\n }\n const handler = methods[handlerName]\n if (!handler) {\n continue\n }\n const encodedEventName = attribute.slice(matchedPrefix.length)\n const eventName = decodeEventAttributeName(encodedEventName)\n const flagAttributeValue = EVENT_FLAG_ATTRIBUTE_PREFIXES\n .map(prefix => element.getAttribute(`${prefix}${encodedEventName}`))\n .find(value => value !== null) ?? null\n const flags = parseEventFlags(flagAttributeValue)\n element.addEventListener(eventName, (nativeEvent) => {\n if (flags.catch) {\n nativeEvent.stopPropagation()\n }\n const dataset = { ...element.dataset }\n const syntheticEvent = {\n type: eventName,\n timeStamp: nativeEvent.timeStamp,\n detail: (nativeEvent as CustomEvent).detail ?? (nativeEvent as InputEvent).data ?? undefined,\n target: {\n dataset,\n },\n currentTarget: {\n dataset,\n },\n originalEvent: nativeEvent,\n }\n invokeMiniProgramEventHandler(handler, instance, syntheticEvent, nativeEvent)\n }, flags.capture)\n }\n }\n}\n"],"mappings":";;;;AAQA,SAAS,gBAAgB,OAAsB;CAC7C,IAAI,CAAC,OACH,OAAO;EAAE,OAAO;EAAO,SAAS;CAAM;CAExC,MAAM,SAAS,MAAM,MAAM,GAAG,C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1,16 @@
|
|
|
1
|
+
import { AsyncDirective, ElementPart, PartInfo } from "lit/async-directive.js";
|
|
2
|
+
//#region src/runtime/eventBinding.d.ts
|
|
3
|
+
interface RuntimeEventFlags {
|
|
4
|
+
capture?: boolean;
|
|
5
|
+
}
|
|
6
|
+
declare class RuntimeEventBindingDirective extends AsyncDirective {
|
|
7
|
+
#private;
|
|
8
|
+
constructor(partInfo: PartInfo);
|
|
9
|
+
render(_eventName: string, _listener: EventListener, _flags?: RuntimeEventFlags): symbol;
|
|
10
|
+
update(part: ElementPart, [eventName, listener, flags]: Parameters<this['render']>): symbol;
|
|
11
|
+
protected disconnected(): void;
|
|
12
|
+
protected reconnected(): void;
|
|
13
|
+
}
|
|
14
|
+
export declare const bindRuntimeEvent: (_eventName: string, _listener: EventListener, _flags?: RuntimeEventFlags | undefined) => import("lit/async-directive.js").DirectiveResult<typeof RuntimeEventBindingDirective>;
|
|
15
|
+
//#endregion
|
|
16
|
+
//# sourceMappingURL=eventBinding.d.mts.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { nothing } from "lit";
|
|
2
|
+
import { AsyncDirective, PartType, directive } from "lit/async-directive.js";
|
|
3
|
+
|
|
4
|
+
//#region src/runtime/eventBinding.ts
|
|
5
|
+
var RuntimeEventBindingDirective = class extends AsyncDirective {
|
|
6
|
+
#capture = false;
|
|
7
|
+
#element;
|
|
8
|
+
#eventName;
|
|
9
|
+
#listener;
|
|
10
|
+
#listening = false;
|
|
11
|
+
constructor(partInfo) {
|
|
12
|
+
super(partInfo);
|
|
13
|
+
if (partInfo.type !== PartType.ELEMENT) throw new TypeError("Runtime event bindings must be used in an element expression.");
|
|
14
|
+
}
|
|
15
|
+
render(_eventName, _listener, _flags) {
|
|
16
|
+
return nothing;
|
|
17
|
+
}
|
|
18
|
+
update(part, [eventName, listener, flags]) {
|
|
19
|
+
const capture = Boolean(flags?.capture);
|
|
20
|
+
if (part.element !== this.#element || eventName !== this.#eventName || listener !== this.#listener || capture !== this.#capture) {
|
|
21
|
+
this.#removeListener();
|
|
22
|
+
this.#element = part.element;
|
|
23
|
+
this.#eventName = eventName;
|
|
24
|
+
this.#listener = listener;
|
|
25
|
+
this.#capture = capture;
|
|
26
|
+
this.#addListener();
|
|
27
|
+
}
|
|
28
|
+
return nothing;
|
|
29
|
+
}
|
|
30
|
+
disconnected() {
|
|
31
|
+
this.#removeListener();
|
|
32
|
+
}
|
|
33
|
+
reconnected() {
|
|
34
|
+
this.#addListener();
|
|
35
|
+
}
|
|
36
|
+
#addListener() {
|
|
37
|
+
if (!this.isConnected || this.#listening || !this.#element || !this.#eventName || !this.#listener) return;
|
|
38
|
+
this.#element.addEventListener(this.#eventName, this.#listener, this.#capture);
|
|
39
|
+
this.#listening = true;
|
|
40
|
+
}
|
|
41
|
+
#removeListener() {
|
|
42
|
+
if (!this.#listening || !this.#element || !this.#eventName || !this.#listener) return;
|
|
43
|
+
this.#element.removeEventListener(this.#eventName, this.#listener, this.#capture);
|
|
44
|
+
this.#listening = false;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
const bindRuntimeEvent = directive(RuntimeEventBindingDirective);
|
|
48
|
+
|
|
49
|
+
//#endregion
|
|
50
|
+
export { bindRuntimeEvent };
|
|
51
|
+
//# sourceMappingURL=eventBinding.mjs.map
|
|
@@ -0,0 +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"}
|
package/dist/runtime/index.d.mts
CHANGED
|
@@ -2,10 +2,12 @@ import { RenderContext, createRenderContext } from "./renderContext.mjs";
|
|
|
2
2
|
import { createTemplate, renderTemplate } from "./legacyTemplate/index.mjs";
|
|
3
3
|
import { TemplateRenderer, TemplateScope } from "./template.mjs";
|
|
4
4
|
import { defineComponent } from "./component/index.mjs";
|
|
5
|
+
import { AppHideCallback, AppHideOptions, AppLaunchOptions, AppShowCallback } from "./polyfill/routeRuntime/options.mjs";
|
|
5
6
|
import { ResolvedWebRoutingConfig, WebRouteHistoryState, WebRouteTarget, WebRoutingConfig, WebRoutingMode, disposeWebRouting, getWebRoutingConfig, resolveWebRoutingConfig } from "./polyfill/routeRuntime/history.mjs";
|
|
6
7
|
import { WebPageHead, WebResourceHint, WebResourceHintRelation, WebResourceHintsConfig, WebRuntimeSeoConfig as WebSeoConfig, configureWebSeo, resetWebDocumentHead, setupWebResourceHints, syncWebDocumentHead, updateWebDocumentTitle } from "./seo/index.mjs";
|
|
7
8
|
import { WebTabBarConfig, WebTabBarItem } from "../shared/tabBar.mjs";
|
|
8
9
|
import { ButtonFormConfig, ensureButtonDefined, setButtonFormConfig } from "./button/index.mjs";
|
|
10
|
+
import { bindRuntimeEvent } from "./eventBinding.mjs";
|
|
9
11
|
import { getRuntimeExecutionMode, setRuntimeExecutionMode } from "./execution.mjs";
|
|
10
12
|
import { WebRuntimeClipboard, WebRuntimeDialogs, WebRuntimeHost, WebRuntimeStorage } from "./host/types.mjs";
|
|
11
13
|
import { getRuntimeClipboard, getRuntimeDialogs, getRuntimeFetch, getRuntimeStorage, getWebRuntimeHost, openRuntimeUrl, resetWebRuntimeHost, setWebRuntimeHost } from "./host/index.mjs";
|
|
@@ -22,7 +24,7 @@ import { setPageLayout } from "./pageLayout.mjs";
|
|
|
22
24
|
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 "./polyfill/deviceAuthSystemApi.mjs";
|
|
23
25
|
import { ResolvedWebViewportConfig, WebViewportConfig } from "./viewport/types.mjs";
|
|
24
26
|
import { getWebViewportWidth, resolveWebViewportConfig, setupWebViewport } from "./viewport/index.mjs";
|
|
25
|
-
import { getEnterOptionsSync, getLaunchOptionsSync, initializePageRoutes, navigateBack, navigateTo, reLaunch, redirectTo, registerApp, registerComponent, registerPage, switchTab } from "./polyfill/routeRuntime.mjs";
|
|
27
|
+
import { getEnterOptionsSync, getLaunchOptionsSync, initializePageRoutes, navigateBack, navigateTo, offAppHide, offAppShow, onAppHide, onAppShow, reLaunch, redirectTo, registerApp, registerComponent, registerPage, switchTab } from "./polyfill/routeRuntime.mjs";
|
|
26
28
|
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";
|
|
27
29
|
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";
|
|
28
30
|
import { canIUse, createInterstitialAd, createRewardedVideoAd, getExtConfig, getExtConfigSync, getLogManager, getUpdateManager, hideNavigationBarLoading, reportAnalytics, setBackgroundColor, setBackgroundTextStyle, setNavigationBarColor, setNavigationBarTitle, showNavigationBarLoading } from "./polyfill/index.mjs";
|
|
@@ -30,6 +32,6 @@ import "./polyfill.mjs";
|
|
|
30
32
|
import { RpxConfig, setupRpx } from "./rpx.mjs";
|
|
31
33
|
import { injectStyle, removeStyle } from "./style.mjs";
|
|
32
34
|
import { RuntimeWarningLevel, RuntimeWarningOptions, setRuntimeWarningOptions } from "./warning.mjs";
|
|
33
|
-
import { installWebModuleRegistration, registerWebWevuApp, registerWebWevuComponent } from "./wevu.mjs";
|
|
35
|
+
import { installWebModuleRegistration, registerWebWevuApp, registerWebWevuComponent, registerWebWevuComponentFactory } from "./wevu.mjs";
|
|
34
36
|
export * from "wevu/internal-runtime";
|
|
35
|
-
export { 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, 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, offNetworkStatusChange, offWindowResize, onNetworkStatusChange, onWindowResize, openAppAuthorizeSetting, openCustomerServiceChat, openDocument, openLocation, openRuntimeUrl, openSetting, openVideoEditor, pageScrollTo, preloadSubpackage, previewImage, previewMedia, reLaunch, redirectTo, registerApp, registerComponent, registerPage, registerWebWevuApp, registerWebWevuComponent, 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 };
|
|
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 };
|
package/dist/runtime/index.mjs
CHANGED
|
@@ -6,6 +6,7 @@ import { ensureButtonDefined, setButtonFormConfig } from "./button/index.mjs";
|
|
|
6
6
|
import { getRuntimeExecutionMode, setRuntimeExecutionMode } from "./execution.mjs";
|
|
7
7
|
import { createRenderContext } from "./renderContext.mjs";
|
|
8
8
|
import { defineComponent } from "./component/index.mjs";
|
|
9
|
+
import { bindRuntimeEvent } from "./eventBinding.mjs";
|
|
9
10
|
import { getRuntimeClipboard, getRuntimeDialogs, getRuntimeFetch, getRuntimeStorage, getWebRuntimeHost, openRuntimeUrl, resetWebRuntimeHost, setWebRuntimeHost } from "./host/index.mjs";
|
|
10
11
|
import { resolveImageModeStyle } from "./nativeComponents/image.mjs";
|
|
11
12
|
import { createInputEventDetail } from "./nativeComponents/input.mjs";
|
|
@@ -14,7 +15,7 @@ import { getWebViewportWidth, resolveWebViewportConfig, setupWebViewport } from
|
|
|
14
15
|
import { setupRpx } from "./rpx.mjs";
|
|
15
16
|
import { configureWebSeo, resetWebDocumentHead, setupWebResourceHints, syncWebDocumentHead, updateWebDocumentTitle } from "./seo/index.mjs";
|
|
16
17
|
import { disposeWebRouting, getWebRoutingConfig, resolveWebRoutingConfig } from "./polyfill/routeRuntime/history.mjs";
|
|
17
|
-
import { getEnterOptionsSync, getLaunchOptionsSync, initializePageRoutes, navigateBack, navigateTo, reLaunch, redirectTo, registerApp, registerComponent, registerPage, switchTab } from "./polyfill/routeRuntime.mjs";
|
|
18
|
+
import { getEnterOptionsSync, getLaunchOptionsSync, initializePageRoutes, navigateBack, navigateTo, offAppHide, offAppShow, onAppHide, onAppShow, reLaunch, redirectTo, registerApp, registerComponent, registerPage, switchTab } from "./polyfill/routeRuntime.mjs";
|
|
18
19
|
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";
|
|
19
20
|
import { createScrollEventDetail } from "./nativeComponents/scrollView.mjs";
|
|
20
21
|
import { createSwitchEventDetail } from "./nativeComponents/switch.mjs";
|
|
@@ -26,7 +27,7 @@ import { authorize, checkSession, getAccountInfoSync, getAppAuthorizeSetting, ge
|
|
|
26
27
|
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";
|
|
27
28
|
import { canIUse, createInterstitialAd, createRewardedVideoAd, getExtConfig, getExtConfigSync, getLogManager, getUpdateManager, hideNavigationBarLoading, reportAnalytics, setBackgroundColor, setBackgroundTextStyle, setNavigationBarColor, setNavigationBarTitle, showNavigationBarLoading } from "./polyfill/index.mjs";
|
|
28
29
|
import { createTemplate, renderTemplate } from "./legacyTemplate/index.mjs";
|
|
29
|
-
import { installWebModuleRegistration, registerWebWevuApp, registerWebWevuComponent } from "./wevu.mjs";
|
|
30
|
+
import { installWebModuleRegistration, registerWebWevuApp, registerWebWevuComponent, registerWebWevuComponentFactory } from "./wevu.mjs";
|
|
30
31
|
|
|
31
32
|
export * from "wevu/internal-runtime"
|
|
32
33
|
|
|
@@ -34,5 +35,5 @@ export * from "wevu/internal-runtime"
|
|
|
34
35
|
installWebHostGlobals();
|
|
35
36
|
|
|
36
37
|
//#endregion
|
|
37
|
-
export { authorize, 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, offNetworkStatusChange, offWindowResize, onNetworkStatusChange, onWindowResize, openAppAuthorizeSetting, openCustomerServiceChat, openDocument, openLocation, openRuntimeUrl, openSetting, openVideoEditor, pageScrollTo, preloadSubpackage, previewImage, previewMedia, reLaunch, redirectTo, registerApp, registerComponent, registerPage, registerWebWevuApp, registerWebWevuComponent, 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 { 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
39
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/runtime/index.ts"],"sourcesContent":["import { installWebHostGlobals } from './hostGlobals'\n\ninstallWebHostGlobals()\n\nexport type { WebTabBarConfig, WebTabBarItem } from './appShell/tabBar'\nexport { ensureButtonDefined, setButtonFormConfig } from './button'\nexport type { ButtonFormConfig } from './button'\nexport { defineComponent } from './component'\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 offNetworkStatusChange,\n offWindowResize,\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 {\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 {
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/runtime/index.ts"],"sourcesContent":["import { installWebHostGlobals } from './hostGlobals'\n\ninstallWebHostGlobals()\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,sBAAsB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/runtime/inputHandlerResult.ts
|
|
2
|
+
const nativeInputEventStates = /* @__PURE__ */ new WeakMap();
|
|
3
|
+
function dispatchNativeInputEvent(target, detail) {
|
|
4
|
+
const event = new CustomEvent("input", {
|
|
5
|
+
bubbles: true,
|
|
6
|
+
composed: true,
|
|
7
|
+
detail
|
|
8
|
+
});
|
|
9
|
+
const state = { target };
|
|
10
|
+
nativeInputEventStates.set(event, state);
|
|
11
|
+
target.dispatchEvent(event);
|
|
12
|
+
return state.value;
|
|
13
|
+
}
|
|
14
|
+
function invokeMiniProgramEventHandler(handler, instance, syntheticEvent, nativeEvent) {
|
|
15
|
+
const result = handler.call(instance, syntheticEvent);
|
|
16
|
+
const state = nativeEvent.type === "input" ? nativeInputEventStates.get(nativeEvent) : void 0;
|
|
17
|
+
if (state?.target === nativeEvent.currentTarget && typeof result === "string") state.value = result;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
export { dispatchNativeInputEvent, invokeMiniProgramEventHandler };
|
|
22
|
+
//# sourceMappingURL=inputHandlerResult.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inputHandlerResult.mjs","names":[],"sources":["../../src/runtime/inputHandlerResult.ts"],"sourcesContent":["interface NativeInputEventState {\n target: Element\n value?: string\n}\n\nconst nativeInputEventStates = new WeakMap<Event, NativeInputEventState>()\n\nexport function dispatchNativeInputEvent<T>(target: Element, detail: T) {\n const event = new CustomEvent<T>('input', {\n bubbles: true,\n composed: true,\n detail,\n })\n const state: NativeInputEventState = { target }\n nativeInputEventStates.set(event, state)\n target.dispatchEvent(event)\n return state.value\n}\n\nexport function invokeMiniProgramEventHandler(\n handler: (event: unknown) => unknown,\n instance: unknown,\n syntheticEvent: unknown,\n nativeEvent: Event,\n) {\n const result = handler.call(instance, syntheticEvent)\n const state = nativeEvent.type === 'input'\n ? nativeInputEventStates.get(nativeEvent)\n : undefined\n if (state?.target === nativeEvent.currentTarget && typeof result === 'string') {\n state.value = result\n }\n}\n"],"mappings":";AAKA,MAAM,yCAAyB,IAAI,QAAsC;AAEzE,SAAgB,yBAA4B,QAAiB,QAAW;CACtE,MAAM,QAAQ,IAAI,YAAe,SAAS;EACxC,SAAS;EACT,UAAU;EACV;CACF,CAAC;CACD,MAAM,QAA+B,EAAE,OAAO;CAC9C,uBAAuB,IAAI,OAAO,KAAK;CACvC,OAAO,cAAc,KAAK;CAC1B,OAAO,MAAM;AACf;AAEA,SAAgB,8BACd,SACA,UACA,gBACA,aACA;CACA,MAAM,SAAS,QAAQ,KAAK,UAAU,cAAc;CACpD,MAAM,QAAQ,YAAY,SAAS,UAC/B,uBAAuB,IAAI,WAAW,IACtC;CACJ,IAAI,OAAO,WAAW,YAAY,iBAAiB,OAAO,WAAW,UACnE,MAAM,QAAQ;AAElB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CONTROL_ATTRS, hasControlAttribute, normalizeAttributeName, resolveControlAttributeValue } from "../../shared/wxml.mjs";
|
|
2
|
-
import { MINI_PROGRAM_EVENT_ATTRIBUTE_PREFIX, MINI_PROGRAM_EVENT_FLAG_ATTRIBUTE_PREFIX } from "../component/constants.mjs";
|
|
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
|
|
@@ -19,6 +19,24 @@ const EVENT_PREFIX_FLAGS = {
|
|
|
19
19
|
catch: true
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
|
+
function parseEventAttribute(name) {
|
|
23
|
+
const separatorIndex = name.indexOf(":");
|
|
24
|
+
if (separatorIndex >= 0) {
|
|
25
|
+
const prefix = name.slice(0, separatorIndex);
|
|
26
|
+
const rawEvent = name.slice(separatorIndex + 1);
|
|
27
|
+
if (rawEvent && prefix in EVENT_PREFIX_FLAGS) return {
|
|
28
|
+
prefix,
|
|
29
|
+
rawEvent
|
|
30
|
+
};
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const match = EVENT_PREFIX_RE.exec(name);
|
|
34
|
+
if (!match) return;
|
|
35
|
+
return {
|
|
36
|
+
prefix: match[1],
|
|
37
|
+
rawEvent: match[2]
|
|
38
|
+
};
|
|
39
|
+
}
|
|
22
40
|
function extractFor(attribs) {
|
|
23
41
|
const expr = resolveControlAttributeValue(attribs, "for");
|
|
24
42
|
const restAttribs = {};
|
|
@@ -40,17 +58,17 @@ function buildAttributeString(attribs, scope) {
|
|
|
40
58
|
let result = "";
|
|
41
59
|
for (const [name, rawValue] of Object.entries(attribs)) {
|
|
42
60
|
if (CONTROL_ATTRS.has(name)) continue;
|
|
43
|
-
const
|
|
44
|
-
if (
|
|
45
|
-
const
|
|
46
|
-
const
|
|
61
|
+
const eventInfo = parseEventAttribute(name);
|
|
62
|
+
if (eventInfo) {
|
|
63
|
+
const normalizedEvent = eventInfo.rawEvent.toLowerCase();
|
|
64
|
+
const runtimeEvent = EVENT_KIND_ALIAS[normalizedEvent] ?? eventInfo.rawEvent;
|
|
65
|
+
const encodedEvent = encodeEventAttributeName(runtimeEvent);
|
|
47
66
|
const handlerName = resolveAttributeValue(rawValue, scope).trim();
|
|
48
67
|
if (!handlerName) continue;
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
result += ` ${MINI_PROGRAM_EVENT_ATTRIBUTE_PREFIX}${runtimeEvent}="${escapeAttribute(handlerName)}"`;
|
|
68
|
+
const flags = EVENT_PREFIX_FLAGS[eventInfo.prefix];
|
|
69
|
+
result += ` ${MINI_PROGRAM_EVENT_ATTRIBUTE_PREFIX}${encodedEvent}="${escapeAttribute(handlerName)}"`;
|
|
52
70
|
const flagTokens = [flags.capture ? "capture" : "", flags.catch ? "catch" : ""].filter(Boolean);
|
|
53
|
-
if (flagTokens.length) result += ` ${MINI_PROGRAM_EVENT_FLAG_ATTRIBUTE_PREFIX}${
|
|
71
|
+
if (flagTokens.length) result += ` ${MINI_PROGRAM_EVENT_FLAG_ATTRIBUTE_PREFIX}${encodedEvent}="${flagTokens.join(",")}"`;
|
|
54
72
|
continue;
|
|
55
73
|
}
|
|
56
74
|
const value = resolveAttributeValue(rawValue, scope);
|
|
@@ -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 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\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
|
|
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(attribs, 'if')\n || hasControlAttribute(attribs, 'elif')\n || hasControlAttribute(attribs, 'else')\n}\n"],"mappings":";;;;;AAeA,MAAM,kBAAkB;AACxB,MAAM,mBAA2C;CAC/C,KAAK;CACL,SAAS;CACT,WAAW;AACb;AAEA,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,KAAK,QAAQ,GAAG;CACvC,IAAI,kBAAkB,GAAG;EACvB,MAAM,SAAS,KAAK,MAAM,GAAG,cAAc;EAC3C,MAAM,WAAW,KAAK,MAAM,iBAAiB,CAAC;EAC9C,IAAI,YAAY,UAAU,oBACxB,OAAO;GAAE;GAAQ;EAAS;EAE5B;CACF;CACA,MAAM,QAAQ,gBAAgB,KAAK,IAAI;CACvC,IAAI,CAAC,OACH;CAEF,OAAO;EAAE,QAAQ,MAAM;EAAK,UAAU,MAAM;CAAI;AAClD;AAEA,SAAgB,WAAW,SAAmD;CAC5E,MAAM,OAAO,6BAA6B,SAAS,KAAK;CACxD,MAAM,cAAsC,CAAC;CAC7C,MAAM,WAAW,6BAA6B,SAAS,UAAU,CAAC,EAAE,KAAK,KAAK;CAC9E,IAAI,YAA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I,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"}
|
|
@@ -2,6 +2,7 @@ import { getNativeComponentDescriptor } from "../../shared/nativeComponents.mjs"
|
|
|
2
2
|
import { connectFormControl, disconnectFormControl } from "./formControl.mjs";
|
|
3
3
|
import { dispatchMiniProgramEvent, readBooleanAttribute, resolveContainingShadowRoot, resolveMaxLength } from "./helpers.mjs";
|
|
4
4
|
import { ensureNativeComponentStyle } from "./style.mjs";
|
|
5
|
+
import { dispatchNativeInputEvent } from "../inputHandlerResult.mjs";
|
|
5
6
|
|
|
6
7
|
//#region src/runtime/nativeComponents/input.ts
|
|
7
8
|
const BaseElement = globalThis.HTMLElement ?? class {};
|
|
@@ -90,7 +91,8 @@ var WeappInput = class extends BaseElement {
|
|
|
90
91
|
const input = document.createElement("input");
|
|
91
92
|
input.addEventListener("input", (event) => {
|
|
92
93
|
event.stopPropagation();
|
|
93
|
-
|
|
94
|
+
const returnedValue = dispatchNativeInputEvent(this, createInputEventDetail(input));
|
|
95
|
+
if (returnedValue !== void 0) input.value = returnedValue;
|
|
94
96
|
});
|
|
95
97
|
input.addEventListener("focus", () => {
|
|
96
98
|
dispatchMiniProgramEvent(this, "focus", {
|