@ait-co/devtools 0.1.29 → 0.1.31

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.
@@ -1050,7 +1050,7 @@ function readGlobalString(key) {
1050
1050
  }
1051
1051
  const TELEMETRY_ENDPOINT = readGlobalString("__TELEMETRY_ENDPOINT__") ?? "https://t.aitc.dev";
1052
1052
  function getVersion() {
1053
- return "0.1.29";
1053
+ return "0.1.31";
1054
1054
  }
1055
1055
  let panelVisibleSince = null;
1056
1056
  let accumulatedMs = 0;
@@ -1826,7 +1826,7 @@ function checkPermission(name, fnName) {
1826
1826
  //#endregion
1827
1827
  //#region src/mock/device/camera.ts
1828
1828
  /**
1829
- * Camera & Album Photos mock
1829
+ * Camera & Album Photos & Album Items mock
1830
1830
  * mock/web/prompt 모드 지원
1831
1831
  */
1832
1832
  async function openCameraMock() {
@@ -1938,6 +1938,66 @@ const _fetchAlbumPhotos = async (options) => {
1938
1938
  return fetchAlbumPhotosMock(maxCount);
1939
1939
  };
1940
1940
  withPermission(_fetchAlbumPhotos, "photos");
1941
+ async function fetchAlbumItemsMock(maxCount, types) {
1942
+ return getMockImages().slice(0, maxCount).filter(() => types.includes("PHOTO")).map((dataUri) => ({
1943
+ id: crypto.randomUUID(),
1944
+ dataUri,
1945
+ type: "PHOTO"
1946
+ }));
1947
+ }
1948
+ async function fetchAlbumItemsWeb(maxCount, types) {
1949
+ return new Promise((resolve) => {
1950
+ const input = document.createElement("input");
1951
+ input.type = "file";
1952
+ input.accept = types.includes("VIDEO") ? "image/*,video/*" : "image/*";
1953
+ input.multiple = true;
1954
+ let settled = false;
1955
+ input.onchange = async () => {
1956
+ settled = true;
1957
+ const files = Array.from(input.files ?? []).slice(0, maxCount);
1958
+ if (files.length === 0) {
1959
+ resolve([]);
1960
+ return;
1961
+ }
1962
+ resolve(await Promise.all(files.map((file) => new Promise((res, rej) => {
1963
+ const itemType = file.type.startsWith("video/") ? "VIDEO" : "PHOTO";
1964
+ const reader = new FileReader();
1965
+ reader.onload = () => res({
1966
+ id: crypto.randomUUID(),
1967
+ dataUri: reader.result,
1968
+ type: itemType
1969
+ });
1970
+ reader.onerror = () => rej(/* @__PURE__ */ new Error("Failed to read file"));
1971
+ reader.readAsDataURL(file);
1972
+ }))));
1973
+ };
1974
+ const onFocus = () => {
1975
+ setTimeout(() => {
1976
+ if (!settled) resolve([]);
1977
+ window.removeEventListener("focus", onFocus);
1978
+ }, 300);
1979
+ };
1980
+ window.addEventListener("focus", onFocus);
1981
+ input.click();
1982
+ });
1983
+ }
1984
+ async function fetchAlbumItemsPrompt(maxCount) {
1985
+ return (await waitForPromptResponse("photos")).slice(0, maxCount).map((dataUri) => ({
1986
+ id: crypto.randomUUID(),
1987
+ dataUri,
1988
+ type: "PHOTO"
1989
+ }));
1990
+ }
1991
+ const _fetchAlbumItems = async (options) => {
1992
+ checkPermission("photos", "fetchAlbumItems");
1993
+ const maxCount = options?.maxCount ?? 10;
1994
+ const types = options?.types ?? ["PHOTO"];
1995
+ const mode = aitState.state.deviceModes.photos;
1996
+ if (mode === "web") return fetchAlbumItemsWeb(maxCount, types);
1997
+ if (mode === "prompt") return fetchAlbumItemsPrompt(maxCount);
1998
+ return fetchAlbumItemsMock(maxCount, types);
1999
+ };
2000
+ withPermission(_fetchAlbumItems, "photos");
1941
2001
  //#endregion
1942
2002
  //#region src/mock/device/clipboard.ts
1943
2003
  /**
@@ -4182,7 +4242,7 @@ function mount() {
4182
4242
  mockBadge.textContent = aitState.state.panelEditable ? t("panel.editMode.on") : t("panel.editMode.off");
4183
4243
  refreshPanel();
4184
4244
  });
4185
- const headerRight = h("span", { style: "display:flex;align-items:center;gap:6px" }, mockBadge, h("span", { style: "font-size:11px;color:#666;font-weight:400" }, `v0.1.29`), closeBtn);
4245
+ const headerRight = h("span", { style: "display:flex;align-items:center;gap:6px" }, mockBadge, h("span", { style: "font-size:11px;color:#666;font-weight:400" }, `v0.1.31`), closeBtn);
4186
4246
  const header = h("div", { className: "ait-panel-header" }, h("span", {}, t("panel.title")), headerRight);
4187
4247
  tabsEl = h("div", { className: "ait-panel-tabs" });
4188
4248
  for (const tab of getTabs()) {