feat(macos): add Canvas A2UI renderer
This commit is contained in:
28
vendor/a2ui/renderers/lit/src/0.8/events/a2ui.ts
vendored
Normal file
28
vendor/a2ui/renderers/lit/src/0.8/events/a2ui.ts
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
Copyright 2025 Google LLC
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { Action } from "../types/components.js";
|
||||
import { AnyComponentNode } from "../types/types.js";
|
||||
import { BaseEventDetail } from "./base.js";
|
||||
|
||||
type Namespace = "a2ui";
|
||||
|
||||
export interface A2UIAction extends BaseEventDetail<`${Namespace}.action`> {
|
||||
readonly action: Action;
|
||||
readonly dataContextPath: string;
|
||||
readonly sourceComponentId: string;
|
||||
readonly sourceComponent: AnyComponentNode | null;
|
||||
}
|
||||
19
vendor/a2ui/renderers/lit/src/0.8/events/base.ts
vendored
Normal file
19
vendor/a2ui/renderers/lit/src/0.8/events/base.ts
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
Copyright 2025 Google LLC
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
export interface BaseEventDetail<EventType extends string> {
|
||||
readonly eventType: EventType;
|
||||
}
|
||||
53
vendor/a2ui/renderers/lit/src/0.8/events/events.ts
vendored
Normal file
53
vendor/a2ui/renderers/lit/src/0.8/events/events.ts
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
Copyright 2025 Google LLC
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import type * as A2UI from "./a2ui.js";
|
||||
import { BaseEventDetail } from "./base.js";
|
||||
|
||||
const eventInit = {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
composed: true,
|
||||
};
|
||||
|
||||
type EnforceEventTypeMatch<T extends Record<string, BaseEventDetail<string>>> =
|
||||
{
|
||||
[K in keyof T]: T[K] extends BaseEventDetail<infer EventType>
|
||||
? EventType extends K
|
||||
? T[K]
|
||||
: never
|
||||
: never;
|
||||
};
|
||||
|
||||
export type StateEventDetailMap = EnforceEventTypeMatch<{
|
||||
"a2ui.action": A2UI.A2UIAction;
|
||||
}>;
|
||||
|
||||
export class StateEvent<
|
||||
T extends keyof StateEventDetailMap
|
||||
> extends CustomEvent<StateEventDetailMap[T]> {
|
||||
static eventName = "a2uiaction";
|
||||
|
||||
constructor(readonly payload: StateEventDetailMap[T]) {
|
||||
super(StateEvent.eventName, { detail: payload, ...eventInit });
|
||||
}
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface HTMLElementEventMap {
|
||||
a2uiaction: StateEvent<"a2ui.action">;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user