@fcanvas/worker
Version:
The plugin provides support for using fCanvas in WebWorker
1,560 lines (1,553 loc) • 197 kB
JavaScript
var fWorker = (function (exports) {
'use strict';
var __create = Object.create;
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
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(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};
// ../../node_modules/.pnpm/path-normalize@6.0.10/node_modules/path-normalize/lib/index.js
var require_lib = __commonJS({
"../../node_modules/.pnpm/path-normalize@6.0.10/node_modules/path-normalize/lib/index.js"(exports, module) {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
function _typeof(obj) {
"@babel/helpers - typeof";
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) {
return typeof obj2;
} : function(obj2) {
return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
}, _typeof(obj);
}
var SLASH = 47;
var DOT = 46;
var assertPath = function assertPath2(path) {
var t = _typeof(path);
if (t !== "string") {
throw new TypeError("Expected a string, got a ".concat(t));
}
};
var posixNormalize = function posixNormalize2(path, allowAboveRoot) {
var res = "";
var lastSegmentLength = 0;
var lastSlash = -1;
var dots = 0;
var code;
for (var i = 0; i <= path.length; ++i) {
if (i < path.length) {
code = path.charCodeAt(i);
} else if (code === SLASH) {
break;
} else {
code = SLASH;
}
if (code === SLASH) {
if (lastSlash === i - 1 || dots === 1) ; else if (lastSlash !== i - 1 && dots === 2) {
if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== DOT || res.charCodeAt(res.length - 2) !== DOT) {
if (res.length > 2) {
var lastSlashIndex = res.lastIndexOf("/");
if (lastSlashIndex !== res.length - 1) {
if (lastSlashIndex === -1) {
res = "";
lastSegmentLength = 0;
} else {
res = res.slice(0, lastSlashIndex);
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
}
lastSlash = i;
dots = 0;
continue;
}
} else if (res.length === 2 || res.length === 1) {
res = "";
lastSegmentLength = 0;
lastSlash = i;
dots = 0;
continue;
}
}
if (allowAboveRoot) {
if (res.length > 0) {
res += "/..";
} else {
res = "..";
}
lastSegmentLength = 2;
}
} else {
if (res.length > 0) {
res += "/" + path.slice(lastSlash + 1, i);
} else {
res = path.slice(lastSlash + 1, i);
}
lastSegmentLength = i - lastSlash - 1;
}
lastSlash = i;
dots = 0;
} else if (code === DOT && dots !== -1) {
++dots;
} else {
dots = -1;
}
}
return res;
};
var decode = function decode2(s) {
try {
return decodeURIComponent(s);
} catch (_unused) {
return s;
}
};
var normalize2 = function normalize3(p) {
assertPath(p);
var path = p;
if (path.length === 0) {
return ".";
}
var isAbsolute = path.charCodeAt(0) === SLASH;
var trailingSeparator = path.charCodeAt(path.length - 1) === SLASH;
path = decode(path);
path = posixNormalize(path, !isAbsolute);
if (path.length === 0 && !isAbsolute) {
path = ".";
}
if (path.length > 0 && trailingSeparator) {
path += "/";
}
if (isAbsolute) {
return "/" + path;
}
return path;
};
var _default = normalize2;
exports["default"] = _default;
module.exports = exports.default;
}
});
// ../communicate/dist/index.mjs
var __defProp2 = Object.defineProperty;
var __getOwnPropSymbols2 = Object.getOwnPropertySymbols;
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
var __propIsEnum2 = Object.prototype.propertyIsEnumerable;
var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues2 = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp2.call(b, prop))
__defNormalProp2(a, prop, b[prop]);
if (__getOwnPropSymbols2)
for (var prop of __getOwnPropSymbols2(b)) {
if (__propIsEnum2.call(b, prop))
__defNormalProp2(a, prop, b[prop]);
}
return a;
};
var __async2 = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};
var uuid = typeof crypto !== "undefined" && crypto.randomUUID ? crypto.randomUUID.bind(crypto) : () => {
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(
/[xy]/g,
function(c) {
const r = Math.random() * 16 | 0;
const v = c === "x" ? r : r & 3 | 8;
return v.toString(16);
}
);
};
var { toString } = Object.prototype;
function isError(err) {
return toString.call(err) === "[object Error]";
}
var stringifyOrRaw = (data) => {
try {
return JSON.stringify(data);
} catch (e) {
return JSON.stringify(data + "");
}
};
var storeListen = /* @__PURE__ */ new WeakMap();
function listen(port, name, listener, options) {
function handler(event) {
return __async2(this, null, function* () {
const { data } = event;
if (typeof data !== "object")
return;
if (data.type === "call_fn" && data.name === name) {
if (options == null ? void 0 : options.once)
stop();
if (data.ping) {
listener(...data.args);
return;
}
let result;
let err;
try {
const r = yield listener(...data.args);
if (r && typeof r === "object" && "return" in r) {
result = r;
} else {
result = {
return: r
};
}
} catch (error) {
if (options == null ? void 0 : options.debug)
console.warn(error);
err = error;
}
const message = __spreadValues2({
id: data.id,
type: "return_fn",
name: data.name
}, result ? {
retu: result.return,
isOk: true
} : {
retu: isError(err) ? {
isError: true,
data: err.message
} : {
isError: false,
data: stringifyOrRaw(err)
},
isOk: false
});
port.postMessage(message, result);
}
});
}
let conf = storeListen.get(port);
if (!conf) {
if (options == null ? void 0 : options.unique) {
port.addEventListener("message", handler);
} else {
const cbs = /* @__PURE__ */ new Set();
cbs.add(handler);
storeListen.set(
port,
conf = {
handle(event) {
cbs.forEach((cb) => cb(event));
},
cbs
}
);
port.addEventListener("message", conf.handle);
}
} else {
conf.cbs.add(handler);
}
function stop() {
if (options == null ? void 0 : options.unique) {
port.removeEventListener("message", handler);
return;
}
const conf2 = storeListen.get(port);
if (!conf2)
return;
conf2.cbs.delete(handler);
if (conf2.cbs.size === 0) {
port.removeEventListener("message", conf2.handle);
storeListen.delete(port);
}
}
return stop;
}
function pit(port, options, ...args) {
let name;
if (typeof options === "object")
name = options.name;
else
name = options;
const message = {
id: "0",
type: "call_fn",
name,
args,
ping: true
};
port.postMessage(message, typeof options === "object" ? options : void 0);
}
var storePut = /* @__PURE__ */ new WeakMap();
function put(port, options, ...args) {
return new Promise((resolve, reject) => {
var _a8;
const id = uuid();
let name;
let timeout = 3e4;
let signal;
if (typeof options === "object") {
name = options.name;
timeout = (_a8 = options.timeout) != null ? _a8 : 3e4;
signal = options.signal;
} else {
name = options;
}
if (signal == null ? void 0 : signal.aborted) {
reject(new Error("aborted"));
return;
}
function handler(event) {
const { data } = event;
if (typeof data !== "object")
return;
if (data.type === "return_fn" && data.id === id && data.name === name) {
if (data.isOk) {
resolve(data.retu);
} else {
if (data.retu.isError)
reject(new Error(data.retu.data));
else
reject(JSON.parse(data.retu.data));
}
stop();
}
}
const timeoutId = timeout > 0 ? setTimeout(() => {
stop();
reject(new Error("timeout"));
}, timeout) : null;
function onAbort() {
stop();
reject(new Error("aborted"));
}
let conf = storePut.get(port);
if (!conf) {
const cbs = /* @__PURE__ */ new Set();
cbs.add(handler);
storePut.set(
port,
conf = {
handle(event) {
cbs.forEach((cb) => cb(event));
},
cbs
}
);
port.addEventListener("message", conf.handle);
} else {
conf.cbs.add(handler);
}
signal == null ? void 0 : signal.addEventListener("abort", onAbort);
function stop() {
timeoutId && clearTimeout(timeoutId);
signal == null ? void 0 : signal.removeEventListener("abort", onAbort);
const conf2 = storePut.get(port);
if (!conf2)
return;
conf2.cbs.delete(handler);
if (conf2.cbs.size === 0) {
port.removeEventListener("message", conf2.handle);
storePut.delete(port);
}
}
const message = {
id,
type: "call_fn",
name,
args
};
port.postMessage(message, typeof options === "object" ? options : void 0);
});
}
// ../../node_modules/.pnpm/@vue+shared@3.2.47/node_modules/@vue/shared/dist/shared.esm-bundler.js
function makeMap(str, expectsLowerCase) {
const map = /* @__PURE__ */ Object.create(null);
const list = str.split(",");
for (let i = 0; i < list.length; i++) {
map[list[i]] = true;
}
return expectsLowerCase ? (val) => !!map[val.toLowerCase()] : (val) => !!map[val];
}
var EMPTY_OBJ = (window.__DEV__ !== false ? "development" : "production") !== "production" ? Object.freeze({}) : {};
var NOOP = () => {
};
var extend = Object.assign;
var hasOwnProperty = Object.prototype.hasOwnProperty;
var hasOwn = (val, key) => hasOwnProperty.call(val, key);
var isArray = Array.isArray;
var isMap = (val) => toTypeString(val) === "[object Map]";
var isSet = (val) => toTypeString(val) === "[object Set]";
var isFunction = (val) => typeof val === "function";
var isString = (val) => typeof val === "string";
var isSymbol = (val) => typeof val === "symbol";
var isObject = (val) => val !== null && typeof val === "object";
var isPromise = (val) => {
return isObject(val) && isFunction(val.then) && isFunction(val.catch);
};
var objectToString = Object.prototype.toString;
var toTypeString = (value) => objectToString.call(value);
var toRawType = (value) => {
return toTypeString(value).slice(8, -1);
};
var isPlainObject = (val) => toTypeString(val) === "[object Object]";
var isIntegerKey = (key) => isString(key) && key !== "NaN" && key[0] !== "-" && "" + parseInt(key, 10) === key;
var cacheStringFunction = (fn) => {
const cache = /* @__PURE__ */ Object.create(null);
return (str) => {
const hit = cache[str];
return hit || (cache[str] = fn(str));
};
};
var capitalize = cacheStringFunction((str) => str.charAt(0).toUpperCase() + str.slice(1));
var hasChanged = (value, oldValue) => !Object.is(value, oldValue);
// ../../node_modules/.pnpm/@vue+reactivity@3.2.47/node_modules/@vue/reactivity/dist/reactivity.esm-bundler.js
function warn(msg, ...args) {
console.warn(`[Vue warn] ${msg}`, ...args);
}
var activeEffectScope;
var EffectScope = class {
constructor(detached = false) {
this.detached = detached;
this._active = true;
this.effects = [];
this.cleanups = [];
this.parent = activeEffectScope;
if (!detached && activeEffectScope) {
this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1;
}
}
get active() {
return this._active;
}
run(fn) {
if (this._active) {
const currentEffectScope = activeEffectScope;
try {
activeEffectScope = this;
return fn();
} finally {
activeEffectScope = currentEffectScope;
}
} else if ((window.__DEV__ !== false ? "development" : "production") !== "production") {
warn(`cannot run an inactive effect scope.`);
}
}
/**
* This should only be called on non-detached scopes
* @internal
*/
on() {
activeEffectScope = this;
}
/**
* This should only be called on non-detached scopes
* @internal
*/
off() {
activeEffectScope = this.parent;
}
stop(fromParent) {
if (this._active) {
let i, l;
for (i = 0, l = this.effects.length; i < l; i++) {
this.effects[i].stop();
}
for (i = 0, l = this.cleanups.length; i < l; i++) {
this.cleanups[i]();
}
if (this.scopes) {
for (i = 0, l = this.scopes.length; i < l; i++) {
this.scopes[i].stop(true);
}
}
if (!this.detached && this.parent && !fromParent) {
const last = this.parent.scopes.pop();
if (last && last !== this) {
this.parent.scopes[this.index] = last;
last.index = this.index;
}
}
this.parent = void 0;
this._active = false;
}
}
};
function recordEffectScope(effect, scope = activeEffectScope) {
if (scope && scope.active) {
scope.effects.push(effect);
}
}
function getCurrentScope() {
return activeEffectScope;
}
var createDep = (effects) => {
const dep = new Set(effects);
dep.w = 0;
dep.n = 0;
return dep;
};
var wasTracked = (dep) => (dep.w & trackOpBit) > 0;
var newTracked = (dep) => (dep.n & trackOpBit) > 0;
var initDepMarkers = ({ deps }) => {
if (deps.length) {
for (let i = 0; i < deps.length; i++) {
deps[i].w |= trackOpBit;
}
}
};
var finalizeDepMarkers = (effect) => {
const { deps } = effect;
if (deps.length) {
let ptr = 0;
for (let i = 0; i < deps.length; i++) {
const dep = deps[i];
if (wasTracked(dep) && !newTracked(dep)) {
dep.delete(effect);
} else {
deps[ptr++] = dep;
}
dep.w &= ~trackOpBit;
dep.n &= ~trackOpBit;
}
deps.length = ptr;
}
};
var targetMap = /* @__PURE__ */ new WeakMap();
var effectTrackDepth = 0;
var trackOpBit = 1;
var maxMarkerBits = 30;
var activeEffect;
var ITERATE_KEY = Symbol((window.__DEV__ !== false ? "development" : "production") !== "production" ? "iterate" : "");
var MAP_KEY_ITERATE_KEY = Symbol((window.__DEV__ !== false ? "development" : "production") !== "production" ? "Map key iterate" : "");
var ReactiveEffect = class {
constructor(fn, scheduler = null, scope) {
this.fn = fn;
this.scheduler = scheduler;
this.active = true;
this.deps = [];
this.parent = void 0;
recordEffectScope(this, scope);
}
run() {
if (!this.active) {
return this.fn();
}
let parent = activeEffect;
let lastShouldTrack = shouldTrack;
while (parent) {
if (parent === this) {
return;
}
parent = parent.parent;
}
try {
this.parent = activeEffect;
activeEffect = this;
shouldTrack = true;
trackOpBit = 1 << ++effectTrackDepth;
if (effectTrackDepth <= maxMarkerBits) {
initDepMarkers(this);
} else {
cleanupEffect(this);
}
return this.fn();
} finally {
if (effectTrackDepth <= maxMarkerBits) {
finalizeDepMarkers(this);
}
trackOpBit = 1 << --effectTrackDepth;
activeEffect = this.parent;
shouldTrack = lastShouldTrack;
this.parent = void 0;
if (this.deferStop) {
this.stop();
}
}
}
stop() {
if (activeEffect === this) {
this.deferStop = true;
} else if (this.active) {
cleanupEffect(this);
if (this.onStop) {
this.onStop();
}
this.active = false;
}
}
};
function cleanupEffect(effect) {
const { deps } = effect;
if (deps.length) {
for (let i = 0; i < deps.length; i++) {
deps[i].delete(effect);
}
deps.length = 0;
}
}
var shouldTrack = true;
var trackStack = [];
function pauseTracking() {
trackStack.push(shouldTrack);
shouldTrack = false;
}
function resetTracking() {
const last = trackStack.pop();
shouldTrack = last === void 0 ? true : last;
}
function track(target, type2, key) {
if (shouldTrack && activeEffect) {
let depsMap = targetMap.get(target);
if (!depsMap) {
targetMap.set(target, depsMap = /* @__PURE__ */ new Map());
}
let dep = depsMap.get(key);
if (!dep) {
depsMap.set(key, dep = createDep());
}
const eventInfo = (window.__DEV__ !== false ? "development" : "production") !== "production" ? { effect: activeEffect, target, type: type2, key } : void 0;
trackEffects(dep, eventInfo);
}
}
function trackEffects(dep, debuggerEventExtraInfo) {
let shouldTrack2 = false;
if (effectTrackDepth <= maxMarkerBits) {
if (!newTracked(dep)) {
dep.n |= trackOpBit;
shouldTrack2 = !wasTracked(dep);
}
} else {
shouldTrack2 = !dep.has(activeEffect);
}
if (shouldTrack2) {
dep.add(activeEffect);
activeEffect.deps.push(dep);
if ((window.__DEV__ !== false ? "development" : "production") !== "production" && activeEffect.onTrack) {
activeEffect.onTrack(Object.assign({ effect: activeEffect }, debuggerEventExtraInfo));
}
}
}
function trigger(target, type2, key, newValue, oldValue, oldTarget) {
const depsMap = targetMap.get(target);
if (!depsMap) {
return;
}
let deps = [];
if (type2 === "clear") {
deps = [...depsMap.values()];
} else if (key === "length" && isArray(target)) {
const newLength = Number(newValue);
depsMap.forEach((dep, key2) => {
if (key2 === "length" || key2 >= newLength) {
deps.push(dep);
}
});
} else {
if (key !== void 0) {
deps.push(depsMap.get(key));
}
switch (type2) {
case "add":
if (!isArray(target)) {
deps.push(depsMap.get(ITERATE_KEY));
if (isMap(target)) {
deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
}
} else if (isIntegerKey(key)) {
deps.push(depsMap.get("length"));
}
break;
case "delete":
if (!isArray(target)) {
deps.push(depsMap.get(ITERATE_KEY));
if (isMap(target)) {
deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
}
}
break;
case "set":
if (isMap(target)) {
deps.push(depsMap.get(ITERATE_KEY));
}
break;
}
}
const eventInfo = (window.__DEV__ !== false ? "development" : "production") !== "production" ? { target, type: type2, key, newValue, oldValue, oldTarget } : void 0;
if (deps.length === 1) {
if (deps[0]) {
if ((window.__DEV__ !== false ? "development" : "production") !== "production") {
triggerEffects(deps[0], eventInfo);
} else {
triggerEffects(deps[0]);
}
}
} else {
const effects = [];
for (const dep of deps) {
if (dep) {
effects.push(...dep);
}
}
if ((window.__DEV__ !== false ? "development" : "production") !== "production") {
triggerEffects(createDep(effects), eventInfo);
} else {
triggerEffects(createDep(effects));
}
}
}
function triggerEffects(dep, debuggerEventExtraInfo) {
const effects = isArray(dep) ? dep : [...dep];
for (const effect of effects) {
if (effect.computed) {
triggerEffect(effect, debuggerEventExtraInfo);
}
}
for (const effect of effects) {
if (!effect.computed) {
triggerEffect(effect, debuggerEventExtraInfo);
}
}
}
function triggerEffect(effect, debuggerEventExtraInfo) {
if (effect !== activeEffect || effect.allowRecurse) {
if ((window.__DEV__ !== false ? "development" : "production") !== "production" && effect.onTrigger) {
effect.onTrigger(extend({ effect }, debuggerEventExtraInfo));
}
if (effect.scheduler) {
effect.scheduler();
} else {
effect.run();
}
}
}
var isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`);
var builtInSymbols = new Set(
/* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol)
);
var get$1 = /* @__PURE__ */ createGetter();
var shallowGet = /* @__PURE__ */ createGetter(false, true);
var readonlyGet = /* @__PURE__ */ createGetter(true);
var arrayInstrumentations = /* @__PURE__ */ createArrayInstrumentations();
function createArrayInstrumentations() {
const instrumentations = {};
["includes", "indexOf", "lastIndexOf"].forEach((key) => {
instrumentations[key] = function(...args) {
const arr = toRaw(this);
for (let i = 0, l = this.length; i < l; i++) {
track(arr, "get", i + "");
}
const res = arr[key](...args);
if (res === -1 || res === false) {
return arr[key](...args.map(toRaw));
} else {
return res;
}
};
});
["push", "pop", "shift", "unshift", "splice"].forEach((key) => {
instrumentations[key] = function(...args) {
pauseTracking();
const res = toRaw(this)[key].apply(this, args);
resetTracking();
return res;
};
});
return instrumentations;
}
function hasOwnProperty2(key) {
const obj = toRaw(this);
track(obj, "has", key);
return obj.hasOwnProperty(key);
}
function createGetter(isReadonly2 = false, shallow = false) {
return function get2(target, key, receiver) {
if (key === "__v_isReactive") {
return !isReadonly2;
} else if (key === "__v_isReadonly") {
return isReadonly2;
} else if (key === "__v_isShallow") {
return shallow;
} else if (key === "__v_raw" && receiver === (isReadonly2 ? shallow ? shallowReadonlyMap : readonlyMap : shallow ? shallowReactiveMap : reactiveMap).get(target)) {
return target;
}
const targetIsArray = isArray(target);
if (!isReadonly2) {
if (targetIsArray && hasOwn(arrayInstrumentations, key)) {
return Reflect.get(arrayInstrumentations, key, receiver);
}
if (key === "hasOwnProperty") {
return hasOwnProperty2;
}
}
const res = Reflect.get(target, key, receiver);
if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
return res;
}
if (!isReadonly2) {
track(target, "get", key);
}
if (shallow) {
return res;
}
if (isRef(res)) {
return targetIsArray && isIntegerKey(key) ? res : res.value;
}
if (isObject(res)) {
return isReadonly2 ? readonly(res) : reactive(res);
}
return res;
};
}
var set$1 = /* @__PURE__ */ createSetter();
var shallowSet = /* @__PURE__ */ createSetter(true);
function createSetter(shallow = false) {
return function set2(target, key, value, receiver) {
let oldValue = target[key];
if (isReadonly(oldValue) && isRef(oldValue) && !isRef(value)) {
return false;
}
if (!shallow) {
if (!isShallow(value) && !isReadonly(value)) {
oldValue = toRaw(oldValue);
value = toRaw(value);
}
if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
oldValue.value = value;
return true;
}
}
const hadKey = isArray(target) && isIntegerKey(key) ? Number(key) < target.length : hasOwn(target, key);
const result = Reflect.set(target, key, value, receiver);
if (target === toRaw(receiver)) {
if (!hadKey) {
trigger(target, "add", key, value);
} else if (hasChanged(value, oldValue)) {
trigger(target, "set", key, value, oldValue);
}
}
return result;
};
}
function deleteProperty(target, key) {
const hadKey = hasOwn(target, key);
const oldValue = target[key];
const result = Reflect.deleteProperty(target, key);
if (result && hadKey) {
trigger(target, "delete", key, void 0, oldValue);
}
return result;
}
function has$1(target, key) {
const result = Reflect.has(target, key);
if (!isSymbol(key) || !builtInSymbols.has(key)) {
track(target, "has", key);
}
return result;
}
function ownKeys(target) {
track(target, "iterate", isArray(target) ? "length" : ITERATE_KEY);
return Reflect.ownKeys(target);
}
var mutableHandlers = {
get: get$1,
set: set$1,
deleteProperty,
has: has$1,
ownKeys
};
var readonlyHandlers = {
get: readonlyGet,
set(target, key) {
if ((window.__DEV__ !== false ? "development" : "production") !== "production") {
warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target);
}
return true;
},
deleteProperty(target, key) {
if ((window.__DEV__ !== false ? "development" : "production") !== "production") {
warn(`Delete operation on key "${String(key)}" failed: target is readonly.`, target);
}
return true;
}
};
var shallowReactiveHandlers = /* @__PURE__ */ extend({}, mutableHandlers, {
get: shallowGet,
set: shallowSet
});
var toShallow = (value) => value;
var getProto = (v) => Reflect.getPrototypeOf(v);
function get(target, key, isReadonly2 = false, isShallow2 = false) {
target = target[
"__v_raw"
/* ReactiveFlags.RAW */
];
const rawTarget = toRaw(target);
const rawKey = toRaw(key);
if (!isReadonly2) {
if (key !== rawKey) {
track(rawTarget, "get", key);
}
track(rawTarget, "get", rawKey);
}
const { has: has2 } = getProto(rawTarget);
const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
if (has2.call(rawTarget, key)) {
return wrap(target.get(key));
} else if (has2.call(rawTarget, rawKey)) {
return wrap(target.get(rawKey));
} else if (target !== rawTarget) {
target.get(key);
}
}
function has(key, isReadonly2 = false) {
const target = this[
"__v_raw"
/* ReactiveFlags.RAW */
];
const rawTarget = toRaw(target);
const rawKey = toRaw(key);
if (!isReadonly2) {
if (key !== rawKey) {
track(rawTarget, "has", key);
}
track(rawTarget, "has", rawKey);
}
return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey);
}
function size(target, isReadonly2 = false) {
target = target[
"__v_raw"
/* ReactiveFlags.RAW */
];
!isReadonly2 && track(toRaw(target), "iterate", ITERATE_KEY);
return Reflect.get(target, "size", target);
}
function add(value) {
value = toRaw(value);
const target = toRaw(this);
const proto = getProto(target);
const hadKey = proto.has.call(target, value);
if (!hadKey) {
target.add(value);
trigger(target, "add", value, value);
}
return this;
}
function set(key, value) {
value = toRaw(value);
const target = toRaw(this);
const { has: has2, get: get2 } = getProto(target);
let hadKey = has2.call(target, key);
if (!hadKey) {
key = toRaw(key);
hadKey = has2.call(target, key);
} else if ((window.__DEV__ !== false ? "development" : "production") !== "production") {
checkIdentityKeys(target, has2, key);
}
const oldValue = get2.call(target, key);
target.set(key, value);
if (!hadKey) {
trigger(target, "add", key, value);
} else if (hasChanged(value, oldValue)) {
trigger(target, "set", key, value, oldValue);
}
return this;
}
function deleteEntry(key) {
const target = toRaw(this);
const { has: has2, get: get2 } = getProto(target);
let hadKey = has2.call(target, key);
if (!hadKey) {
key = toRaw(key);
hadKey = has2.call(target, key);
} else if ((window.__DEV__ !== false ? "development" : "production") !== "production") {
checkIdentityKeys(target, has2, key);
}
const oldValue = get2 ? get2.call(target, key) : void 0;
const result = target.delete(key);
if (hadKey) {
trigger(target, "delete", key, void 0, oldValue);
}
return result;
}
function clear() {
const target = toRaw(this);
const hadItems = target.size !== 0;
const oldTarget = (window.__DEV__ !== false ? "development" : "production") !== "production" ? isMap(target) ? new Map(target) : new Set(target) : void 0;
const result = target.clear();
if (hadItems) {
trigger(target, "clear", void 0, void 0, oldTarget);
}
return result;
}
function createForEach(isReadonly2, isShallow2) {
return function forEach(callback, thisArg) {
const observed = this;
const target = observed[
"__v_raw"
/* ReactiveFlags.RAW */
];
const rawTarget = toRaw(target);
const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
!isReadonly2 && track(rawTarget, "iterate", ITERATE_KEY);
return target.forEach((value, key) => {
return callback.call(thisArg, wrap(value), wrap(key), observed);
});
};
}
function createIterableMethod(method, isReadonly2, isShallow2) {
return function(...args) {
const target = this[
"__v_raw"
/* ReactiveFlags.RAW */
];
const rawTarget = toRaw(target);
const targetIsMap = isMap(rawTarget);
const isPair = method === "entries" || method === Symbol.iterator && targetIsMap;
const isKeyOnly = method === "keys" && targetIsMap;
const innerIterator = target[method](...args);
const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
!isReadonly2 && track(rawTarget, "iterate", isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY);
return {
// iterator protocol
next() {
const { value, done } = innerIterator.next();
return done ? { value, done } : {
value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
done
};
},
// iterable protocol
[Symbol.iterator]() {
return this;
}
};
};
}
function createReadonlyMethod(type2) {
return function(...args) {
if ((window.__DEV__ !== false ? "development" : "production") !== "production") {
const key = args[0] ? `on key "${args[0]}" ` : ``;
console.warn(`${capitalize(type2)} operation ${key}failed: target is readonly.`, toRaw(this));
}
return type2 === "delete" ? false : this;
};
}
function createInstrumentations() {
const mutableInstrumentations2 = {
get(key) {
return get(this, key);
},
get size() {
return size(this);
},
has,
add,
set,
delete: deleteEntry,
clear,
forEach: createForEach(false, false)
};
const shallowInstrumentations2 = {
get(key) {
return get(this, key, false, true);
},
get size() {
return size(this);
},
has,
add,
set,
delete: deleteEntry,
clear,
forEach: createForEach(false, true)
};
const readonlyInstrumentations2 = {
get(key) {
return get(this, key, true);
},
get size() {
return size(this, true);
},
has(key) {
return has.call(this, key, true);
},
add: createReadonlyMethod(
"add"
/* TriggerOpTypes.ADD */
),
set: createReadonlyMethod(
"set"
/* TriggerOpTypes.SET */
),
delete: createReadonlyMethod(
"delete"
/* TriggerOpTypes.DELETE */
),
clear: createReadonlyMethod(
"clear"
/* TriggerOpTypes.CLEAR */
),
forEach: createForEach(true, false)
};
const shallowReadonlyInstrumentations2 = {
get(key) {
return get(this, key, true, true);
},
get size() {
return size(this, true);
},
has(key) {
return has.call(this, key, true);
},
add: createReadonlyMethod(
"add"
/* TriggerOpTypes.ADD */
),
set: createReadonlyMethod(
"set"
/* TriggerOpTypes.SET */
),
delete: createReadonlyMethod(
"delete"
/* TriggerOpTypes.DELETE */
),
clear: createReadonlyMethod(
"clear"
/* TriggerOpTypes.CLEAR */
),
forEach: createForEach(true, true)
};
const iteratorMethods = ["keys", "values", "entries", Symbol.iterator];
iteratorMethods.forEach((method) => {
mutableInstrumentations2[method] = createIterableMethod(method, false, false);
readonlyInstrumentations2[method] = createIterableMethod(method, true, false);
shallowInstrumentations2[method] = createIterableMethod(method, false, true);
shallowReadonlyInstrumentations2[method] = createIterableMethod(method, true, true);
});
return [
mutableInstrumentations2,
readonlyInstrumentations2,
shallowInstrumentations2,
shallowReadonlyInstrumentations2
];
}
var [mutableInstrumentations, readonlyInstrumentations, shallowInstrumentations, shallowReadonlyInstrumentations] = /* @__PURE__ */ createInstrumentations();
function createInstrumentationGetter(isReadonly2, shallow) {
const instrumentations = shallow ? isReadonly2 ? shallowReadonlyInstrumentations : shallowInstrumentations : isReadonly2 ? readonlyInstrumentations : mutableInstrumentations;
return (target, key, receiver) => {
if (key === "__v_isReactive") {
return !isReadonly2;
} else if (key === "__v_isReadonly") {
return isReadonly2;
} else if (key === "__v_raw") {
return target;
}
return Reflect.get(hasOwn(instrumentations, key) && key in target ? instrumentations : target, key, receiver);
};
}
var mutableCollectionHandlers = {
get: /* @__PURE__ */ createInstrumentationGetter(false, false)
};
var shallowCollectionHandlers = {
get: /* @__PURE__ */ createInstrumentationGetter(false, true)
};
var readonlyCollectionHandlers = {
get: /* @__PURE__ */ createInstrumentationGetter(true, false)
};
function checkIdentityKeys(target, has2, key) {
const rawKey = toRaw(key);
if (rawKey !== key && has2.call(target, rawKey)) {
const type2 = toRawType(target);
console.warn(`Reactive ${type2} contains both the raw and reactive versions of the same object${type2 === `Map` ? ` as keys` : ``}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`);
}
}
var reactiveMap = /* @__PURE__ */ new WeakMap();
var shallowReactiveMap = /* @__PURE__ */ new WeakMap();
var readonlyMap = /* @__PURE__ */ new WeakMap();
var shallowReadonlyMap = /* @__PURE__ */ new WeakMap();
function targetTypeMap(rawType) {
switch (rawType) {
case "Object":
case "Array":
return 1;
case "Map":
case "Set":
case "WeakMap":
case "WeakSet":
return 2;
default:
return 0;
}
}
function getTargetType(value) {
return value[
"__v_skip"
/* ReactiveFlags.SKIP */
] || !Object.isExtensible(value) ? 0 : targetTypeMap(toRawType(value));
}
function reactive(target) {
if (isReadonly(target)) {
return target;
}
return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap);
}
function shallowReactive(target) {
return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers, shallowReactiveMap);
}
function readonly(target) {
return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap);
}
function createReactiveObject(target, isReadonly2, baseHandlers, collectionHandlers, proxyMap) {
if (!isObject(target)) {
if ((window.__DEV__ !== false ? "development" : "production") !== "production") {
console.warn(`value cannot be made reactive: ${String(target)}`);
}
return target;
}
if (target[
"__v_raw"
/* ReactiveFlags.RAW */
] && !(isReadonly2 && target[
"__v_isReactive"
/* ReactiveFlags.IS_REACTIVE */
])) {
return target;
}
const existingProxy = proxyMap.get(target);
if (existingProxy) {
return existingProxy;
}
const targetType = getTargetType(target);
if (targetType === 0) {
return target;
}
const proxy = new Proxy(target, targetType === 2 ? collectionHandlers : baseHandlers);
proxyMap.set(target, proxy);
return proxy;
}
function isReactive(value) {
if (isReadonly(value)) {
return isReactive(value[
"__v_raw"
/* ReactiveFlags.RAW */
]);
}
return !!(value && value[
"__v_isReactive"
/* ReactiveFlags.IS_REACTIVE */
]);
}
function isReadonly(value) {
return !!(value && value[
"__v_isReadonly"
/* ReactiveFlags.IS_READONLY */
]);
}
function isShallow(value) {
return !!(value && value[
"__v_isShallow"
/* ReactiveFlags.IS_SHALLOW */
]);
}
function toRaw(observed) {
const raw = observed && observed[
"__v_raw"
/* ReactiveFlags.RAW */
];
return raw ? toRaw(raw) : observed;
}
var toReactive = (value) => isObject(value) ? reactive(value) : value;
var toReadonly = (value) => isObject(value) ? readonly(value) : value;
function trackRefValue(ref2) {
if (shouldTrack && activeEffect) {
ref2 = toRaw(ref2);
if ((window.__DEV__ !== false ? "development" : "production") !== "production") {
trackEffects(ref2.dep || (ref2.dep = createDep()), {
target: ref2,
type: "get",
key: "value"
});
} else {
trackEffects(ref2.dep || (ref2.dep = createDep()));
}
}
}
function triggerRefValue(ref2, newVal) {
ref2 = toRaw(ref2);
const dep = ref2.dep;
if (dep) {
if ((window.__DEV__ !== false ? "development" : "production") !== "production") {
triggerEffects(dep, {
target: ref2,
type: "set",
key: "value",
newValue: newVal
});
} else {
triggerEffects(dep);
}
}
}
function isRef(r) {
return !!(r && r.__v_isRef === true);
}
function ref(value) {
return createRef(value, false);
}
function createRef(rawValue, shallow) {
if (isRef(rawValue)) {
return rawValue;
}
return new RefImpl(rawValue, shallow);
}
var RefImpl = class {
constructor(value, __v_isShallow) {
this.__v_isShallow = __v_isShallow;
this.dep = void 0;
this.__v_isRef = true;
this._rawValue = __v_isShallow ? value : toRaw(value);
this._value = __v_isShallow ? value : toReactive(value);
}
get value() {
trackRefValue(this);
return this._value;
}
set value(newVal) {
const useDirectValue = this.__v_isShallow || isShallow(newVal) || isReadonly(newVal);
newVal = useDirectValue ? newVal : toRaw(newVal);
if (hasChanged(newVal, this._rawValue)) {
this._rawValue = newVal;
this._value = useDirectValue ? newVal : toReactive(newVal);
triggerRefValue(this, newVal);
}
}
};
function unref(ref2) {
return isRef(ref2) ? ref2.value : ref2;
}
var _a$1;
var ComputedRefImpl = class {
constructor(getter, _setter, isReadonly2, isSSR) {
this._setter = _setter;
this.dep = void 0;
this.__v_isRef = true;
this[_a$1] = false;
this._dirty = true;
this.effect = new ReactiveEffect(getter, () => {
if (!this._dirty) {
this._dirty = true;
triggerRefValue(this);
}
});
this.effect.computed = this;
this.effect.active = this._cacheable = !isSSR;
this[
"__v_isReadonly"
/* ReactiveFlags.IS_READONLY */
] = isReadonly2;
}
get value() {
const self2 = toRaw(this);
trackRefValue(self2);
if (self2._dirty || !self2._cacheable) {
self2._dirty = false;
self2._value = self2.effect.run();
}
return self2._value;
}
set value(newValue) {
this._setter(newValue);
}
};
_a$1 = "__v_isReadonly";
function computed(getterOrOptions, debugOptions, isSSR = false) {
let getter;
let setter;
const onlyGetter = isFunction(getterOrOptions);
if (onlyGetter) {
getter = getterOrOptions;
setter = (window.__DEV__ !== false ? "development" : "production") !== "production" ? () => {
console.warn("Write operation failed: computed value is readonly");
} : NOOP;
} else {
getter = getterOrOptions.get;
setter = getterOrOptions.set;
}
const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
if ((window.__DEV__ !== false ? "development" : "production") !== "production" && debugOptions && !isSSR) {
cRef.effect.onTrack = debugOptions.onTrack;
cRef.effect.onTrigger = debugOptions.onTrigger;
}
return cRef;
}
// ../fcanvas/dist/index.mjs
var import_path_normalize = __toESM(require_lib(), 1);
var __defProp3 = Object.defineProperty;
var __getOwnPropSymbols3 = Object.getOwnPropertySymbols;
var __hasOwnProp3 = Object.prototype.hasOwnProperty;
var __propIsEnum3 = Object.prototype.propertyIsEnumerable;
var __pow = Math.pow;
var __defNormalProp3 = (obj, key, value) => key in obj ? __defProp3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues3 = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp3.call(b, prop))
__defNormalProp3(a, prop, b[prop]);
if (__getOwnPropSymbols3)
for (var prop of __getOwnPropSymbols3(b)) {
if (__propIsEnum3.call(b, prop))
__defNormalProp3(a, prop, b[prop]);
}
return a;
};
var __publicField = (obj, key, value) => {
__defNormalProp3(obj, typeof key !== "symbol" ? key + "" : key, value);
return value;
};
function callWithErrorHandling(fn, type2, args) {
let res;
try {
res = args ? fn(...args) : fn();
} catch (err) {
handleError(err, type2);
}
return res;
}
function callWithAsyncErrorHandling(fn, type2, args) {
if (isFunction(fn)) {
const res = callWithErrorHandling(fn, type2, args);
if (res && isPromise(res)) {
res.catch((err) => {
handleError(err, type2);
});
}
return res;
}
const values = [];
for (let i = 0; i < fn.length; i++)
values.push(callWithAsyncErrorHandling(fn[i], type2, args));
return values;
}
function handleError(err, type2) {
console.error(new Error(`[src/fns/watch]: ${type2}`));
console.error(err);
}
function warn2(message) {
console.warn(createError(message));
}
function createError(message) {
return new Error(`[reactivue]: ${message}`);
}
var isFlushing = false;
var isFlushPending = false;
var queue = [];
var flushIndex = 0;
var pendingPostFlushCbs = [];
var activePostFlushCbs = null;
var postFlushIndex = 0;
var resolvedPromise = /* @__PURE__ */ Promise.resolve();
var RECURSION_LIMIT = 100;
function findInsertionIndex(id) {
let start = flushIndex + 1;
let end = queue.length;
while (start < end) {
const middle = start + end >>> 1;
const middleJobId = getId(queue[middle]);
middleJobId < id ? start = middle + 1 : end = middle;
}
return start;
}
function queueJob(job) {
if (!queue.length || !queue.includes(
job,
isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex
)) {
if (job.id == null)
queue.push(job);
else
queue.splice(findInsertionIndex(job.id), 0, job);
queueFlush();
}
}
function queueFlush() {
if (!isFlushing && !isFlushPending) {
isFlushPending = true;
resolvedPromise.then(flushJobs);
}
}
function queuePostFlushCb(cb) {
if (!isArray(cb)) {
if (!activePostFlushCbs || !activePostFlushCbs.includes(
cb,
cb.allowRecurse ? postFlushIndex + 1 : postFlushIndex
))
pendingPostFlushCbs.push(cb);
} else {
pendingPostFlushCbs.push(...cb);