app/assets/build/coco/coco.js in coveragebook_components-0.17.1 vs app/assets/build/coco/coco.js in coveragebook_components-0.17.2

- old
+ new

@@ -7174,10 +7174,11 @@ } } }); var module_exports = {}; __export2(module_exports, { + Alpine: () => src_default, default: () => module_default }); module.exports = __toCommonJS(module_exports); var flushPending = false; var flushing = false; @@ -7260,10 +7261,28 @@ }; return [wrappedEffect, () => { cleanup(); }]; } + function watch(getter, callback) { + let firstTime = true; + let oldValue; + let effectReference = effect(() => { + let value = getter(); + JSON.stringify(value); + if (!firstTime) { + queueMicrotask(() => { + callback(value, oldValue); + oldValue = value; + }); + } else { + oldValue = value; + } + firstTime = false; + }); + return () => release(effectReference); + } function dispatch(el, name, detail = {}) { el.dispatchEvent( new CustomEvent(name, { detail, bubbles: true, @@ -7419,26 +7438,22 @@ function stopObservingMutations() { flushObserver(); observer.disconnect(); currentlyObserving = false; } - var recordQueue = []; - var willProcessRecordQueue = false; + var queuedMutations = []; function flushObserver() { - recordQueue = recordQueue.concat(observer.takeRecords()); - if (recordQueue.length && !willProcessRecordQueue) { - willProcessRecordQueue = true; - queueMicrotask(() => { - processRecordQueue(); - willProcessRecordQueue = false; - }); - } + let records = observer.takeRecords(); + queuedMutations.push(() => records.length > 0 && onMutate(records)); + let queueLengthWhenTriggered = queuedMutations.length; + queueMicrotask(() => { + if (queuedMutations.length === queueLengthWhenTriggered) { + while (queuedMutations.length > 0) + queuedMutations.shift()(); + } + }); } - function processRecordQueue() { - onMutate(recordQueue); - recordQueue.length = 0; - } function mutateDom(callback) { if (!currentlyObserving) return callback(); stopObservingMutations(); let result = callback(); @@ -7458,20 +7473,20 @@ function onMutate(mutations) { if (isCollecting) { deferredMutations = deferredMutations.concat(mutations); return; } - let addedNodes = []; - let removedNodes = []; + let addedNodes = /* @__PURE__ */ new Set(); + let removedNodes = /* @__PURE__ */ new Set(); let addedAttributes = /* @__PURE__ */ new Map(); let removedAttributes = /* @__PURE__ */ new Map(); for (let i2 = 0; i2 < mutations.length; i2++) { if (mutations[i2].target._x_ignoreMutationObserver) continue; if (mutations[i2].type === "childList") { - mutations[i2].addedNodes.forEach((node) => node.nodeType === 1 && addedNodes.push(node)); - mutations[i2].removedNodes.forEach((node) => node.nodeType === 1 && removedNodes.push(node)); + mutations[i2].addedNodes.forEach((node) => node.nodeType === 1 && addedNodes.add(node)); + mutations[i2].removedNodes.forEach((node) => node.nodeType === 1 && removedNodes.add(node)); } if (mutations[i2].type === "attributes") { let el = mutations[i2].target; let name = mutations[i2].attributeName; let oldValue = mutations[i2].oldValue; @@ -7500,21 +7515,21 @@ }); addedAttributes.forEach((attrs, el) => { onAttributeAddeds.forEach((i2) => i2(el, attrs)); }); for (let node of removedNodes) { - if (addedNodes.includes(node)) + if (addedNodes.has(node)) continue; onElRemoveds.forEach((i2) => i2(node)); destroyTree(node); } addedNodes.forEach((node) => { node._x_ignoreSelf = true; node._x_ignore = true; }); for (let node of addedNodes) { - if (removedNodes.includes(node)) + if (removedNodes.has(node)) continue; if (!node.isConnected) continue; delete node._x_ignoreSelf; delete node._x_ignore; @@ -7688,11 +7703,14 @@ } catch (e2) { handleError(e2, el, expression); } } function handleError(error2, el, expression = void 0) { - Object.assign(error2, { el, expression }); + error2 = Object.assign( + error2 != null ? error2 : { message: "No error message given." }, + { el, expression } + ); console.warn(`Alpine Expression Error: ${error2.message} ${expression ? 'Expression: "' + expression + '"\n\n' : ""}`, el); setTimeout(() => { throw error2; @@ -7804,13 +7822,11 @@ function directive(name, callback) { directiveHandlers[name] = callback; return { before(directive2) { if (!directiveHandlers[directive2]) { - console.warn( - "Cannot find directive `${directive}`. `${name}` will use the default order of execution" - ); + console.warn(String.raw`Cannot find directive \`${directive2}\`. \`${name}\` will use the default order of execution`); return; } const pos = directiveOrder.indexOf(directive2); directiveOrder.splice(pos >= 0 ? pos : directiveOrder.indexOf("DEFAULT"), 0, name); } @@ -8600,29 +8616,29 @@ }; } function entangle({ get: outerGet, set: outerSet }, { get: innerGet, set: innerSet }) { let firstRun = true; let outerHash; + let innerHash; let reference = effect(() => { - const outer = outerGet(); - const inner = innerGet(); + let outer = outerGet(); + let inner = innerGet(); if (firstRun) { innerSet(cloneIfObject(outer)); firstRun = false; - outerHash = JSON.stringify(outer); } else { - const outerHashLatest = JSON.stringify(outer); + let outerHashLatest = JSON.stringify(outer); + let innerHashLatest = JSON.stringify(inner); if (outerHashLatest !== outerHash) { innerSet(cloneIfObject(outer)); - outerHash = outerHashLatest; - } else { + } else if (outerHashLatest !== innerHashLatest) { outerSet(cloneIfObject(inner)); - outerHash = JSON.stringify(inner); + } else { } } - JSON.stringify(innerGet()); - JSON.stringify(outerGet()); + outerHash = JSON.stringify(outerGet()); + innerHash = JSON.stringify(innerGet()); }); return () => { release(reference); }; } @@ -8727,11 +8743,11 @@ return effect; }, get raw() { return raw; }, - version: "3.13.3", + version: "3.13.5", flushAndStopDeferringMutations, dontAutoEvaluateFunctions, disableEffectScheduling, startObservingMutations, stopObservingMutations, @@ -8780,35 +8796,28 @@ // INTERNAL cloneNode, // INTERNAL bound: getBinding, $data: scope, + watch, walk, data, bind: bind2 }; var alpine_default2 = Alpine3; - var import_reactivity9 = __toESM2(require_reactivity()); + var import_reactivity10 = __toESM2(require_reactivity()); magic("nextTick", () => nextTick); magic("dispatch", (el) => dispatch.bind(dispatch, el)); - magic("watch", (el, { evaluateLater: evaluateLater2, effect: effect3 }) => (key, callback) => { + magic("watch", (el, { evaluateLater: evaluateLater2, cleanup }) => (key, callback) => { let evaluate2 = evaluateLater2(key); - let firstTime = true; - let oldValue; - let effectReference = effect3(() => evaluate2((value) => { - JSON.stringify(value); - if (!firstTime) { - queueMicrotask(() => { - callback(value, oldValue); - oldValue = value; - }); - } else { - oldValue = value; - } - firstTime = false; - })); - el._x_effects.delete(effectReference); + let getter = () => { + let value; + evaluate2((i2) => value = i2); + return value; + }; + let unwatch = watch(getter, callback); + cleanup(unwatch); }); magic("store", getStores); magic("data", (el) => scope(el)); magic("root", (el) => closestRoot(el)); magic("refs", (el) => { @@ -8843,15 +8852,35 @@ if (!el._x_ids) el._x_ids = {}; if (!el._x_ids[name]) el._x_ids[name] = findAndIncrementId(name); } - magic("id", (el) => (name, key = null) => { - let root = closestIdRoot(el, name); - let id = root ? root._x_ids[name] : findAndIncrementId(name); - return key ? `${name}-${id}-${key}` : `${name}-${id}`; + magic("id", (el, { cleanup }) => (name, key = null) => { + let cacheKey = `${name}${key ? `-${key}` : ""}`; + return cacheIdByNameOnElement(el, cacheKey, cleanup, () => { + let root = closestIdRoot(el, name); + let id = root ? root._x_ids[name] : findAndIncrementId(name); + return key ? `${name}-${id}-${key}` : `${name}-${id}`; + }); }); + interceptClone((from, to) => { + if (from._x_id) { + to._x_id = from._x_id; + } + }); + function cacheIdByNameOnElement(el, cacheKey, cleanup, callback) { + if (!el._x_id) + el._x_id = {}; + if (el._x_id[cacheKey]) + return el._x_id[cacheKey]; + let output = callback(); + el._x_id[cacheKey] = output; + cleanup(() => { + delete el._x_id[cacheKey]; + }); + return output; + } magic("el", (el) => el); warnMissingPluginMagic("Focus", "focus", "focus"); warnMissingPluginMagic("Persist", "persist", "persist"); function warnMissingPluginMagic(name, magicName, slug) { magic(magicName, (el) => warn(`You can't use [$${magicName}] without first installing the "${name}" plugin here: https://alpinejs.dev/plugins/${slug}`, el)); @@ -9151,11 +9180,11 @@ let removeListener = isCloning ? () => { } : on(el, event, modifiers, (e2) => { setValue(getInputValue(el, modifiers, e2, getValue())); }); if (modifiers.includes("fill")) { - if ([null, ""].includes(getValue()) || el.type === "checkbox" && Array.isArray(getValue())) { + if ([void 0, null, ""].includes(getValue()) || el.type === "checkbox" && Array.isArray(getValue())) { el.dispatchEvent(new Event(event, {})); } } if (!el._x_removeModelListeners) el._x_removeModelListeners = {}; @@ -9616,10 +9645,15 @@ }); directive("id", (el, { expression }, { evaluate: evaluate2 }) => { let names = evaluate2(expression); names.forEach((name) => setIdRoot(el, name)); }); + interceptClone((from, to) => { + if (from._x_ids) { + to._x_ids = from._x_ids; + } + }); mapAttributes(startingWith("@", into(prefix("on:")))); directive("on", skipDuringClone((el, { value, modifiers, expression }, { cleanup }) => { let evaluate2 = expression ? evaluateLater(el, expression) : () => { }; if (el.tagName.toLowerCase() === "template") { @@ -9640,11 +9674,11 @@ warnMissingPluginDirective("Mask", "mask", "mask"); function warnMissingPluginDirective(name, directiveName, slug) { directive(directiveName, (el) => warn(`You can't use [x-${directiveName}] without first installing the "${name}" plugin here: https://alpinejs.dev/plugins/${slug}`, el)); } alpine_default2.setEvaluator(normalEvaluator); - alpine_default2.setReactivityEngine({ reactive: import_reactivity9.reactive, effect: import_reactivity9.effect, release: import_reactivity9.stop, raw: import_reactivity9.toRaw }); + alpine_default2.setReactivityEngine({ reactive: import_reactivity10.reactive, effect: import_reactivity10.effect, release: import_reactivity10.stop, raw: import_reactivity10.toRaw }); var src_default = alpine_default2; var module_default = src_default; } }); @@ -9669,11 +9703,11 @@ }; var __toCommonJS = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod); var module_exports = {}; __export2(module_exports, { default: () => module_default, - morph: () => morph2 + morph: () => src_default }); module.exports = __toCommonJS(module_exports); function morph2(from, toHtml, options) { monkeyPatchDomSetAttributeToAllowAtSymbols(); let fromEl; @@ -10032,15 +10066,16 @@ }; var __toCommonJS = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod); var module_exports = {}; __export2(module_exports, { default: () => module_default, + mask: () => src_default, stripDown: () => stripDown }); module.exports = __toCommonJS(module_exports); function src_default(Alpine3) { - Alpine3.directive("mask", (el, { value, expression }, { effect, evaluateLater }) => { + Alpine3.directive("mask", (el, { value, expression }, { effect, evaluateLater, cleanup }) => { let templateFn = () => expression; let lastInputValue = ""; queueMicrotask(() => { if (["function", "dynamic"].includes(value)) { let evaluator = evaluateLater(expression); @@ -10064,12 +10099,21 @@ processInputValue(el, false); } if (el._x_model) el._x_model.set(el.value); }); - el.addEventListener("input", () => processInputValue(el)); - el.addEventListener("blur", () => processInputValue(el, false)); + const controller = new AbortController(); + cleanup(() => { + controller.abort(); + }); + el.addEventListener("input", () => processInputValue(el), { + signal: controller.signal, + // Setting this as a capture phase listener to ensure it runs + // before wire:model or x-model added as a latent binding... + capture: true + }); + el.addEventListener("blur", () => processInputValue(el, false), { signal: controller.signal }); function processInputValue(el2, shouldRestoreCursor = true) { let input = el2.value; let template = templateFn(input); if (!template || template === "false") return false; @@ -15369,11 +15413,11 @@ var alpine_default = import_alpinejs.default; // ../../../package.json var package_default = { name: "coveragebook-components", - version: "0.17.1", + version: "0.17.2", repository: "git@github.com:coveragebook/coco.git", license: "NO LICENSE", author: "Mark Perkins <mark@coveragebook.com>", main: "app/assets/build/coco/coco.js", engines: { @@ -15411,34 +15455,34 @@ tabWidth: 2, trailingComma: "es5" }, dependencies: { "@alpinejs/focus": "^3.13.2", - "@alpinejs/mask": "^3.13.3", - "@alpinejs/morph": "^3.13.2", + "@alpinejs/mask": "^3.13.5", + "@alpinejs/morph": "^3.13.5", "@jaames/iro": "^5.5.2", "@percy/cli": "^1.27.3", "@tailwindcss/container-queries": "^0.1.0", "@tailwindcss/forms": "^0.5.6", "alias-hq": "^6.2.2", - alpinejs: "^3.13.2", + alpinejs: "^3.13.5", autoprefixer: "^10.4.16", "container-query-polyfill": "^1.0.2", del: "^7.1.0", esbuild: "^0.19.11", "esbuild-plugin-copy": "^2.0.2", "fast-glob": "^3.3.1", "fast-sort": "^3.2.1", husky: "^8.0.3", "js-cookie": "^3.0.5", - "lint-staged": "^15.2.0", + "lint-staged": "^15.2.2", "lodash.camelcase": "^4.3.0", "lodash.kebabcase": "^4.1.1", "lodash.keyby": "^4.6.0", "lodash.mapvalues": "^4.6.0", "lucide-static": "^0.303.0", postcss: "^8.4.31", - "postcss-cli": "^10.1.0", + "postcss-cli": "^11.0.0", "postcss-value-parser": "^4.2.0", prettier: "^3.1.1", "release-it": "^17.0.1", svgo: "^3.0.2", tailwindcss: "^3.4.0",