UNPKG

@webqit/oohtml

Version:

A suite of new DOM features that brings language support for modern UI development paradigms: a component-based architecture, data binding, and reactivity.

1,307 lines (1,269 loc) 243 kB
var __defProp = Object.defineProperty; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __publicField = (obj, key, value) => { __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); return value; }; var __accessCheck = (obj, member, msg) => { if (!member.has(obj)) throw TypeError("Cannot " + msg); }; var __privateGet = (obj, member, getter) => { __accessCheck(obj, member, "read from private field"); return getter ? getter.call(obj) : member.get(obj); }; var __privateAdd = (obj, member, value) => { if (member.has(obj)) throw TypeError("Cannot add the same private member more than once"); member instanceof WeakSet ? member.add(obj) : member.set(obj, value); }; var __privateSet = (obj, member, value, setter) => { __accessCheck(obj, member, "write to private field"); setter ? setter.call(obj, value) : member.set(obj, value); return value; }; // node_modules/@webqit/use-live/src/index.lite.js var index_lite_exports = {}; __export(index_lite_exports, { AsyncLiveFunction: () => AsyncLiveFunction, AsyncLiveScript: () => AsyncLiveScript, LiveFunction: () => LiveFunction, LiveModule: () => LiveModule, LiveProgramHandle: () => LiveProgramHandle, LiveScript: () => LiveScript, Observer: () => Observer, compile: () => compile2, matchPrologDirective: () => matchPrologDirective, nextKeyword: () => nextKeyword, parse: () => parse, serialize: () => serialize, transform: () => transform }); // node_modules/@webqit/observer/src/main.js var main_exports = {}; __export(main_exports, { any: () => any, apply: () => apply, batch: () => batch, construct: () => construct, defineProperties: () => defineProperties, defineProperty: () => defineProperty, deleteProperties: () => deleteProperties, deleteProperty: () => deleteProperty, get: () => get, getOwnPropertyDescriptor: () => getOwnPropertyDescriptor, getOwnPropertyDescriptors: () => getOwnPropertyDescriptors, getPrototypeOf: () => getPrototypeOf, has: () => has, intercept: () => intercept, isExtensible: () => isExtensible, map: () => map, observe: () => observe, ownKeys: () => ownKeys, path: () => path, preventExtensions: () => preventExtensions, reduce: () => reduce, set: () => set, setPrototypeOf: () => setPrototypeOf, subtree: () => subtree }); // node_modules/@webqit/util/js/isObject.js function isObject_default(val) { return !Array.isArray(val) && typeof val === "object" && val; } // node_modules/@webqit/util/js/getType.js function getType_default(val) { return typeof val; } // node_modules/@webqit/util/js/isArray.js function isArray_default(val) { return Array.isArray(val); } // node_modules/@webqit/util/js/isTypeFunction.js function isTypeFunction_default(val) { return typeof val === "function"; } // node_modules/@webqit/util/js/isNull.js function isNull_default(val) { return val === null || val === ""; } // node_modules/@webqit/util/js/isUndefined.js function isUndefined_default(val) { return arguments.length && (val === void 0 || typeof val === "undefined"); } // node_modules/@webqit/util/js/isTypeObject.js function isTypeObject_default(val) { return Array.isArray(val) || typeof val === "object" && val || isTypeFunction_default(val); } // node_modules/@webqit/util/js/isEmpty.js function isEmpty_default(val) { return isNull_default(val) || isUndefined_default(val) || val === false || val === 0 || isTypeObject_default(val) && !Object.keys(val).length; } // node_modules/@webqit/util/js/isFunction.js function isFunction_default(val) { return isTypeFunction_default(val) || val && {}.toString.call(val) === "[object function]"; } // node_modules/@webqit/util/js/isNumber.js function isNumber_default(val) { return val instanceof Number || typeof val === "number"; } // node_modules/@webqit/util/js/isNumeric.js function isNumeric_default(val) { return isNumber_default(val) || val !== true && val !== false && val !== null && val !== "" && !isNaN(val * 1); } // node_modules/@webqit/util/js/isString.js function isString_default(val) { return val instanceof String || typeof val === "string" && val !== null; } // node_modules/@webqit/util/js/isTypeArray.js function isTypeArray_default(val) { return !isString_default(val) && !isUndefined_default(val.length); } // node_modules/@webqit/util/arr/pushUnique.js function pushUnique_default(arr, ...items) { items.forEach((itm) => { if (arr.indexOf(itm) < 0) { arr.push(itm); } }); return arr; } // node_modules/@webqit/util/obj/getPrototypeChain.js function getPrototypeChain_default(obj, until) { until = until || Object.prototype; until = until && !isArray_default(until) ? [until] : until; var prototypalChain = []; var obj = obj; while (obj && (!until || until.indexOf(obj) < 0) && obj.name !== "default") { prototypalChain.push(obj); obj = obj ? Object.getPrototypeOf(obj) : null; } return prototypalChain; } // node_modules/@webqit/util/obj/getAllPropertyNames.js function getAllPropertyNames_default(obj, until) { var keysAll = []; getPrototypeChain_default(obj, until).forEach((obj2) => { pushUnique_default(keysAll, ...Object.getOwnPropertyNames(obj2)); }); return keysAll; } // node_modules/@webqit/util/obj/mergeCallback.js function mergeCallback(objs, callback, deepProps = false, isReplace = false, withSymbols = false) { var depth = 0; var obj1 = objs.shift(); if (isNumeric_default(obj1) || obj1 === true || obj1 === false) { depth = obj1; obj1 = objs.shift(); } if (!objs.length) { throw new Error("_merge() requires two or more array/objects."); } objs.forEach((obj2, i) => { if (!isTypeObject_default(obj2) && !isFunction_default(obj2)) { return; } (deepProps ? getAllPropertyNames_default(obj2) : Object.keys(obj2)).forEach((key) => { if (!callback(key, obj1, obj2, i)) { return; } var valAtObj1 = obj1[key]; var valAtObj2 = obj2[key]; if ((isArray_default(valAtObj1) && isArray_default(valAtObj2) || isObject_default(valAtObj1) && isObject_default(valAtObj2)) && (depth === true || depth > 0)) { obj1[key] = isArray_default(valAtObj1) && isArray_default(valAtObj2) ? [] : {}; mergeCallback([isNumeric_default(depth) ? depth - 1 : depth, obj1[key], valAtObj1, valAtObj2], callback, deepProps, isReplace, withSymbols); } else { if (isArray_default(obj1) && isArray_default(obj2)) { if (isReplace) { obj1[key] = valAtObj2; } else { obj1.push(valAtObj2); } } else { try { if (withSymbols) { Object.defineProperty(obj1, key, Object.getOwnPropertyDescriptor(obj2, key)); } else { obj1[key] = obj2[key]; } } catch (e) { } } } }); }); return obj1; } // node_modules/@webqit/util/obj/merge.js function merge_default(...objs) { return mergeCallback(objs, (k, obj1, obj2) => { return true; }, false, false, false); } // node_modules/@webqit/util/js/wq.js function wq(obj, ...namespaces) { if (!obj || !["object", "function"].includes(typeof obj)) { throw new Error(`Argument #1 must be of type object`); } let wq2 = obj[Symbol.for("wq")]; if (!wq2) { wq2 = new WQInternals(); Object.defineProperty(obj, Symbol.for("wq"), { value: wq2, enumerable: false, configurable: false, writable: false }); } if (!namespaces.length) { return wq2; } let _ns, _wq3; while (_ns = namespaces.shift()) { if ((_wq3 = wq2) && !(wq2 = wq2.get(_ns))) { wq2 = new WQInternals(); _wq3.set(_ns, wq2); } } return wq2; } var WQInternals = class extends Map { }; // node_modules/@webqit/util/arr/from.js function from_default(val, castObject = true) { if (isArray_default(val)) { return val; } ; if (!castObject && isObject_default(val)) { return [val]; } ; if (val !== false && val !== 0 && isEmpty_default(val)) { return []; } ; if (isTypeArray_default(val)) { return Array.prototype.slice.call(val); } ; if (isObject_default(val)) { return Object.values(val); } ; return [val]; } // node_modules/@webqit/observer/src/util.js var _wq = (target, ...args) => wq(target, "observerAPI", ...args); var _await = (value, callback) => value instanceof Promise ? value.then(callback) : callback(value); var env = {}; // node_modules/@webqit/observer/src/core/Registration.js var Registration = class { constructor(registry2, dfn) { this.registry = registry2; Object.assign(this, { ...dfn, target: registry2.target }); if (this.params.signal) { this.params.signal.addEventListener("abort", () => this.remove()); } } remove() { this.removed = true; return this.registry.removeRegistration(this); } }; // node_modules/@webqit/observer/src/core/ListenerRegistration.js var ListenerRegistration = class extends Registration { constructor() { super(...arguments); this.emit.currentRegistration = this; Object.defineProperty(this, "abortController", { value: new AbortController() }); Object.defineProperty(this, "signal", { value: this.abortController.signal }); env.setMaxListeners?.(0, this.signal); } remove() { this.abortController.abort(); super.remove(); } fire(events) { if (this.emit.recursionTarget && !["inject", "force-async", "force-sync"].includes(this.params.recursions)) return; let matches = events, filter = this.filter; if (filter !== Infinity && (filter = from_default(filter, false))) { matches = events.filter((event) => filter.includes(event.key)); } if (this.params.diff) { matches = matches.filter((event) => event.type !== "set" || event.value !== event.oldValue); } if (!matches.length) return; if (["inject", "defer"].includes(this.params.recursions)) { if (this.emit.recursionTarget) { this.emit.recursionTarget.push(...matches); return; } this.emit.recursionTarget = this.params.recursions === "inject" ? matches : []; } const $ret = this.filter === Infinity || Array.isArray(this.filter) ? this.emit(matches, this) : this.emit(matches[0], this); return _await($ret, (ret) => { const recursions = this.emit.recursionTarget; delete this.emit.recursionTarget; if (this.params.recursions === "defer") { if (recursions?.length) return this.emit.currentRegistration.fire(recursions); } return ret; }); } }; // node_modules/@webqit/observer/src/core/Registry.js var Registry = class { constructor(target) { this.target = target; this.entries = []; } addRegistration(registration) { this.entries.push(registration); return registration; } removeRegistration(registration) { this.entries = this.entries.filter((_entry) => _entry !== registration); } static _getInstance(type, target, createIfNotExists = true, namespace = this.__namespace) { if (!isTypeObject_default(target)) throw new Error(`Subject must be of type object; "${getType_default(target)}" given!`); let ImplementationClass = this; if (namespace && _wq(globalThis, "observerAPI", "namespaces").has(type + "-" + namespace)) { ImplementationClass = _wq(globalThis, "observerAPI", "namespaces").get(type + "-" + namespace); type += "-" + namespace; } if (!_wq(target, "registry").has(type) && createIfNotExists) { _wq(target, "registry").set(type, new ImplementationClass(target)); } return _wq(target, "registry").get(type); } static _namespace(type, namespace, ImplementationClass = null) { type += "-" + namespace; if (arguments.length === 2) return _wq(globalThis, "observerAPI", "namespaces").get(type); if (!(ImplementationClass.prototype instanceof this)) { throw new Error(`The implementation of the namespace ${this.name}.${namespace} must be a subclass of ${this.name}.`); } _wq(globalThis, "observerAPI", "namespaces").set(type, ImplementationClass); ImplementationClass.__namespace = namespace; } }; // node_modules/@webqit/observer/src/core/Descriptor.js var Descriptor = class { constructor(target, dfn) { this.target = target; if (!dfn.operation) throw new Error("Descriptor operation must be given in definition!"); Object.assign(this, dfn); } get [Symbol.toStringTag]() { return "Descriptor"; } static [Symbol.hasInstance](instance) { return instance?.[Symbol.toStringTag] === "Descriptor" && instance.operation; } }; // node_modules/@webqit/observer/src/core/ListenerRegistry.js var ListenerRegistry = class extends Registry { static getInstance(target, createIfNotExists = true, namespace = null) { return super._getInstance("listeners", ...arguments); } static namespace(namespace, ImplementationClass = null) { return super._namespace("listeners", ...arguments); } constructor(target) { super(target); this.batches = []; } addRegistration(filter, emit, params) { return super.addRegistration(new ListenerRegistration(this, { filter, emit, params })); } emit(events, { eventsArePropertyDescriptors = false, eventIsArrayMethodDescriptor = false } = {}) { if (this.batches.length) { const arrayMethodName = this.batches[0].params.arrayMethodName; this.batches[0].snapshots.push({ events: [...events], arrayMethodName, eventsArePropertyDescriptors, eventIsArrayMethodDescriptor }); return; } this.$emit(this.entries, [{ events, eventsArePropertyDescriptors, eventIsArrayMethodDescriptor }]); } $emit(listeners, snapshots) { let listenersLength = 0, listenersAskingEventsWithPropertyDescriptors = 0, listenersAskingArrayMethodDescriptors = 0; for (const listener of listeners) { listenersLength += 1; if (listener.params.withPropertyDescriptors) { listenersAskingEventsWithPropertyDescriptors += 1; } if (listener.params.withArrayMethodDescriptors) { listenersAskingArrayMethodDescriptors += 1; } } const events_with_PropertyDescriptors_with_ArrayMethodDescriptors = [], events_with_PropertyDescriptors_without_ArrayMethodDescriptors = []; const events_without_PropertyDescriptors_with_ArrayMethodDescriptors = [], events_without_PropertyDescriptors_without_ArrayMethodDescriptors = []; for (const snapshot of snapshots) { const arrayMethodName = snapshot.arrayMethodName; const eventsArePropertyDescriptors = snapshot.eventsArePropertyDescriptors; const eventIsArrayMethodDescriptor = snapshot.eventIsArrayMethodDescriptor; for (const event of snapshot.events) { if (arrayMethodName) { event.operation = arrayMethodName; } if (listenersAskingEventsWithPropertyDescriptors) { listenersAskingArrayMethodDescriptors && events_with_PropertyDescriptors_with_ArrayMethodDescriptors.push(event); if (!eventIsArrayMethodDescriptor) { listenersAskingArrayMethodDescriptors !== listenersLength && events_with_PropertyDescriptors_without_ArrayMethodDescriptors.push(event); } } if (listenersAskingEventsWithPropertyDescriptors !== listenersLength) { let $event = event; if (eventsArePropertyDescriptors) { const { target, type, ...details } = event; $event = new Descriptor(target, { type: "set", ...details }); Object.defineProperty($event, "value", "get" in details.value ? { get: () => details.value.get() } : { value: details.value.value }); if (details.oldValue) { Object.defineProperty($event, "oldValue", "get" in details.oldValue ? { get: () => details.oldValue.get() } : { value: details.oldValue.value }); } } listenersAskingArrayMethodDescriptors && events_without_PropertyDescriptors_with_ArrayMethodDescriptors.push($event); if (!eventIsArrayMethodDescriptor) { listenersAskingArrayMethodDescriptors !== listenersLength && events_without_PropertyDescriptors_without_ArrayMethodDescriptors.push($event); } } } } for (const listener of listeners) { if (listener.params.withPropertyDescriptors) { if (listener.params.withArrayMethodDescriptors) { events_with_PropertyDescriptors_with_ArrayMethodDescriptors.length && listener.fire(events_with_PropertyDescriptors_with_ArrayMethodDescriptors); } else { events_with_PropertyDescriptors_without_ArrayMethodDescriptors.length && listener.fire(events_with_PropertyDescriptors_without_ArrayMethodDescriptors); } } else { if (listener.params.withArrayMethodDescriptors) { events_without_PropertyDescriptors_with_ArrayMethodDescriptors.length && listener.fire(events_without_PropertyDescriptors_with_ArrayMethodDescriptors); } else { events_without_PropertyDescriptors_without_ArrayMethodDescriptors.length && listener.fire(events_without_PropertyDescriptors_without_ArrayMethodDescriptors); } } } } batch(callback, params = {}) { this.batches.unshift({ entries: [...this.entries], snapshots: [], params }); const returnValue = callback(); return _await(returnValue, (returnValue2) => { const batch2 = this.batches.shift(); if (!batch2.snapshots.length) return returnValue2; this.$emit(batch2.entries, batch2.snapshots); return returnValue2; }); } }; // node_modules/@webqit/observer/src/core/TrapsRegistration.js var TrapsRegistration = class extends Registration { exec(descriptor, next, recieved) { if (this.running || !this.traps[descriptor.operation]) { return next(...Array.prototype.slice.call(arguments, 2)); } this.running = true; return this.traps[descriptor.operation](descriptor, recieved, (...args) => { this.running = false; return next(...args); }); } }; // node_modules/@webqit/observer/src/core/TrapsRegistry.js var TrapsRegistry = class extends Registry { static getInstance(target, createIfNotExists = true, namespace = null) { return super._getInstance("traps", ...arguments); } static namespace(namespace, ImplementationClass = null) { return super._namespace("traps", ...arguments); } addRegistration(dfn) { return super.addRegistration(new TrapsRegistration(this, dfn)); } emit(descriptor, defaultHandler = null) { const $this = this; return function next(index, ..._args) { const registration = $this.entries[index]; if (registration) { return registration.exec(descriptor, (...args) => { return next(index + 1, ...args); }, ..._args); } return defaultHandler ? defaultHandler(descriptor, ..._args) : _args[0]; }(0); } }; // node_modules/@webqit/observer/src/actors.js var actors_exports = {}; __export(actors_exports, { accessorize: () => accessorize, proxy: () => proxy, unaccessorize: () => unaccessorize, unproxy: () => unproxy }); var symWQOriginal = Symbol("wqOriginal"); function accessorize(target, props, params = {}) { target = resolveTarget(target); const accessorizedProps = _wq(target, "accessorizedProps"); function getDescriptorDeep(prop) { let descriptor, proto = target; do { descriptor = Object.getOwnPropertyDescriptor(proto, prop); } while (!descriptor && (proto = Object.getPrototypeOf(proto))); return descriptor ? { proto, descriptor } : { descriptor: { value: void 0, configurable: true, enumerable: true, writable: true } }; } function accessorizeProp(prop) { if (accessorizedProps.has(prop + "")) return true; const currentDescriptorRecord = getDescriptorDeep(prop); currentDescriptorRecord.getValue = function(withPropertyDescriptors = false) { if (withPropertyDescriptors) return this.descriptor; return this.descriptor.get ? this.descriptor.get() : this.descriptor.value; }; currentDescriptorRecord.setValue = function(value, withPropertyDescriptors = false) { this.dirty = true; if (withPropertyDescriptors) { this.descriptor = value; return; } return this.descriptor.set ? this.descriptor.set(value) !== false : (this.descriptor.value = value, true); }; currentDescriptorRecord.intact = function() { const currentDescriptor = Object.getOwnPropertyDescriptor(target, prop); return currentDescriptor?.get === accessorization.get && currentDescriptor?.set === accessorization.set && accessorizedProps.get(prop + "") === this; }; currentDescriptorRecord.restore = function() { if (!this.intact()) return false; if (this.proto && this.proto !== target || !this.proto && !this.dirty) { delete target[prop]; } else { Object.defineProperty(target, prop, this.descriptor); } accessorizedProps.delete(prop + ""); return true; }; accessorizedProps.set(!isNaN(prop) ? parseInt(prop) : prop, currentDescriptorRecord); const { enumerable = true } = currentDescriptorRecord.descriptor; const accessorization = { enumerable, configurable: true }; if ("value" in currentDescriptorRecord.descriptor || currentDescriptorRecord.descriptor.set) { accessorization.set = function(value) { return set(this, prop, value, params); }; } if ("value" in currentDescriptorRecord.descriptor || currentDescriptorRecord.descriptor.get) { accessorization.get = function() { return get(this, prop, params); }; } try { Object.defineProperty(target, prop, accessorization); return true; } catch (e) { accessorizedProps.delete(prop + ""); return false; } } const _props = Array.isArray(props) ? props : props === void 0 ? Object.keys(target) : [props]; const statuses = _props.map(accessorizeProp); return props === void 0 || Array.isArray(props) ? statuses : statuses[0]; } function unaccessorize(target, props, params = {}) { target = resolveTarget(target); const accessorizedProps = _wq(target, "accessorizedProps"); function unaccessorizeProp(prop) { if (!accessorizedProps.has(prop + "")) return true; return accessorizedProps.get(prop + "").restore(); } const _props = Array.isArray(props) ? props : props === void 0 ? Object.keys(target) : [props]; const statuses = _props.map(unaccessorizeProp); return props === void 0 || Array.isArray(props) ? statuses : statuses[0]; } function proxy(target, params = {}, extendCallback = void 0) { const originalTarget = resolveTarget(target); if (typeof params.membrane === "boolean") throw new Error(`The params.membrane parameter cannot be of type boolean.`); if (params.membrane && _wq(originalTarget, "membraneRef").has(params.membrane)) { return _wq(originalTarget, "membraneRef").get(params.membrane); } const traps = { apply: (target2, thisArgument, argumentsList) => apply(target2, thisArgument, argumentsList, void 0, params), construct: (target2, argumentsList, newTarget = null) => construct(target2, argumentsList, newTarget, params), defineProperty: (target2, propertyKey, attributes) => defineProperty(target2, propertyKey, attributes, params), deleteProperty: (target2, propertyKey) => deleteProperty(target2, propertyKey, params), get: (target2, propertyKey, receiver = null) => { if (propertyKey === symWQOriginal) { return originalTarget; } const $params = { ...params, receiver }; const returnValue = get(target2, propertyKey, $params); if (Array.isArray(target2) && typeof returnValue === "function" && !/^class\s?/.test(Function.prototype.toString.call(returnValue))) { return proxy(returnValue, { ...params, arrayMethodName: propertyKey, membrane: receiver }, extendCallback); } if (params.chainable && isTypeObject_default(returnValue) && propertyKey !== "prototype" && !(typeof returnValue === "function" && /^class\s?|\{\s\[native\scode\]\s\}$/.test(Function.prototype.toString.call(returnValue)))) { return proxy(returnValue, params, extendCallback); } return returnValue; }, getOwnPropertyDescriptor: (target2, propertyKey) => getOwnPropertyDescriptor(target2, propertyKey, params), getPrototypeOf: (target2) => getPrototypeOf(target2, params), has: (target2, propertyKey) => has(target2, propertyKey, params), isExtensible: (target2) => isExtensible(target2, params), ownKeys: (target2) => ownKeys(target2, params), preventExtensions: (target2) => preventExtensions(target2, params), set: (target2, propertyKey, value, receiver = null) => set(target2, propertyKey, value, { ...params, receiver }), setPrototypeOf: (target2, prototype) => setPrototypeOf(target2, prototype, params) }; const $traps = extendCallback?.(traps) || traps; const $proxy = new Proxy(originalTarget, $traps); if (params.membrane) { _wq(originalTarget, "membraneRef").set(params.membrane, $proxy); } return $proxy; } function unproxy(target) { return target && target[symWQOriginal] || target; } function resolveTarget(target) { if (!target || !isTypeObject_default(target)) throw new Error("Target must be of type object!"); return unproxy(target); } // node_modules/@webqit/observer/src/main.js var Path = class extends Array { get [Symbol.toStringTag]() { return "Path"; } static [Symbol.hasInstance](instance) { return Array.isArray(instance) && instance[Symbol.toStringTag] === "Path"; } }; function path(...segments) { return new Path(...segments); } var Subtree = class extends Array { get [Symbol.toStringTag]() { return "Subtree"; } static [Symbol.hasInstance](instance) { return Array.isArray(instance) && instance[Symbol.toStringTag] === "Subtree"; } }; function subtree() { return new Subtree(); } function any() { return Infinity; } function reduce(target, path2, receiver, final = (x) => x, params = {}) { const _isSubtree = path2 instanceof Subtree; if (!_isSubtree && !path2?.length) return; return function eat(target2, path3, $params, $isSubtree) { const isSubtree = $isSubtree || path3[$params.level] instanceof Subtree; const segment = isSubtree ? Infinity : path3[$params.level]; const isLastSegment = isSubtree ? false : $params.level === path3.length - 1; if (target2 instanceof Descriptor && target2.operation !== "get") { $params = { ...$params, probe: "always" }; } else if ($params.probe !== "always") { $params = { ...$params, probe: !isLastSegment }; } return receiver(target2, segment, (result, ...args) => { const addTrail = (desc) => { if (!(desc instanceof Descriptor)) return; desc.path = "key" in desc ? [desc.key] : []; if (target2 instanceof Descriptor) { desc.path = "key" in desc ? target2.path.concat(desc.key) : target2.path.slice(0); Object.defineProperty(desc, "context", { get: () => target2, configurable: true }); } }; const flags = args[0] || {}; const advance = (result2) => { if (result2 instanceof Descriptor && "argumentsList" in result2) { return; } const $value = resolveObj(result2, false); return _await($value, ($value2) => { if (result2 instanceof Descriptor) { result2.value = $value2; } else { result2 = $value2; } return eat(result2, path3, { ...$params, ...flags, keyInParent: result2.key, level: $params.level + 1 }, isSubtree); }); }; if (isPropsList(segment) && Array.isArray(result)) { result.forEach(addTrail); if (isLastSegment) { return final(result, ...args); } if (isSubtree && result[0] instanceof Descriptor && (result[0].operation !== "get" || params.asGet)) { final(result, ...args); } for (const entry of result) { advance(entry); } return; } addTrail(result); if (isLastSegment) { return final(result, ...args); } return advance(result); }, $params); }(target, path2.slice(0), { ...params, level: 0 }, _isSubtree); } function observe(target, prop, receiver, params = {}) { const originalTarget = resolveObj(target, !params.level); if (isFunction_default(arguments[1])) { [, receiver, params = {}] = arguments; prop = Infinity; } if (!isFunction_default(receiver)) throw new Error(`Handler must be a function; "${getType_default(receiver)}" given!`); if (prop instanceof Path || prop instanceof Subtree) return reduce(originalTarget, prop, observe, receiver, params); params = { ...params, descripted: true }; delete params.live; if (!isTypeObject_default(originalTarget)) return params.probe && get(originalTarget, prop, receiver, params) || void 0; const emit = bind(originalTarget, prop, receiver, params); if (params.probe) { return get(originalTarget, prop, emit, params); } return emit(); } function intercept(target, traps, params = {}) { const originalTarget = resolveObj(target); if (!isObject_default(traps)) { [, , , params = {}] = arguments; traps = { [arguments[1]]: arguments[2] }; } return TrapsRegistry.getInstance(originalTarget, true, params.namespace).addRegistration({ traps, params }); } function getOwnPropertyDescriptor(target, prop, receiver = (x) => x, params = {}) { return exec(target, "getOwnPropertyDescriptor", { key: prop }, receiver, params); } function getOwnPropertyDescriptors(target, prop, receiver = (x) => x, params = {}) { return exec(target, "getOwnPropertyDescriptors", { key: prop }, receiver, params); } function getPrototypeOf(target, receiver = (x) => x, params = {}) { return exec(target, "getPrototypeOf", {}, receiver, params); } function isExtensible(target, receiver = (x) => x, params = {}) { return exec(target, "isExtensible", {}, receiver, params); } function ownKeys(target, receiver = (x) => x, params = {}) { return exec(target, "ownKeys", {}, receiver, params); } function has(target, prop, receiver = (x) => x, params = {}) { return exec(target, "has", { key: prop }, receiver, params); } function get(target, prop, receiver = (x) => x, params = {}) { let isLive; const originalTarget = resolveObj(target, !params.level); if (isObject_default(receiver)) { [params, receiver] = [receiver, (x) => x]; } else if (params.live) { isLive = true; } if (prop instanceof Path || prop instanceof Subtree) return reduce(originalTarget, prop, get, receiver, { ...params, asGet: true }); return resolveProps(originalTarget, prop, (props) => { const related = [...props]; return function next(results, _props, _done) { if (!_props.length) return _done(results); const prop2 = _props.shift(); if (!["string", "number", "symbol"].includes(typeof prop2)) { throw new Error(`Property name/key ${prop2} invalid.`); } function defaultGet(descriptor2, value = void 0) { const _next = (value2) => (descriptor2.value = value2, next([...results, params.live || params.descripted ? descriptor2 : value2], _props, _done)); if (arguments.length > 1) return _next(value); if (!isTypeObject_default(originalTarget)) return _next(originalTarget?.[descriptor2.key]); const accessorizedProps = _wq(originalTarget, "accessorizedProps", false); const accessorization = accessorizedProps && accessorizedProps.get(descriptor2.key); if (accessorization && accessorization.intact()) { return _next(accessorization.getValue(params.withPropertyDescriptors)); } if (params.withPropertyDescriptors) { const desc = Object.getOwnPropertyDescriptor(originalTarget, descriptor2.key); return _next(desc); } return _next(Reflect.get(originalTarget, descriptor2.key)); } const descriptor = new Descriptor(originalTarget, { type: "get", key: prop2, value: void 0, operation: "get", related }); if (!isTypeObject_default(originalTarget)) return defaultGet(descriptor); const trapsRegistry = TrapsRegistry.getInstance(originalTarget, false, params.namespace); if (trapsRegistry) { return trapsRegistry.emit(descriptor, defaultGet); } return defaultGet(descriptor); }([], props.slice(0), (results) => { const result_s = isPropsList(prop) ? results : results[0]; if (isLive && isTypeObject_default(originalTarget)) { const emit = bind(originalTarget, prop, receiver, params, target.key); return emit(result_s); } return receiver(result_s); }); }, params); } function batch(target, callback, params = {}) { const originalTarget = resolveObj(target); return ListenerRegistry.getInstance(originalTarget, true, params.namespace).batch(callback, params); } function map(source, target, params = {}) { target = resolveObj(target); source = resolveObj(source); const only = (params.only || []).slice(0), except = (params.except || []).slice(0); const sourceKeys = Object.keys(params.spread ? [...source] : source).map((k) => !isNaN(k) ? parseInt(k) : k); const filteredKeys = only.length ? only.filter((k) => sourceKeys.includes(k)) : sourceKeys.filter((k) => !except.includes(k)); const resolveKey = (k) => { if (!Array.isArray(target) || isNaN(k)) return k; return k - except.filter((i) => i < k).length; }; const doSet = (key) => { const descriptor = getOwnPropertyDescriptor(source, key, params); if ("value" in descriptor && descriptor.writable && descriptor.enumerable && descriptor.configurable) { set(target, resolveKey(key), descriptor.value, params); } else if (descriptor.enumerable || params.onlyEnumerable === false) { defineProperty(target, key, { ...descriptor, configurable: true }, params); } }; batch(target, () => { filteredKeys.forEach(doSet); }); return observe(source, (mutations) => { mutations.filter((m) => only.length ? only.includes(m.key) : !except.includes(m.key)).forEach((m) => { if (m.type === "delete") return deleteProperty(target, resolveKey(m.key), params); if (m.type === "def") { if (m.value.enumerable || params.onlyEnumerable === false) { defineProperty(target, resolveKey(m.key), { ...m.value, configurable: true }, params); } return; } doSet(m.key); }); }, { ...params, withPropertyDescriptors: true }); } function set(target, prop, value, receiver = (x) => x, params = {}, def = false) { const originalTarget = resolveObj(target); let entries = [[prop, value]]; if (isObject_default(prop)) { [, , receiver = (x) => x, params = {}, def = false] = arguments; entries = Object.entries(prop); } if (isObject_default(receiver)) { [def, params, receiver] = [typeof params === "boolean" ? params : def, receiver, (x) => x]; } const related = entries.map(([prop2]) => prop2); return function next(descriptors, entries2, _done) { if (!entries2.length) return _done(descriptors); const [prop2, value2] = entries2.shift(); function defaultSet(descriptor, status = void 0) { const _next = (status2) => (descriptor.status = status2, next(descriptors.concat(descriptor), entries2, _done)); if (arguments.length > 1) return _next(descriptor, status); const accessorizedProps = _wq(originalTarget, "accessorizedProps", false); const accessorization = accessorizedProps && accessorizedProps.get(descriptor.key); if (descriptor.type === "def") { if (accessorization && !accessorization.restore()) _next(false); Object.defineProperty(originalTarget, descriptor.key, descriptor.value); return _next(true); } if (accessorization && accessorization.intact()) { return _next(accessorization.setValue(descriptor.value)); } return _next(Reflect.set(originalTarget, descriptor.key, descriptor.value)); } function exec3(isUpdate, oldValue) { if (params.diff && value2 === oldValue) return next(descriptors, entries2, _done); const descriptor = new Descriptor(originalTarget, { type: def ? "def" : "set", key: prop2, value: value2, isUpdate, oldValue, related: [...related], operation: def ? "defineProperty" : "set", detail: params.detail }); const trapsRegistry = TrapsRegistry.getInstance(originalTarget, false, params.namespace); return trapsRegistry ? trapsRegistry.emit(descriptor, defaultSet) : defaultSet(descriptor); } return has(originalTarget, prop2, (exists) => { if (!exists) return exec3(exists); if (prop2 === "length" && Array.isArray(originalTarget) && _wq(originalTarget).has("$length")) { return exec3(true, _wq(originalTarget).get("$length")); } const $params = { ...params, withPropertyDescriptors: def }; return get(originalTarget, prop2, (oldValue) => exec3(exists, oldValue), $params); }, params); }([], entries.slice(0), (descriptors) => { const listenerRegistry = ListenerRegistry.getInstance(originalTarget, false, params.namespace); if (listenerRegistry) listenerRegistry.emit(descriptors, { eventsArePropertyDescriptors: !!def }); return receiver( isPropsList(prop) ? descriptors.map((opr) => opr.status) : descriptors[0]?.status ); }); } function defineProperty(target, prop, descriptor, receiver = (x) => x, params = {}) { return set(target, prop, descriptor, receiver, params, true); } function defineProperties(target, descriptors, receiver = (x) => x, params = {}) { return set(target, descriptors, receiver, params, true); } function deleteProperty(target, prop, receiver = (x) => x, params = {}) { const originalTarget = resolveObj(target); if (isObject_default(receiver)) { [params, receiver] = [receiver, (x) => x]; } const props = from_default(prop, false), related = [...props]; return function next(descriptors, props2, _done) { if (!props2.length) return _done(descriptors); const prop2 = props2.shift(); function defaultDel(descriptor, status = void 0) { const _next = (status2) => (descriptor.status = status2, next(descriptors.concat(descriptor), props2, _done)); if (arguments.length > 1) return _next(descriptor, status); const accessorizedProps = _wq(originalTarget, "accessorizedProps", false); const accessorization = accessorizedProps && accessorizedProps.get(descriptor.key); if (accessorization && !accessorization.restore()) _next(false); return _next(Reflect.deleteProperty(originalTarget, descriptor.key)); } function exec3(oldValue) { const descriptor = new Descriptor(originalTarget, { type: "delete", key: prop2, oldValue, related: [...related], operation: "deleteProperty", detail: params.detail }); const trapsRegistry = TrapsRegistry.getInstance(originalTarget, false, params.namespace); return trapsRegistry ? trapsRegistry.emit(descriptor, defaultDel) : defaultDel(descriptor); } return get(originalTarget, prop2, exec3, params); }([], props.slice(0), (descriptors) => { const listenerRegistry = ListenerRegistry.getInstance(originalTarget, false, params.namespace); if (listenerRegistry) listenerRegistry.emit(descriptors); return receiver( isPropsList(prop) ? descriptors.map((opr) => opr.status) : descriptors[0].status ); }); } function deleteProperties(target, props, receiver = (x) => x, params = {}) { return deleteProperty(...arguments); } function construct(target, argumentsList, newTarget = null, receiver = (x) => x, params = {}) { return exec(target, "construct", arguments.length > 2 ? { argumentsList, newTarget } : { argumentsList }, receiver, params); } function apply(target, thisArgument, argumentsList, receiver = (x) => x, params = {}) { const originalThis = unproxy(thisArgument); let returnValue; if (Array.isArray(thisArgument)) { if (params.arrayMethodName) { const descriptor = new Descriptor(originalThis, { operation: params.arrayMethodName, argumentsList }); const listenerRegistry = ListenerRegistry.getInstance(originalThis, false, params.namespace); listenerRegistry?.emit([descriptor], { eventIsArrayMethodDescriptor: true }); } _wq(originalThis).set("$length", originalThis.length); returnValue = batch( originalThis, () => exec(target, "apply", { thisArgument, argumentsList }, receiver, params), params ); _wq(originalThis).delete("$length"); } else { returnValue = exec(target, "apply", { thisArgument: originalThis, argumentsList }, receiver, params); } return returnValue; } function setPrototypeOf(target, proto, receiver = (x) => x, params = {}) { return exec(target, "setPrototypeOf", { proto }, receiver, params); } function preventExtensions(target, receiver = (x) => x, params = {}) { return exec(target, "preventExtensions", {}, receiver, params); } function bind(target, prop, receiver, params = {}) { const controller = new AbortController(); env.setMaxListeners?.(0, controller.signal); if (params.signal) { params.signal.addEventListener("abort", () => controller.abort()); } const $params = { ...params, signal: controller.signal }; const listenerRegistry = ListenerRegistry.getInstance(target, true, $params.namespace); const childRegistrations = /* @__PURE__ */ new Map(); return function emit(descriptor_s = [], prevRegistration = null) { let flags, registrationNext, isExisting; if (isPropsList(prop)) { if (prevRegistration) { isExisting = true; registrationNext = prevRegistration; for (const descriptor of descriptor_s) { childRegistrations.get(descriptor.key)?.remove(); childRegistrations.delete(descriptor.key); } } else { registrationNext = listenerRegistry.addRegistration(prop, emit, $params); } flags = { signal: registrationNext.signal, childRegistrations }; } else { prevRegistration?.remove(); registrationNext = listenerRegistry.addRegistration(prop, emit, $params); flags = { signal: registrationNext.signal }; } if ($params.childRegistrations && $params.keyInParent) { $params.childRegistrations.set($params.keyInParent, registrationNext); } if (arguments.length) { const handlerReturnValue = receiver(descriptor_s, flags); if (arguments.length > 1) return handlerReturnValue; } return controller; }; } function exec(target, operation, payload = {}, receiver = (x) => x, params = {}) { target = resolveObj(target); if (isObject_default(receiver)) { [params, receiver] = [receiver, (x) => x]; } function defaultExec(descriptor2, result) { if (arguments.length > 1) return receiver(result); return receiver((Reflect[operation] || Object[operation])(target, ...Object.values(payload))); } const descriptor = new Descriptor(target, { operation, ...payload }); const trapsRegistry = TrapsRegistry.getInstance(target, false, params.namespace); if (trapsRegistry) { return trapsRegistry.emit(descriptor, defaultExec); } return defaultExec(descriptor); } function isPropsList(prop) { return prop === Infinity || Array.isArray(prop); } function resolveObj(obj, assert = true, probePropertyDescriptors = true) { if ((!obj || !isTypeObject_default(obj)) && assert) throw new Error(`Object must be of type object or array! "${getType_default(obj)}" given.`); if (obj instanceof Descriptor) { if (obj.type === "def" && probePropertyDescriptors) { obj = typeof obj.value.get === "function" ? obj.value.get() : obj.value.value; } else { obj = obj.value; } } return obj && unproxy(obj); } function resolveProps(obj, prop, receiver, params = {}) { if (prop === Infinity) { if (params.level && !isTypeObject_default(obj)) return receiver([]); return receiver(Object.entries(Object.getOwnPropertyDescriptors(obj)).filter(([, p]) => p.writable !== false && !p.get && !p.set).map(([name]) => name)); } return receiver(from_default(prop, false)); } // node_modules/@webqit/observer/src/index.js var Observer = { ...main_exports, ...actors_exports }; // node_modules/@webqit/use-live/src/runtime/LiveProgramHandle.js var LiveProgramHandle = class { constructor(runtime) { Object.defineProperty(this, Symbol.toStringTag, { value: "LiveProgramHandle" }); Object.defineProperty(this, "runtime", { value: runtime }); const events = { statechange: () => { Observer.defineProperty(this, "value", { value: runtime.flowControl.get("return")?.arg, enumerable: true, configurable: true }); } }; for (const name in events) { runtime.on(name, events[name]); events[name](); } if (runtime.$params.sourceType === "module") { Object.defineProperty(this, "exports", { value: runtime.exports }); } } abort() { return this.runtime.abort(true); } }; // node_modules/@webqit/use-live/src/util.js var _call = (_function, ...args) => { const callback = args.pop(); if (_function.constructor.name === "AsyncFunction") return _await2(_function.call(...args), callback); try { return callback(_function.call(...args)); } catch (e) { return callback(void 0, e); } }; var _await2 = (maybePromise, callback) => { return maybePromise instanceof Promise ? maybePromise.then(callback).catch((e) => callback(void 0, e)) : callback(maybePromise); }; var _isTypeObject = (val) => { return typeof val === "object" && val || typeof val === "function"; }; function _$functionArgs(args) { const params = typeof args[args.length - 1] === "object" ? args.pop() : {}; const source = args.pop() || ""; return { source, args, params }; } var env2 = {}; function matchPrologDirective(str, strictStart = false) { if (strictStart) return /^(["'])use live\1\s*(;|$)/.test(str); return /(["'])use live\1\s*(;|$)/.test(str); } function nextKeyword(input, start = 0, mode = null) { let i = start; const l = input.length; const skipWS = () => { while (i < l && /\s/.test(input[i])) i++; }; const skipLineComment = () => { i += 2; while (i < l && input[i] !== "\n" && input[i] !== "\r") i++; }; const skipBlockComment = () => { i += 2; while (i < l && !(input[i] === "*" && input[i + 1] === "/")) i++; if (i < l) i += 2; }; while (i < l) { skipWS(); if (input[i] === "/" && input[i + 1] === "/") { skipLineComment(); continue; } if (input[i] === "/" && input[i + 1] === "*") { skipBlockComment(); continue; } break; } if (mode === 0) return input.slice(i); const startIdent = i; if (i < l && /[A-Za-z$_]/.test(input[i])) { i++; while (i < l && /[A-Za-z0-9$_]/.test(input[i])) i++; return input.slice(startIdent, i); } if (mode === 1 && i < l) { return input[i]; } return null; } // node_modules/@webqit/use-live/src/params.js function resolveParams(...extensions) { let extension, params = { runtimeParams, transformerParams, parserParams }; while (extension = extensions.shift()) { const { runtimeParams: _runtimeParams = {}, transformerParams: { globalsNoObserve: _globalsNoObserve = [], globalsOnlyPathsExcept: _globalsOnlyPathsExcept = [], ..._transformerParams } = {}, parserParams: _parserParams = {} } = extension; params = { runtimeParams: { ...params.runtimeParams, ..._runtimeParams }, transformerParams: { ...params.transformerParams, globalsNoObserve: [...params.transformerParams.globalsNoObserve, ..._globalsNoObserve], globalsOnlyPathsExcept: [...params.transformerParams.globalsOnlyPathsExcept, ..._globalsOnlyPathsExcept], ..._transformerParams }, parserParams: { ...params.parserParams, ..._parserParams } }; if (extensions.devMode) { } } return params; } var parserParams = { ecmaVersion: "latest", allowReturnOutsideFunction: true, allowAwaitOutsideFunction: false, allowSuperOutsideMethod: false, preserveParens: false, locations: true }; var transformerParams = { globalsNoObserve: ["arguments", "debugger"], globalsOnlyPathsExcept: [], originalSource: true, locations: true, compact: 2 }; var runtimeParams = { apiVersion: 3 }; // node_modules/@webqit/use-live/src/transformer/Node.js var Node_default = { throwStmt(argument) { return { type: "ThrowStatement", argument }; }, tryStmt(block, handler, finalizer, guardedHandlers) { return { type: "TryStatement", block, handler, finalizer, guardedHandlers }; }, catchClause(param, body) { return { type: "CatchClause", param, body }; }, exprStmt(expression) { return { type: "ExpressionStatement", expression }; }, blockStmt(body) { return { type: "BlockStatement", body }; }, labeledStmt(label, body) { return { type: "LabeledStatement", label, body }; }, withStmt(object, body) { return { type: "WithStatement", object, body }; },