Compare commits
6 commits
78c32ed043
...
205894a83c
Author | SHA1 | Date | |
---|---|---|---|
205894a83c | |||
3c07b12b74 | |||
d6655a3297 | |||
b1b7f0fe05 | |||
94a943c0dd | |||
6732b6a17e |
22 changed files with 178 additions and 117 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -12,4 +12,5 @@
|
|||
/base/secrets.yaml
|
||||
/trash
|
||||
/venv
|
||||
/.venv
|
||||
/.venv
|
||||
.python-version
|
||||
|
|
5
base/esp8266.template.yaml
Normal file
5
base/esp8266.template.yaml
Normal file
|
@ -0,0 +1,5 @@
|
|||
# Basic Config
|
||||
esphome:
|
||||
name: ${device_name}
|
||||
esp8266:
|
||||
board: esp01_1m
|
|
@ -1,11 +1,9 @@
|
|||
substitutions:
|
||||
friendly_name: Bistro Lights
|
||||
esphome:
|
||||
name: bistro-lights
|
||||
platform: ESP8266
|
||||
board: esp01_1m
|
||||
device_name: bistro-lights
|
||||
|
||||
packages:
|
||||
esphome: !include base/esp8266.template.yaml
|
||||
common: !include base/common.template.yaml
|
||||
|
||||
uart:
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
substitutions:
|
||||
friendly_name: Coffee Grinder
|
||||
|
||||
# Basic Config
|
||||
esphome:
|
||||
name: coffee-grinder
|
||||
platform: ESP8266
|
||||
board: esp01_1m
|
||||
device_name: coffee-grinder
|
||||
|
||||
packages:
|
||||
esphome: !include base/esp8266.template.yaml
|
||||
common: !include base/common.template.yaml
|
||||
|
||||
# Device Specific Config
|
||||
|
|
|
@ -2,13 +2,10 @@ substitutions:
|
|||
device_name: front_porch_light
|
||||
friendly_name: Front Porch Light
|
||||
icon: "mdi:light-switch"
|
||||
|
||||
esphome:
|
||||
name: front-porch-light
|
||||
platform: ESP8266
|
||||
board: esp01_1m
|
||||
device_name: front-porch-light
|
||||
|
||||
packages:
|
||||
esphome: !include base/esp8266.template.yaml
|
||||
common: !include base/common.template.yaml
|
||||
|
||||
output:
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
substitutions:
|
||||
substitutions:
|
||||
friendly_name: Holmes Tower
|
||||
esphome:
|
||||
name: holmes-fan
|
||||
platform: ESP8266
|
||||
board: d1_mini
|
||||
device_name: holmes-fan
|
||||
|
||||
packages:
|
||||
esphome: !include base/esp8266.template.yaml
|
||||
common: !include base/common.template.yaml
|
||||
|
||||
time:
|
||||
|
|
|
@ -4,6 +4,7 @@ substitutions:
|
|||
weather_entity: weather.pirateweather
|
||||
light_group_entity: light.bedroom_lights
|
||||
alarm_schedule_entity: schedule.alarm_clock
|
||||
media_title_entity: sensor.bedroom_speaker_playing
|
||||
packages:
|
||||
Nabu Casa.Home Assistant Voice PE: github://esphome/home-assistant-voice-pe/home-assistant-voice.yaml
|
||||
grove-i2c: github://esphome/home-assistant-voice-pe/modules/grove-i2c.yaml
|
||||
|
@ -21,10 +22,11 @@ wifi:
|
|||
|
||||
font:
|
||||
# - file: "gfonts://Share+Tech+Mono"
|
||||
- file: "BebasNeue-Regular.ttf"
|
||||
- file: "./fonts/BebasNeue-Regular.ttf"
|
||||
id: font_time
|
||||
size: 40
|
||||
- file: "gfonts://VT323"
|
||||
# - file: "gfonts://VT323"
|
||||
- file: "./fonts/BebasNeue-Regular.ttf"
|
||||
id: font_smaller
|
||||
size: 20
|
||||
extras:
|
||||
|
@ -97,24 +99,24 @@ graphical_display_menu:
|
|||
immediate_edit: true
|
||||
text: 'Weather'
|
||||
switch: show_weather
|
||||
- type: menu
|
||||
text: 'Wake Word'
|
||||
items:
|
||||
# - type: menu
|
||||
# text: 'Wake Word'
|
||||
# items:
|
||||
# - type: switch
|
||||
# immediate_edit: true
|
||||
# text: 'Enable MWW'
|
||||
# text: 'Wake Word'
|
||||
# switch: use_wake_word
|
||||
# - type: select
|
||||
# select: wake_word_set
|
||||
# text: Active Word
|
||||
# immediate_edit: true
|
||||
- type: switch
|
||||
immediate_edit: true
|
||||
text: !lambda |-
|
||||
return "\ue029 Tone";
|
||||
switch: wake_sound
|
||||
- type: back
|
||||
text: 'Back'
|
||||
# - type: back
|
||||
# text: 'Back'
|
||||
- type: switch
|
||||
immediate_edit: true
|
||||
text: !lambda |-
|
||||
return "\ue029 Tone";
|
||||
switch: wake_sound
|
||||
- type: command
|
||||
text: 'Exit'
|
||||
on_value:
|
||||
|
@ -126,6 +128,7 @@ switch:
|
|||
id: show_weather
|
||||
restore_mode: RESTORE_DEFAULT_OFF
|
||||
optimistic: true
|
||||
# Internal switch to track when a timer is ringing on the device.
|
||||
- platform: template
|
||||
id: alarm_ringing
|
||||
optimistic: true
|
||||
|
@ -134,35 +137,33 @@ switch:
|
|||
on_turn_off:
|
||||
# Disable stop wake word
|
||||
- lambda: id(stop).disable();
|
||||
# Stop any current annoucement (ie: stop the alarm ring mid playback)
|
||||
- script.execute: disable_repeat
|
||||
# Stop any current annoucement (ie: stop the timer ring mid playback)
|
||||
- if:
|
||||
condition:
|
||||
lambda: return id(nabu_media_player)->state == media_player::MediaPlayerState::MEDIA_PLAYER_STATE_ANNOUNCING;
|
||||
media_player.is_announcing:
|
||||
then:
|
||||
lambda: |-
|
||||
id(nabu_media_player)
|
||||
->make_call()
|
||||
.set_command(media_player::MediaPlayerCommand::MEDIA_PLAYER_COMMAND_STOP)
|
||||
.set_announcement(true)
|
||||
.perform();
|
||||
media_player.stop:
|
||||
announcement: true
|
||||
# Set back ducking ratio to zero
|
||||
- nabu.set_ducking:
|
||||
- mixer_speaker.apply_ducking:
|
||||
id: media_mixing_input
|
||||
decibel_reduction: 0
|
||||
duration: 1.0s
|
||||
# Refresh the LED ring
|
||||
- script.execute: control_leds
|
||||
on_turn_on:
|
||||
# Duck audio
|
||||
- nabu.set_ducking:
|
||||
- mixer_speaker.apply_ducking:
|
||||
id: media_mixing_input
|
||||
decibel_reduction: 20
|
||||
duration: 0.0s
|
||||
# Enable stop wake word
|
||||
- lambda: id(stop).enable();
|
||||
- media_player.volume_set: 50%
|
||||
# Ring alarm
|
||||
# Ring timer
|
||||
- script.execute: ring_alarm
|
||||
# Refresh LED
|
||||
- script.execute: control_leds_timer_ringing
|
||||
- script.execute: control_leds
|
||||
# If 15 minutes have passed and the timer is still ringing, stop it.
|
||||
- delay: 15min
|
||||
- switch.turn_off: alarm_ringing
|
||||
|
@ -196,39 +197,48 @@ display:
|
|||
- id: page_time
|
||||
lambda: |-
|
||||
// it.strftime(110, 0, id(font_time), TextAlign::TOP_RIGHT, ((id(the_time).now().second % 4 < 2) ? "%l:%M" : "%l %M"), id(the_time).now());
|
||||
it.strftime(110, 0, id(font_time), TextAlign::TOP_RIGHT, ((id(the_time).now().second % 4 < 2) ? "%l:%M" : "%l %M %P"), id(the_time).now());
|
||||
// it.strftime(110, 0, id(font_time), TextAlign::TOP_RIGHT, ((id(the_time).now().second % 4 < 2) ? "%l:%M %P" : "%l %M %P"), id(the_time).now());
|
||||
it.strftime(64, 0, id(font_time), TextAlign::TOP_CENTER, "%l:%M %P", id(the_time).now());
|
||||
// it.printf(it.get_width()-2, 36, id(font_smaller), TextAlign::BOTTOM_RIGHT, "%c", id(the_time).now().strftime("%P")[0]);
|
||||
if (id(show_weather).state) {
|
||||
std::map<std::string, std::string> weather_icon_map
|
||||
{
|
||||
{"clear-night", "\uef44"},
|
||||
{"cloudy", "\ue2bd"},
|
||||
{"exceptional", "\uf3cc"},
|
||||
{"fog", "\ue818"},
|
||||
{"hail", "\uf67f"},
|
||||
{"lightning", "\uea0b"},
|
||||
{"lightning-rainy", "\uebdb"},
|
||||
{"partlycloudy", "\uf172"},
|
||||
{"pouring", "\uf61f"},
|
||||
{"rainy", "\uf61e"},
|
||||
{"snowy", "\ue80f"},
|
||||
{"snowy-rainy", "\uf61d"},
|
||||
{"sunny", "\ue81a"},
|
||||
{"windy", "\uefd8"},
|
||||
{"windy-variant", "\ue29c"}
|
||||
};
|
||||
it.printf(0, 38, id(font_smaller),"%s%3.0f°", weather_icon_map[id(weather_condition).state.c_str()].c_str(), id(weather_temp).state);
|
||||
if (
|
||||
(id(external_media_player)->state == media_player::MediaPlayerState::MEDIA_PLAYER_STATE_PLAYING) &&
|
||||
(id(the_time).now().second % 20 < 10)
|
||||
) {
|
||||
it.print(0,40,id(font_smaller),id(media_info).state.c_str());
|
||||
}
|
||||
if (id(va).is_continuous()) {
|
||||
it.print(80, 40, id(font_smaller), "\ue029");
|
||||
} else if (id(va).is_running()) {
|
||||
it.print(80, 40, id(font_smaller), "\uf5d1");
|
||||
}
|
||||
if (!id(va).get_timers().empty()) {
|
||||
it.print(60, 40, id(font_smaller), "\ue425");
|
||||
}
|
||||
if (id(alarm_mode).active_index() > 0) {
|
||||
it.print(it.get_width()-2, it.get_height()-2, id(font_smaller), TextAlign::BOTTOM_RIGHT, (id(alarm_mode).active_index() == 2 ? "\ue7f4" : "\uf540"));
|
||||
else {
|
||||
if (id(show_weather).state) {
|
||||
std::map<std::string, std::string> weather_icon_map
|
||||
{
|
||||
{"clear-night", "\uef44"},
|
||||
{"cloudy", "\ue2bd"},
|
||||
{"exceptional", "\uf3cc"},
|
||||
{"fog", "\ue818"},
|
||||
{"hail", "\uf67f"},
|
||||
{"lightning", "\uea0b"},
|
||||
{"lightning-rainy", "\uebdb"},
|
||||
{"partlycloudy", "\uf172"},
|
||||
{"pouring", "\uf61f"},
|
||||
{"rainy", "\uf61e"},
|
||||
{"snowy", "\ue80f"},
|
||||
{"snowy-rainy", "\uf61d"},
|
||||
{"sunny", "\ue81a"},
|
||||
{"windy", "\uefd8"},
|
||||
{"windy-variant", "\ue29c"}
|
||||
};
|
||||
it.printf(0, 38, id(font_smaller),"%s%3.0f°", weather_icon_map[id(weather_condition).state.c_str()].c_str(), id(weather_temp).state);
|
||||
}
|
||||
if (id(va).is_continuous()) {
|
||||
it.print(80, 40, id(font_smaller), "\ue029");
|
||||
} else if (id(va).is_running()) {
|
||||
it.print(80, 40, id(font_smaller), "\uf5d1");
|
||||
}
|
||||
if (!id(va).get_timers().empty()) {
|
||||
it.print(60, 40, id(font_smaller), "\ue425");
|
||||
}
|
||||
if (id(alarm_mode).active_index() > 0) {
|
||||
it.print(it.get_width()-2, it.get_height()-2, id(font_smaller), TextAlign::BOTTOM_RIGHT, (id(alarm_mode).active_index() == 2 ? "\ue7f4" : "\uf540"));
|
||||
}
|
||||
}
|
||||
- id: page_timer
|
||||
lambda: |-
|
||||
|
@ -253,6 +263,9 @@ text_sensor:
|
|||
- platform: homeassistant
|
||||
id: weather_condition
|
||||
entity_id: ${weather_entity}
|
||||
- platform: homeassistant
|
||||
id: media_info
|
||||
entity_id: ${media_title_entity}
|
||||
|
||||
sensor:
|
||||
- platform: homeassistant
|
||||
|
@ -387,10 +400,10 @@ binary_sensor:
|
|||
else:
|
||||
- if:
|
||||
condition:
|
||||
lambda: return id(nabu_media_player)->state == media_player::MediaPlayerState::MEDIA_PLAYER_STATE_ANNOUNCING;
|
||||
lambda: return id(external_media_player)->state == media_player::MediaPlayerState::MEDIA_PLAYER_STATE_ANNOUNCING;
|
||||
then:
|
||||
- lambda: |
|
||||
id(nabu_media_player)
|
||||
id(external_media_player)
|
||||
->make_call()
|
||||
.set_command(media_player::MediaPlayerCommand::MEDIA_PLAYER_COMMAND_STOP)
|
||||
.set_announcement(true)
|
||||
|
@ -460,6 +473,13 @@ binary_sensor:
|
|||
condition:
|
||||
lambda: return !id(init_in_progress) && !id(color_changed);
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
display_menu.is_active:
|
||||
then:
|
||||
- display_menu.hide:
|
||||
else:
|
||||
- display_menu.show_main:
|
||||
- script.execute:
|
||||
id: play_sound
|
||||
priority: false
|
||||
|
@ -467,6 +487,7 @@ binary_sensor:
|
|||
- event.trigger:
|
||||
id: button_press_event
|
||||
event_type: "triple_press"
|
||||
|
||||
# Long Press
|
||||
# . Exposed as an event entity. To be used in automations inside Home Assistant
|
||||
- timing:
|
||||
|
@ -484,16 +505,6 @@ binary_sensor:
|
|||
- event.trigger:
|
||||
id: button_press_event
|
||||
event_type: "long_press"
|
||||
- timing:
|
||||
- ON for 2s to 4s
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
display_menu.is_active:
|
||||
then:
|
||||
- display_menu.hide:
|
||||
else:
|
||||
- display_menu.show_main:
|
||||
# Very important do not remove. Trust me :D
|
||||
- timing:
|
||||
# H ....
|
||||
|
@ -614,11 +625,11 @@ script:
|
|||
sound_file: !lambda return id(alarm_glockenspiel);
|
||||
- wait_until:
|
||||
lambda: |-
|
||||
return id(nabu_media_player)->state == media_player::MediaPlayerState::MEDIA_PLAYER_STATE_ANNOUNCING;
|
||||
return id(external_media_player)->state == media_player::MediaPlayerState::MEDIA_PLAYER_STATE_ANNOUNCING;
|
||||
- wait_until:
|
||||
not:
|
||||
lambda: |-
|
||||
return id(nabu_media_player)->state == media_player::MediaPlayerState::MEDIA_PLAYER_STATE_ANNOUNCING;
|
||||
return id(external_media_player)->state == media_player::MediaPlayerState::MEDIA_PLAYER_STATE_ANNOUNCING;
|
||||
# - id: set_alarm_time
|
||||
# then:
|
||||
# - datetime.time.set:
|
||||
|
@ -717,7 +728,7 @@ select:
|
|||
# - lambda: !lambda id(va).set_wake_word(x);
|
||||
|
||||
media_player:
|
||||
- id: !extend nabu_media_player
|
||||
- id: !extend external_media_player
|
||||
files:
|
||||
- id: alarm_glockenspiel
|
||||
file: ./inc/glockenspiel.wav
|
||||
file: ./sounds/glockenspiel.flac
|
Binary file not shown.
|
@ -1,5 +1,6 @@
|
|||
substitutions:
|
||||
friendly_name: Merkury Light Strip
|
||||
device_name: kitchen-strip
|
||||
wifi:
|
||||
use_address: kitchen-counter.local
|
||||
|
||||
|
@ -8,11 +9,10 @@ ota:
|
|||
password: !secret kitchen_counter_ota
|
||||
|
||||
packages:
|
||||
esphome: !include base/esp8266.template.yaml
|
||||
common: !include base/common.template.yaml
|
||||
|
||||
esphome:
|
||||
name: merkury-strip
|
||||
platform: ESP8266
|
||||
board: esp8285
|
||||
on_boot:
|
||||
- lambda: |-
|
||||
id(my_ota).set_auth_password("");
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
esphome:
|
||||
name: minidisplay
|
||||
|
||||
esp8266:
|
||||
board: esp12e
|
||||
|
||||
substitutions:
|
||||
device_name: minidisplay
|
||||
friendly_name: Mini Display
|
||||
|
||||
packages:
|
||||
esphome: !include base/esp8266.template.yaml
|
||||
common: !include base/common.template.yaml
|
||||
|
||||
time:
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
substitutions:
|
||||
friendly_name: Outside Plug
|
||||
esphome:
|
||||
name: outside-plug
|
||||
platform: ESP8266
|
||||
board: esp8285
|
||||
device_name: outside-plug
|
||||
|
||||
packages:
|
||||
esphome: !include base/esp8266.template.yaml
|
||||
common: !include base/common.template.yaml
|
||||
|
||||
switch:
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
esphome:
|
||||
name: prism-light
|
||||
platform: ESP8266
|
||||
board: esp01_1m
|
||||
substitutions:
|
||||
friendly_name: Prism
|
||||
device_name: prism-light
|
||||
|
||||
packages:
|
||||
esphome: !include base/esp8266.template.yaml
|
||||
common: !include base/common.template.yaml
|
||||
|
||||
api:
|
||||
|
@ -128,10 +128,14 @@ select:
|
|||
- Vortex
|
||||
- Sunset
|
||||
- Frigid
|
||||
# - MLM Long
|
||||
- MLM
|
||||
set_action:
|
||||
- lambda: |-
|
||||
if (x == "Hyperion") id(set_pattern)->execute("10320003001c03e803e800000000012c03c003e80000000000c703e803e800000000");
|
||||
if (x == "Hypnotize") id(set_pattern)->execute("083c0001000003e803e800000000001e03e803e800000000003c03e803e800000000007803e803e80000000000b403e803e80000000000f003e803e800000000010e03e803e800000000012c03e803e800000000");
|
||||
if (x == "Vortex") id(set_pattern)->execute("09640008000003e803e800000000001e03e803e800000000003c03e803e800000000007803e803e80000000000b403e803e80000000000f003e803e800000000010e03e803e800000000012c03e803e800000000");
|
||||
if (x == "Sunset") id(set_pattern)->execute("0b280002000003e803e800000000000003e803e800000000001e03e803e800000000001e03e803e800000000003c03e803e800000000003c03e803e800000000");
|
||||
if (x == "Frigid") id(set_pattern)->execute("0c28000100b403e803e80000000000f003e803e800000000010e03e803e8000000000000000003e800000000");
|
||||
if (x == "Frigid") id(set_pattern)->execute("0c28000100b403e803e80000000000f003e803e800000000010e03e803e8000000000000000003e800000000");
|
||||
// if (x == "MLM Long") id(set_pattern)->execute("0d34000200a703b602280000000000a7032f03270000000000960158038d000000000000000003e80000000000d201c703760000000000f302820320000000000106030f01d600000000");
|
||||
if (x == "MLM") id(set_pattern)->execute("0d10000200a703b602280000000000a703b602280000000000960158038d0000000000960158038d000000000000000003e80000000000d201c703760000000000d201c70376000000000106030f01d6000000000106030f01d600000000");
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
substitutions:
|
||||
friendly_name: Robovac 35C
|
||||
device_name: robovac
|
||||
esphome:
|
||||
name: ${device_name}
|
||||
|
||||
esp8266:
|
||||
board: esp01_1m
|
||||
|
||||
packages:
|
||||
esphome: !include base/esp8266.template.yaml
|
||||
common: !include base/common.template.yaml
|
||||
|
||||
wifi:
|
||||
|
|
BIN
sounds/glockenspiel.flac
Normal file
BIN
sounds/glockenspiel.flac
Normal file
Binary file not shown.
0
inc/style.min.css → static/style.min.css
vendored
0
inc/style.min.css → static/style.min.css
vendored
59
tuyacolor/index.html
Normal file
59
tuyacolor/index.html
Normal file
|
@ -0,0 +1,59 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Tuya Color Patterns</title>
|
||||
<script type="text/javascript" src="./van.nomodule.min.js" />
|
||||
<script type="text/javascript" src="./van-x.nomodule.min.js" />
|
||||
<script type="text/javascript">
|
||||
function hex2tuya(hex) {
|
||||
hex = hex.replace(/^#/,'');
|
||||
const r = parseInt(hex.substring(0,2),16);
|
||||
const g = parseInt(hex.substring(2,4),16);
|
||||
const b = parseInt(hex.substring(4,6),16);
|
||||
const hsv = rgb2hsv(r,g,b);
|
||||
const h = Math.round(hsv.h).toString(16).padStart(4,"0");
|
||||
const s = Math.round(hsv.s*10).toString(16).padStart(4,"0");
|
||||
const v = Math.round(hsv.v*10).toString(16).padStart(4,"0");
|
||||
const tuyastr = h+s+v+"00000000";
|
||||
return tuyastr;
|
||||
}
|
||||
|
||||
function rgb2hsv (r, g, b) {
|
||||
// Sourced from https://stackoverflow.com/a/8023734
|
||||
let rabs, gabs, babs, rr, gg, bb, h, s, v, diff, diffc, percentRoundFn;
|
||||
rabs = r / 255;
|
||||
gabs = g / 255;
|
||||
babs = b / 255;
|
||||
v = Math.max(rabs, gabs, babs),
|
||||
diff = v - Math.min(rabs, gabs, babs);
|
||||
diffc = c => (v - c) / 6 / diff + 1 / 2;
|
||||
percentRoundFn = num => Math.round(num * 100) / 100;
|
||||
if (diff == 0) {
|
||||
h = s = 0;
|
||||
} else {
|
||||
s = diff / v;
|
||||
rr = diffc(rabs);
|
||||
gg = diffc(gabs);
|
||||
bb = diffc(babs);
|
||||
|
||||
if (rabs === v) {
|
||||
h = bb - gg;
|
||||
} else if (gabs === v) {
|
||||
h = (1 / 3) + rr - bb;
|
||||
} else if (babs === v) {
|
||||
h = (2 / 3) + gg - rr;
|
||||
}
|
||||
if (h < 0) {
|
||||
h += 1;
|
||||
}else if (h > 1) {
|
||||
h -= 1;
|
||||
}
|
||||
}
|
||||
return {
|
||||
h: Math.round(h * 360),
|
||||
s: percentRoundFn(s * 100),
|
||||
v: percentRoundFn(v * 100)
|
||||
};
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
</html>
|
1
tuyacolor/van-x.nomodule.min.js
vendored
Normal file
1
tuyacolor/van-x.nomodule.min.js
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{let e,t,r,{fromEntries:o,entries:l,keys:n,hasOwn:f,getPrototypeOf:a}=Object,{get:i,set:y,deleteProperty:c,ownKeys:s}=Reflect,{state:m,derive:d,add:u}=van,b=1e3,w=Symbol(),A=Symbol(),S=Symbol(),_=Symbol(),g=Symbol(),p=Symbol(),P=e=>(e[A]=1,e),v=e=>e instanceof Object&&!(e instanceof Function)&&!e[p],h=e=>{if(e?.[A]){let t=m();return d(()=>{let r=e();v(t.rawVal)&&v(r)?B(t.rawVal,r):t.val=x(r)}),t}return m(x(e))},F=e=>{let t=Array.isArray(e)?[]:{__proto__:a(e)};for(let[r,o]of l(e))t[r]=h(o);return t[S]=[],t[_]=m(1),t},O={get:(e,t,r)=>t===w?e:f(e,t)?Array.isArray(e)&&"length"===t?(e[_].val,e.length):e[t].val:i(e,t,r),set:(e,o,l,n)=>f(e,o)?Array.isArray(e)&&"length"===o?(l!==e.length&&++e[_].val,e.length=l,1):(e[o].val=x(l),1):o in e?y(e,o,l,n):y(e,o,h(l))&&(++e[_].val,C(e).forEach(E.bind(t,n,o,e[o],r)),1),deleteProperty:(e,t)=>(c(e,t)&&R(e,t),++e[_].val),ownKeys:e=>(e[_].val,s(e))},x=e=>!v(e)||e[w]?e:new Proxy(F(e),O),D=e=>(e[p]=1,e),j=e=>e[w],K=a(m()),N=e=>new Proxy(e,{get:(e,t,r)=>a(e[t]??0)===K?{val:k(e[t].rawVal)}:i(e,t,r)}),k=e=>e?.[w]?new Proxy(N(e[w]),O):e,C=e=>e[S]=e[S].filter(e=>e.t.isConnected),E=(e,t,r,o,{t:l,f:f})=>{let a=Array.isArray(e),i=a?Number(t):t;u(l,()=>l[g][t]=f(r,()=>delete e[t],i)),a&&!o&&i!==e.length-1&&l.insertBefore(l.lastChild,l[g][n(e).find(e=>Number(e)>i)])},R=(e,t)=>{for(let r of C(e)){let e=r.t[g];e[t]?.remove(),delete e[t]}},T=r=>(e??(setTimeout(()=>(e.forEach(C),e=t),b),e=new Set)).add(r),q=(e,t,r)=>{let o={t:e instanceof Function?e():e,f:r},n=t[w];o.t[g]={},n[S].push(o),T(n);for(let[e,r]of l(n))E(t,e,r,1,o);return o.t},z=(e,t)=>{for(let[r,o]of l(t)){let t=e[r];v(t)&&v(o)?z(t,o):e[r]=o}for(let r in e)f(t,r)||delete e[r];let r=n(t),o=Array.isArray(e);if(o||n(e).some((e,t)=>e!==r[t])){let l=e[w];if(o)e.length=t.length;else{++l[_].val;let e={...l};for(let e of r)delete l[e];for(let t of r)l[t]=e[t]}for(let{t:e}of C(l)){let{firstChild:t,[g]:o}=e;for(let l of r)t===o[l]?t=t.nextSibling:e.insertBefore(o[l],t)}}return e},B=(e,n)=>{r=1;try{return z(e,n instanceof Function?Array.isArray(e)?n(e.filter(e=>1)):o(n(l(e))):n)}finally{r=t}},G=e=>Array.isArray(e)?e.filter(e=>1).map(G):v(e)?o(l(e).map(([e,t])=>[e,G(t)])):e;window.vanX={calc:P,reactive:x,noreactive:D,stateFields:j,raw:k,list:q,replace:B,compact:G}}
|
1
tuyacolor/van.nomodule.min.js
vendored
Normal file
1
tuyacolor/van.nomodule.min.js
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{let e,t,r,o,n,l,s,i,f,h,w,a,d,u,_,c,S,g,y,b,m,v,j,x,O;s=Object.getPrototypeOf,f={},h=s(i={isConnected:1}),w=s(s),a=(e,t,r,o)=>(e??(setTimeout(r,o),new Set)).add(t),d=(e,t,o)=>{let n=r;r=t;try{return e(o)}catch(e){return console.error(e),o}finally{r=n}},u=e=>e.filter(e=>e.t?.isConnected),_=e=>n=a(n,e,()=>{for(let e of n)e.o=u(e.o),e.l=u(e.l);n=l},1e3),c={get val(){return r?.i?.add(this),this.rawVal},get oldVal(){return r?.i?.add(this),this.h},set val(o){r?.u?.add(this),o!==this.rawVal&&(this.rawVal=o,this.o.length+this.l.length?(t?.add(this),e=a(e,this,x)):this.h=o)}},S=e=>({__proto__:c,rawVal:e,h:e,o:[],l:[]}),g=(e,t)=>{let r={i:new Set,u:new Set},n={f:e},l=o;o=[];let s=d(e,r,t);s=(s??document).nodeType?s:new Text(s);for(let e of r.i)r.u.has(e)||(_(e),e.o.push(n));for(let e of o)e.t=s;return o=l,n.t=s},y=(e,t=S(),r)=>{let n={i:new Set,u:new Set},l={f:e,s:t};l.t=r??o?.push(l)??i,t.val=d(e,n,t.rawVal);for(let e of n.i)n.u.has(e)||(_(e),e.l.push(l));return t},b=(e,...t)=>{for(let r of t.flat(1/0)){let t=s(r??0),o=t===c?g(()=>r.val):t===w?g(r):r;o!=l&&e.append(o)}return e},m=(e,t,...r)=>{let[{is:o,...n},...i]=s(r[0]??0)===h?r:[{},...r],a=e?document.createElementNS(e,t,{is:o}):document.createElement(t,{is:o});for(let[e,r]of Object.entries(n)){let o=t=>t?Object.getOwnPropertyDescriptor(t,e)??o(s(t)):l,n=t+","+e,i=f[n]??=o(s(a))?.set??0,h=e.startsWith("on")?(t,r)=>{let o=e.slice(2);a.removeEventListener(o,r),a.addEventListener(o,t)}:i?i.bind(a):a.setAttribute.bind(a,e),d=s(r??0);e.startsWith("on")||d===w&&(r=y(r),d=c),d===c?g(()=>(h(r.val,r.h),a)):h(r)}return b(a,i)},v=e=>({get:(t,r)=>m.bind(l,e,r)}),j=(e,t)=>t?t!==e&&e.replaceWith(t):e.remove(),x=()=>{let r=0,o=[...e].filter(e=>e.rawVal!==e.h);do{t=new Set;for(let e of new Set(o.flatMap(e=>e.l=u(e.l))))y(e.f,e.s,e.t),e.t=l}while(++r<100&&(o=[...t]).length);let n=[...e].filter(e=>e.rawVal!==e.h);e=l;for(let e of new Set(n.flatMap(e=>e.o=u(e.o))))j(e.t,g(e.f,e.t)),e.t=l;for(let e of n)e.h=e.rawVal},O={tags:new Proxy(e=>new Proxy(m,v(e)),v()),hydrate:(e,t)=>j(e,g(t,e)),add:b,state:S,derive:y},window.van=O;}
|
Loading…
Add table
Add a link
Reference in a new issue