shadergradient
Advanced tools
Comparing version 0.3.18 to 0.3.19
// src/Gradient/comps/GradientMesh/shaders/defaults/plane/fragment.glsl | ||
var fragment_default = "\n#define STANDARD\n#ifdef PHYSICAL\n#define REFLECTIVITY\n#define CLEARCOAT\n#define TRANSMISSION\n#endif\nuniform vec3 diffuse;uniform vec3 emissive;uniform float roughness;uniform float metalness;uniform float opacity;\n#ifdef TRANSMISSION\nuniform float transmission;\n#endif\n#ifdef REFLECTIVITY\nuniform float reflectivity;\n#endif\n#ifdef CLEARCOAT\nuniform float clearcoat;uniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\nuniform vec3 sheen;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n#ifdef USE_TANGENT\nvarying vec3 vTangent;varying vec3 vBitangent;\n#endif\n#endif\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <color_pars_fragment>\n#include <common>\n#include <dithering_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <map_pars_fragment>\n#include <packing>\n#include <uv2_pars_fragment>\n#include <uv_pars_fragment>\n#include <bsdfs>\n#include <bumpmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <clipping_planes_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <lights_physical_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <shadowmap_pars_fragment>\nvarying vec3 vNormal;varying float displacement;varying vec3 vPos;varying float vDistort;uniform float uC1r;uniform float uC1g;uniform float uC1b;uniform float uC2r;uniform float uC2g;uniform float uC2b;uniform float uC3r;uniform float uC3g;uniform float uC3b;varying vec3 color1;varying vec3 color2;varying vec3 color3;void main(){vec3 color1=vec3(uC1r,uC1g,uC1b);vec3 color2=vec3(uC2r,uC2g,uC2b);vec3 color3=vec3(uC3r,uC3g,uC3b);float clearcoat=1.0;float clearcoatRoughness=0.5;\n#include <clipping_planes_fragment>\nvec4 diffuseColor=vec4(mix(mix(color1,color2,smoothstep(-3.0,3.0,vPos.x)),color3,vPos.z),1);ReflectedLight reflectedLight=ReflectedLight(vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0));vec3 totalEmissiveRadiance=emissive;\n#ifdef TRANSMISSION\nfloat totalTransmission=transmission;\n#endif\n#include <logdepthbuf_fragment>\n#include <map_fragment>\n#include <color_fragment>\n#include <alphamap_fragment>\n#include <alphatest_fragment>\n#include <roughnessmap_fragment>\n#include <metalnessmap_fragment>\n#include <normal_fragment_begin>\n#include <normal_fragment_maps>\n#include <clearcoat_normal_fragment_begin>\n#include <clearcoat_normal_fragment_maps>\n#include <emissivemap_fragment>\n#include <lights_physical_fragment>\n#include <lights_fragment_begin>\n#include <lights_fragment_maps>\n#include <lights_fragment_end>\n#include <aomap_fragment>\nvec3 outgoingLight=reflectedLight.directDiffuse+reflectedLight.indirectDiffuse+reflectedLight.directSpecular+reflectedLight.indirectSpecular;\n#ifdef TRANSMISSION\ndiffuseColor.a*=mix(saturate(1.-totalTransmission+linearToRelativeLuminance(reflectedLight.directSpecular+reflectedLight.indirectSpecular)),1.0,metalness);\n#endif\n#include <tonemapping_fragment>\n#include <encodings_fragment>\n#include <fog_fragment>\n#include <premultiplied_alpha_fragment>\n#include <dithering_fragment>\ngl_FragColor=vec4(outgoingLight,diffuseColor.a);}"; | ||
var fragment_default = "\n#define STANDARD\n#ifdef PHYSICAL\n#define REFLECTIVITY\n#define CLEARCOAT\n#define TRANSMISSION\n#endif\nuniform vec3 diffuse;uniform vec3 emissive;uniform float roughness;uniform float metalness;uniform float opacity;\n#ifdef TRANSMISSION\nuniform float transmission;\n#endif\n#ifdef REFLECTIVITY\nuniform float reflectivity;\n#endif\n#ifdef CLEARCOAT\nuniform float clearcoat;uniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\nuniform vec3 sheen;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n#ifdef USE_TANGENT\nvarying vec3 vTangent;varying vec3 vBitangent;\n#endif\n#endif\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <color_pars_fragment>\n#include <common>\n#include <dithering_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <map_pars_fragment>\n#include <packing>\n#include <uv2_pars_fragment>\n#include <uv_pars_fragment>\n#include <bsdfs>\n#include <bumpmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <clipping_planes_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <lights_physical_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <shadowmap_pars_fragment>\nvarying vec3 vNormal;varying float displacement;varying vec3 vPos;varying float vDistort;uniform float uC1r;uniform float uC1g;uniform float uC1b;uniform float uC2r;uniform float uC2g;uniform float uC2b;uniform float uC3r;uniform float uC3g;uniform float uC3b;varying vec3 color1;varying vec3 color2;varying vec3 color3;float linearToRelativeLuminance2(const in vec3 color){vec3 weights=vec3(0.2126,0.7152,0.0722);return dot(weights,color.rgb);}void main(){vec3 color1=vec3(uC1r,uC1g,uC1b);vec3 color2=vec3(uC2r,uC2g,uC2b);vec3 color3=vec3(uC3r,uC3g,uC3b);float clearcoat=1.0;float clearcoatRoughness=0.5;\n#include <clipping_planes_fragment>\nvec4 diffuseColor=vec4(mix(mix(color1,color2,smoothstep(-3.0,3.0,vPos.x)),color3,vPos.z),1);ReflectedLight reflectedLight=ReflectedLight(vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0));vec3 totalEmissiveRadiance=emissive;\n#ifdef TRANSMISSION\nfloat totalTransmission=transmission;\n#endif\n#include <logdepthbuf_fragment>\n#include <map_fragment>\n#include <color_fragment>\n#include <alphamap_fragment>\n#include <alphatest_fragment>\n#include <roughnessmap_fragment>\n#include <metalnessmap_fragment>\n#include <normal_fragment_begin>\n#include <normal_fragment_maps>\n#include <clearcoat_normal_fragment_begin>\n#include <clearcoat_normal_fragment_maps>\n#include <emissivemap_fragment>\n#include <lights_physical_fragment>\n#include <lights_fragment_begin>\n#include <lights_fragment_maps>\n#include <lights_fragment_end>\n#include <aomap_fragment>\nvec3 outgoingLight=reflectedLight.directDiffuse+reflectedLight.indirectDiffuse+reflectedLight.directSpecular+reflectedLight.indirectSpecular;\n#ifdef TRANSMISSION\ndiffuseColor.a*=mix(saturate(1.-totalTransmission+linearToRelativeLuminance2(reflectedLight.directSpecular+reflectedLight.indirectSpecular)),1.0,metalness);\n#endif\n#include <tonemapping_fragment>\n#include <encodings_fragment>\n#include <fog_fragment>\n#include <premultiplied_alpha_fragment>\n#include <dithering_fragment>\ngl_FragColor=vec4(outgoingLight,diffuseColor.a);}"; | ||
@@ -4,0 +4,0 @@ // src/Gradient/comps/GradientMesh/shaders/defaults/plane/vertex.glsl |
@@ -31,5 +31,3 @@ var __defProp = Object.defineProperty; | ||
// src/Gradient/LCanvas.tsx | ||
import React from "react"; | ||
import { canvasProps } from "../consts.js"; | ||
import { useQueryState } from "../hooks/index.js"; | ||
import React, { useState } from "react"; | ||
import { FiberContextProvider } from "../utils/index.js"; | ||
@@ -46,9 +44,7 @@ function LCanvas(_a) { | ||
const { Canvas } = importedFiber; | ||
const [pixelDensity] = useQueryState("pixelDensity"); | ||
const [fov] = useQueryState("fov"); | ||
return /* @__PURE__ */ React.createElement(Canvas, __spreadValues(__spreadValues({ | ||
const [hey, setHey] = useState(1); | ||
return /* @__PURE__ */ React.createElement(Canvas, __spreadValues({ | ||
id: "gradientCanvas", | ||
key: fov, | ||
resize: { offsetSize: true } | ||
}, canvasProps(pixelDensity, fov)), rest), /* @__PURE__ */ React.createElement(FiberContextProvider, { | ||
}, rest), /* @__PURE__ */ React.createElement(FiberContextProvider, { | ||
value: importedFiber | ||
@@ -55,0 +51,0 @@ }, children)); |
@@ -1,527 +0,7 @@ | ||
var __create = Object.create; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __commonJS = (cb, mod) => function __require() { | ||
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; | ||
}; | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return to; | ||
}; | ||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod)); | ||
// ../../node_modules/strict-uri-encode/index.js | ||
var require_strict_uri_encode = __commonJS({ | ||
"../../node_modules/strict-uri-encode/index.js"(exports, module) { | ||
"use strict"; | ||
module.exports = (str) => encodeURIComponent(str).replace(/[!'()*]/g, (x) => `%${x.charCodeAt(0).toString(16).toUpperCase()}`); | ||
} | ||
}); | ||
// ../../node_modules/decode-uri-component/index.js | ||
var require_decode_uri_component = __commonJS({ | ||
"../../node_modules/decode-uri-component/index.js"(exports, module) { | ||
"use strict"; | ||
var token = "%[a-f0-9]{2}"; | ||
var singleMatcher = new RegExp(token, "gi"); | ||
var multiMatcher = new RegExp("(" + token + ")+", "gi"); | ||
function decodeComponents(components, split) { | ||
try { | ||
return decodeURIComponent(components.join("")); | ||
} catch (err) { | ||
} | ||
if (components.length === 1) { | ||
return components; | ||
} | ||
split = split || 1; | ||
var left = components.slice(0, split); | ||
var right = components.slice(split); | ||
return Array.prototype.concat.call([], decodeComponents(left), decodeComponents(right)); | ||
} | ||
function decode(input) { | ||
try { | ||
return decodeURIComponent(input); | ||
} catch (err) { | ||
var tokens = input.match(singleMatcher); | ||
for (var i = 1; i < tokens.length; i++) { | ||
input = decodeComponents(tokens, i).join(""); | ||
tokens = input.match(singleMatcher); | ||
} | ||
return input; | ||
} | ||
} | ||
function customDecodeURIComponent(input) { | ||
var replaceMap = { | ||
"%FE%FF": "\uFFFD\uFFFD", | ||
"%FF%FE": "\uFFFD\uFFFD" | ||
}; | ||
var match = multiMatcher.exec(input); | ||
while (match) { | ||
try { | ||
replaceMap[match[0]] = decodeURIComponent(match[0]); | ||
} catch (err) { | ||
var result = decode(match[0]); | ||
if (result !== match[0]) { | ||
replaceMap[match[0]] = result; | ||
} | ||
} | ||
match = multiMatcher.exec(input); | ||
} | ||
replaceMap["%C2"] = "\uFFFD"; | ||
var entries = Object.keys(replaceMap); | ||
for (var i = 0; i < entries.length; i++) { | ||
var key = entries[i]; | ||
input = input.replace(new RegExp(key, "g"), replaceMap[key]); | ||
} | ||
return input; | ||
} | ||
module.exports = function(encodedURI) { | ||
if (typeof encodedURI !== "string") { | ||
throw new TypeError("Expected `encodedURI` to be of type `string`, got `" + typeof encodedURI + "`"); | ||
} | ||
try { | ||
encodedURI = encodedURI.replace(/\+/g, " "); | ||
return decodeURIComponent(encodedURI); | ||
} catch (err) { | ||
return customDecodeURIComponent(encodedURI); | ||
} | ||
}; | ||
} | ||
}); | ||
// ../../node_modules/split-on-first/index.js | ||
var require_split_on_first = __commonJS({ | ||
"../../node_modules/split-on-first/index.js"(exports, module) { | ||
"use strict"; | ||
module.exports = (string, separator) => { | ||
if (!(typeof string === "string" && typeof separator === "string")) { | ||
throw new TypeError("Expected the arguments to be of type `string`"); | ||
} | ||
if (separator === "") { | ||
return [string]; | ||
} | ||
const separatorIndex = string.indexOf(separator); | ||
if (separatorIndex === -1) { | ||
return [string]; | ||
} | ||
return [ | ||
string.slice(0, separatorIndex), | ||
string.slice(separatorIndex + separator.length) | ||
]; | ||
}; | ||
} | ||
}); | ||
// ../../node_modules/filter-obj/index.js | ||
var require_filter_obj = __commonJS({ | ||
"../../node_modules/filter-obj/index.js"(exports, module) { | ||
"use strict"; | ||
module.exports = function(obj, predicate) { | ||
var ret = {}; | ||
var keys = Object.keys(obj); | ||
var isArr = Array.isArray(predicate); | ||
for (var i = 0; i < keys.length; i++) { | ||
var key = keys[i]; | ||
var val = obj[key]; | ||
if (isArr ? predicate.indexOf(key) !== -1 : predicate(key, val, obj)) { | ||
ret[key] = val; | ||
} | ||
} | ||
return ret; | ||
}; | ||
} | ||
}); | ||
// ../../node_modules/query-string/index.js | ||
var require_query_string = __commonJS({ | ||
"../../node_modules/query-string/index.js"(exports) { | ||
"use strict"; | ||
var strictUriEncode = require_strict_uri_encode(); | ||
var decodeComponent = require_decode_uri_component(); | ||
var splitOnFirst = require_split_on_first(); | ||
var filterObject = require_filter_obj(); | ||
var isNullOrUndefined = (value) => value === null || value === void 0; | ||
var encodeFragmentIdentifier = Symbol("encodeFragmentIdentifier"); | ||
function encoderForArrayFormat(options) { | ||
switch (options.arrayFormat) { | ||
case "index": | ||
return (key) => (result, value) => { | ||
const index = result.length; | ||
if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { | ||
return result; | ||
} | ||
if (value === null) { | ||
return [...result, [encode(key, options), "[", index, "]"].join("")]; | ||
} | ||
return [ | ||
...result, | ||
[encode(key, options), "[", encode(index, options), "]=", encode(value, options)].join("") | ||
]; | ||
}; | ||
case "bracket": | ||
return (key) => (result, value) => { | ||
if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { | ||
return result; | ||
} | ||
if (value === null) { | ||
return [...result, [encode(key, options), "[]"].join("")]; | ||
} | ||
return [...result, [encode(key, options), "[]=", encode(value, options)].join("")]; | ||
}; | ||
case "colon-list-separator": | ||
return (key) => (result, value) => { | ||
if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { | ||
return result; | ||
} | ||
if (value === null) { | ||
return [...result, [encode(key, options), ":list="].join("")]; | ||
} | ||
return [...result, [encode(key, options), ":list=", encode(value, options)].join("")]; | ||
}; | ||
case "comma": | ||
case "separator": | ||
case "bracket-separator": { | ||
const keyValueSep = options.arrayFormat === "bracket-separator" ? "[]=" : "="; | ||
return (key) => (result, value) => { | ||
if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { | ||
return result; | ||
} | ||
value = value === null ? "" : value; | ||
if (result.length === 0) { | ||
return [[encode(key, options), keyValueSep, encode(value, options)].join("")]; | ||
} | ||
return [[result, encode(value, options)].join(options.arrayFormatSeparator)]; | ||
}; | ||
} | ||
default: | ||
return (key) => (result, value) => { | ||
if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") { | ||
return result; | ||
} | ||
if (value === null) { | ||
return [...result, encode(key, options)]; | ||
} | ||
return [...result, [encode(key, options), "=", encode(value, options)].join("")]; | ||
}; | ||
} | ||
} | ||
function parserForArrayFormat(options) { | ||
let result; | ||
switch (options.arrayFormat) { | ||
case "index": | ||
return (key, value, accumulator) => { | ||
result = /\[(\d*)\]$/.exec(key); | ||
key = key.replace(/\[\d*\]$/, ""); | ||
if (!result) { | ||
accumulator[key] = value; | ||
return; | ||
} | ||
if (accumulator[key] === void 0) { | ||
accumulator[key] = {}; | ||
} | ||
accumulator[key][result[1]] = value; | ||
}; | ||
case "bracket": | ||
return (key, value, accumulator) => { | ||
result = /(\[\])$/.exec(key); | ||
key = key.replace(/\[\]$/, ""); | ||
if (!result) { | ||
accumulator[key] = value; | ||
return; | ||
} | ||
if (accumulator[key] === void 0) { | ||
accumulator[key] = [value]; | ||
return; | ||
} | ||
accumulator[key] = [].concat(accumulator[key], value); | ||
}; | ||
case "colon-list-separator": | ||
return (key, value, accumulator) => { | ||
result = /(:list)$/.exec(key); | ||
key = key.replace(/:list$/, ""); | ||
if (!result) { | ||
accumulator[key] = value; | ||
return; | ||
} | ||
if (accumulator[key] === void 0) { | ||
accumulator[key] = [value]; | ||
return; | ||
} | ||
accumulator[key] = [].concat(accumulator[key], value); | ||
}; | ||
case "comma": | ||
case "separator": | ||
return (key, value, accumulator) => { | ||
const isArray = typeof value === "string" && value.includes(options.arrayFormatSeparator); | ||
const isEncodedArray = typeof value === "string" && !isArray && decode(value, options).includes(options.arrayFormatSeparator); | ||
value = isEncodedArray ? decode(value, options) : value; | ||
const newValue = isArray || isEncodedArray ? value.split(options.arrayFormatSeparator).map((item) => decode(item, options)) : value === null ? value : decode(value, options); | ||
accumulator[key] = newValue; | ||
}; | ||
case "bracket-separator": | ||
return (key, value, accumulator) => { | ||
const isArray = /(\[\])$/.test(key); | ||
key = key.replace(/\[\]$/, ""); | ||
if (!isArray) { | ||
accumulator[key] = value ? decode(value, options) : value; | ||
return; | ||
} | ||
const arrayValue = value === null ? [] : value.split(options.arrayFormatSeparator).map((item) => decode(item, options)); | ||
if (accumulator[key] === void 0) { | ||
accumulator[key] = arrayValue; | ||
return; | ||
} | ||
accumulator[key] = [].concat(accumulator[key], arrayValue); | ||
}; | ||
default: | ||
return (key, value, accumulator) => { | ||
if (accumulator[key] === void 0) { | ||
accumulator[key] = value; | ||
return; | ||
} | ||
accumulator[key] = [].concat(accumulator[key], value); | ||
}; | ||
} | ||
} | ||
function validateArrayFormatSeparator(value) { | ||
if (typeof value !== "string" || value.length !== 1) { | ||
throw new TypeError("arrayFormatSeparator must be single character string"); | ||
} | ||
} | ||
function encode(value, options) { | ||
if (options.encode) { | ||
return options.strict ? strictUriEncode(value) : encodeURIComponent(value); | ||
} | ||
return value; | ||
} | ||
function decode(value, options) { | ||
if (options.decode) { | ||
return decodeComponent(value); | ||
} | ||
return value; | ||
} | ||
function keysSorter(input) { | ||
if (Array.isArray(input)) { | ||
return input.sort(); | ||
} | ||
if (typeof input === "object") { | ||
return keysSorter(Object.keys(input)).sort((a, b) => Number(a) - Number(b)).map((key) => input[key]); | ||
} | ||
return input; | ||
} | ||
function removeHash(input) { | ||
const hashStart = input.indexOf("#"); | ||
if (hashStart !== -1) { | ||
input = input.slice(0, hashStart); | ||
} | ||
return input; | ||
} | ||
function getHash(url) { | ||
let hash = ""; | ||
const hashStart = url.indexOf("#"); | ||
if (hashStart !== -1) { | ||
hash = url.slice(hashStart); | ||
} | ||
return hash; | ||
} | ||
function extract(input) { | ||
input = removeHash(input); | ||
const queryStart = input.indexOf("?"); | ||
if (queryStart === -1) { | ||
return ""; | ||
} | ||
return input.slice(queryStart + 1); | ||
} | ||
function parseValue(value, options) { | ||
if (options.parseNumbers && !Number.isNaN(Number(value)) && (typeof value === "string" && value.trim() !== "")) { | ||
value = Number(value); | ||
} else if (options.parseBooleans && value !== null && (value.toLowerCase() === "true" || value.toLowerCase() === "false")) { | ||
value = value.toLowerCase() === "true"; | ||
} | ||
return value; | ||
} | ||
function parse(query, options) { | ||
options = Object.assign({ | ||
decode: true, | ||
sort: true, | ||
arrayFormat: "none", | ||
arrayFormatSeparator: ",", | ||
parseNumbers: false, | ||
parseBooleans: false | ||
}, options); | ||
validateArrayFormatSeparator(options.arrayFormatSeparator); | ||
const formatter = parserForArrayFormat(options); | ||
const ret = /* @__PURE__ */ Object.create(null); | ||
if (typeof query !== "string") { | ||
return ret; | ||
} | ||
query = query.trim().replace(/^[?#&]/, ""); | ||
if (!query) { | ||
return ret; | ||
} | ||
for (const param of query.split("&")) { | ||
if (param === "") { | ||
continue; | ||
} | ||
let [key, value] = splitOnFirst(options.decode ? param.replace(/\+/g, " ") : param, "="); | ||
value = value === void 0 ? null : ["comma", "separator", "bracket-separator"].includes(options.arrayFormat) ? value : decode(value, options); | ||
formatter(decode(key, options), value, ret); | ||
} | ||
for (const key of Object.keys(ret)) { | ||
const value = ret[key]; | ||
if (typeof value === "object" && value !== null) { | ||
for (const k of Object.keys(value)) { | ||
value[k] = parseValue(value[k], options); | ||
} | ||
} else { | ||
ret[key] = parseValue(value, options); | ||
} | ||
} | ||
if (options.sort === false) { | ||
return ret; | ||
} | ||
return (options.sort === true ? Object.keys(ret).sort() : Object.keys(ret).sort(options.sort)).reduce((result, key) => { | ||
const value = ret[key]; | ||
if (Boolean(value) && typeof value === "object" && !Array.isArray(value)) { | ||
result[key] = keysSorter(value); | ||
} else { | ||
result[key] = value; | ||
} | ||
return result; | ||
}, /* @__PURE__ */ Object.create(null)); | ||
} | ||
exports.extract = extract; | ||
exports.parse = parse; | ||
exports.stringify = (object, options) => { | ||
if (!object) { | ||
return ""; | ||
} | ||
options = Object.assign({ | ||
encode: true, | ||
strict: true, | ||
arrayFormat: "none", | ||
arrayFormatSeparator: "," | ||
}, options); | ||
validateArrayFormatSeparator(options.arrayFormatSeparator); | ||
const shouldFilter = (key) => options.skipNull && isNullOrUndefined(object[key]) || options.skipEmptyString && object[key] === ""; | ||
const formatter = encoderForArrayFormat(options); | ||
const objectCopy = {}; | ||
for (const key of Object.keys(object)) { | ||
if (!shouldFilter(key)) { | ||
objectCopy[key] = object[key]; | ||
} | ||
} | ||
const keys = Object.keys(objectCopy); | ||
if (options.sort !== false) { | ||
keys.sort(options.sort); | ||
} | ||
return keys.map((key) => { | ||
const value = object[key]; | ||
if (value === void 0) { | ||
return ""; | ||
} | ||
if (value === null) { | ||
return encode(key, options); | ||
} | ||
if (Array.isArray(value)) { | ||
if (value.length === 0 && options.arrayFormat === "bracket-separator") { | ||
return encode(key, options) + "[]"; | ||
} | ||
return value.reduce(formatter(key), []).join("&"); | ||
} | ||
return encode(key, options) + "=" + encode(value, options); | ||
}).filter((x) => x.length > 0).join("&"); | ||
}; | ||
exports.parseUrl = (url, options) => { | ||
options = Object.assign({ | ||
decode: true | ||
}, options); | ||
const [url_, hash] = splitOnFirst(url, "#"); | ||
return Object.assign({ | ||
url: url_.split("?")[0] || "", | ||
query: parse(extract(url), options) | ||
}, options && options.parseFragmentIdentifier && hash ? { fragmentIdentifier: decode(hash, options) } : {}); | ||
}; | ||
exports.stringifyUrl = (object, options) => { | ||
options = Object.assign({ | ||
encode: true, | ||
strict: true, | ||
[encodeFragmentIdentifier]: true | ||
}, options); | ||
const url = removeHash(object.url).split("?")[0] || ""; | ||
const queryFromUrl = exports.extract(object.url); | ||
const parsedQueryFromUrl = exports.parse(queryFromUrl, { sort: false }); | ||
const query = Object.assign(parsedQueryFromUrl, object.query); | ||
let queryString = exports.stringify(query, options); | ||
if (queryString) { | ||
queryString = `?${queryString}`; | ||
} | ||
let hash = getHash(object.url); | ||
if (object.fragmentIdentifier) { | ||
hash = `#${options[encodeFragmentIdentifier] ? encode(object.fragmentIdentifier, options) : object.fragmentIdentifier}`; | ||
} | ||
return `${url}${queryString}${hash}`; | ||
}; | ||
exports.pick = (input, filter, options) => { | ||
options = Object.assign({ | ||
parseFragmentIdentifier: true, | ||
[encodeFragmentIdentifier]: false | ||
}, options); | ||
const { url, query, fragmentIdentifier } = exports.parseUrl(input, options); | ||
return exports.stringifyUrl({ | ||
url, | ||
query: filterObject(query, filter), | ||
fragmentIdentifier | ||
}, options); | ||
}; | ||
exports.exclude = (input, filter, options) => { | ||
const exclusionFilter = Array.isArray(filter) ? (key) => !filter.includes(key) : (key, value) => !filter(key, value); | ||
return exports.pick(input, exclusionFilter, options); | ||
}; | ||
} | ||
}); | ||
// src/hooks/useQueryState.ts | ||
var qs = __toESM(require_query_string()); | ||
import { useCallback } from "react"; | ||
import { useQueryStore } from "../store.js"; | ||
console.log("useCallback", useCallback); | ||
var useQueryState = (propName, defaultValue = null) => { | ||
const selector = useCallback((state) => typeof state[propName] !== "undefined" ? state[propName] : defaultValue, [propName, defaultValue]); | ||
const globalValue = useQueryStore(selector); | ||
const _setGlobalValue = useCallback((valueFun) => useQueryStore.setState({ | ||
[propName]: valueFun(useQueryStore.getState()[propName]) | ||
}), [propName]); | ||
const setQueryValue = useCallback((newVal) => { | ||
_setGlobalValue((currentState) => { | ||
if (typeof newVal === "function") { | ||
newVal = newVal(currentState || defaultValue); | ||
} | ||
if (Number.isFinite(newVal)) { | ||
newVal = parseFloat(newVal.toFixed(2)); | ||
} | ||
setTimeout(() => { | ||
const query = useQueryStore.getState(); | ||
updateHistory(qs.stringifyUrl({ url: window.location.pathname, query }, { skipNull: true, arrayFormat: "index" })); | ||
}, 0); | ||
return newVal; | ||
}); | ||
}, [_setGlobalValue]); | ||
return [globalValue, setQueryValue]; | ||
return [3]; | ||
}; | ||
function updateHistory(path) { | ||
var _a; | ||
window.history.pushState({ | ||
prevUrls: [ | ||
...((_a = window.history.state) == null ? void 0 : _a.prevUrls) || [], | ||
window.location.origin + path | ||
] | ||
}, document.title, path); | ||
} | ||
var useQueryState_default = useQueryState; | ||
@@ -528,0 +8,0 @@ export { |
@@ -9,1 +9,2 @@ // src/index.tsx | ||
export * from "./consts.js"; | ||
export * from "./Box/index.js"; |
@@ -8,4 +8,4 @@ // src/UI/Controls/AllControls/AllControls.tsx | ||
// esbuild-css-modules-plugin-namespace:/var/folders/ym/yzmq9ln54g95nc5cn7pqjr180000gn/T/tmp-88532-z01LIa5vWdPJ/shadergradient/src/UI/Controls/AllControls/AllControls.module.css.js | ||
var digest = "30418763de029899eac1486958e1a23149fa098eb670e3ec8b68529a9a63af9f"; | ||
// esbuild-css-modules-plugin-namespace:/var/folders/ym/yzmq9ln54g95nc5cn7pqjr180000gn/T/tmp-49322-fLZ7aTU2xjEb/shadergradient/src/UI/Controls/AllControls/AllControls.module.css.js | ||
var digest = "2b8b10798a14dba3d7a51b08fbb81ed24d6932e00597a837c99f6be0d5c4bbae"; | ||
var css = `._controlMobile_1dm53_1 { | ||
@@ -12,0 +12,0 @@ width: 100vw; |
@@ -9,4 +9,4 @@ // src/UI/Header/Header.tsx | ||
// esbuild-css-modules-plugin-namespace:/var/folders/ym/yzmq9ln54g95nc5cn7pqjr180000gn/T/tmp-88532-z01LIa5vWdPJ/shadergradient/src/UI/Header/Header.module.css.js | ||
var digest = "921f2480323cec1dc92cb2674e095edb058344ff92dde2e96cb8bac5d5891f94"; | ||
// esbuild-css-modules-plugin-namespace:/var/folders/ym/yzmq9ln54g95nc5cn7pqjr180000gn/T/tmp-49322-fLZ7aTU2xjEb/shadergradient/src/UI/Header/Header.module.css.js | ||
var digest = "0702ecc464bb7465cb5bed1736cd29b3bdba6617ebf43e94bffb90725821baa1"; | ||
var css = `._header_bdl6a_1 { | ||
@@ -13,0 +13,0 @@ width: 100vw; |
@@ -1010,4 +1010,4 @@ var __create = Object.create; | ||
// esbuild-css-modules-plugin-namespace:/var/folders/ym/yzmq9ln54g95nc5cn7pqjr180000gn/T/tmp-88532-z01LIa5vWdPJ/shadergradient/src/UI/Links/Links.module.css.js | ||
var digest = "68a6a14da7fcf261102191f5047bd8f816a55fabde508467b1dd9f5eb2d71c73"; | ||
// esbuild-css-modules-plugin-namespace:/var/folders/ym/yzmq9ln54g95nc5cn7pqjr180000gn/T/tmp-49322-fLZ7aTU2xjEb/shadergradient/src/UI/Links/Links.module.css.js | ||
var digest = "865edffcf9b756d5fa74cdb4d489875e71afc36121bde7d21ebeee54599ee5a2"; | ||
var css = `._LinksWrapper_xqdmj_1 { | ||
@@ -1014,0 +1014,0 @@ width: 100vw; |
@@ -8,4 +8,4 @@ // src/UI/PresetTitle/PresetTitle.tsx | ||
// esbuild-css-modules-plugin-namespace:/var/folders/ym/yzmq9ln54g95nc5cn7pqjr180000gn/T/tmp-88532-z01LIa5vWdPJ/shadergradient/src/UI/PresetTitle/PresetTitle.module.css.js | ||
var digest = "f16cd110edfed630eedc5e2f6719ad8440abbfe32055acfa2ca2bf7dc5cb82ec"; | ||
// esbuild-css-modules-plugin-namespace:/var/folders/ym/yzmq9ln54g95nc5cn7pqjr180000gn/T/tmp-49322-fLZ7aTU2xjEb/shadergradient/src/UI/PresetTitle/PresetTitle.module.css.js | ||
var digest = "38a0dbc51cf0e229c182fae0950493111b2810eb91f6964882059d8edad7c7ff"; | ||
var css = `@import url("https://fonts.googleapis.com/css2?family=Lora:wght@500&display=swap"); | ||
@@ -12,0 +12,0 @@ ._presetWrapper_nbez8_2 { |
{ | ||
"name": "shadergradient", | ||
"version": "0.3.18", | ||
"main": "src/index.tsx", | ||
"version": "0.3.19", | ||
"main": "dist/index.js", | ||
"scripts": { | ||
@@ -6,0 +6,0 @@ "serve": "yarn install && node esmbuild/esmbuild serve ./src 8001", |
Sorry, the diff of this file is not supported yet
561
46836255
1232968