ember-primitives 0.30.1 → 0.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/declarations/helpers/body-class.d.ts +29 -0
- package/declarations/helpers/body-class.d.ts.map +1 -0
- package/declarations/on-resize.d.ts +38 -0
- package/declarations/on-resize.d.ts.map +1 -0
- package/dist/helpers/body-class.js +64 -0
- package/dist/helpers/body-class.js.map +1 -0
- package/dist/on-resize.js +116 -0
- package/dist/on-resize.js.map +1 -0
- package/package.json +20 -20
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Initial inspo:
|
|
3
|
+
* - https://github.com/ef4/ember-set-body-class/blob/master/addon/services/body-class.js
|
|
4
|
+
* - https://github.com/ef4/ember-set-body-class/blob/master/addon/helpers/set-body-class.js
|
|
5
|
+
*/
|
|
6
|
+
import Helper from '@ember/component/helper';
|
|
7
|
+
export interface Signature {
|
|
8
|
+
Args: {
|
|
9
|
+
Positional: [
|
|
10
|
+
/**
|
|
11
|
+
* a space-delimited list of classes to apply when this helper is called.
|
|
12
|
+
*
|
|
13
|
+
* When the helper is removed from rendering, the clasess will be removed as well.
|
|
14
|
+
*/
|
|
15
|
+
classes: string
|
|
16
|
+
];
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* This helper returns nothing, as it is a side-effect that mutates and manages external state.
|
|
20
|
+
*/
|
|
21
|
+
Return: undefined;
|
|
22
|
+
}
|
|
23
|
+
export default class BodyClass extends Helper<Signature> {
|
|
24
|
+
localId: number;
|
|
25
|
+
compute([classes]: [string]): undefined;
|
|
26
|
+
willDestroy(): void;
|
|
27
|
+
}
|
|
28
|
+
export declare const bodyClass: typeof BodyClass;
|
|
29
|
+
//# sourceMappingURL=body-class.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"body-class.d.ts","sourceRoot":"","sources":["../../src/helpers/body-class.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAsD7C,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE;QACJ,UAAU,EAAE;YACV;;;;eAIG;YACH,OAAO,EAAE,MAAM;SAChB,CAAC;KACH,CAAC;IACF;;OAEG;IACH,MAAM,EAAE,SAAS,CAAC;CACnB;AAED,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,MAAM,CAAC,SAAS,CAAC;IACtD,OAAO,SAAQ;IAEf,OAAO,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,SAAS;IAQvC,WAAW;CAIZ;AAED,eAAO,MAAM,SAAS,kBAAY,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import Modifier, { type ArgsFor } from 'ember-modifier';
|
|
2
|
+
import type Owner from '@ember/owner';
|
|
3
|
+
export interface Signature {
|
|
4
|
+
/**
|
|
5
|
+
* Any element that is resizable can have onResize attached
|
|
6
|
+
*/
|
|
7
|
+
Element: Element;
|
|
8
|
+
Args: {
|
|
9
|
+
Positional: [
|
|
10
|
+
/**
|
|
11
|
+
* The ResizeObserver callback will only receive
|
|
12
|
+
* one entry per resize event.
|
|
13
|
+
*
|
|
14
|
+
* See: [ResizeObserverEntry](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserverEntry)
|
|
15
|
+
*/
|
|
16
|
+
callback: (entry: ResizeObserverEntry) => void
|
|
17
|
+
];
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
declare class OnResize extends Modifier<Signature> {
|
|
21
|
+
#private;
|
|
22
|
+
constructor(owner: Owner, args: ArgsFor<Signature>);
|
|
23
|
+
modify(element: Element, [callback]: [callback: (entry: ResizeObserverEntry) => void]): void;
|
|
24
|
+
}
|
|
25
|
+
export declare const onResize: typeof OnResize;
|
|
26
|
+
/**
|
|
27
|
+
* Ignores "ResizeObserver loop limit exceeded" error in Ember tests.
|
|
28
|
+
*
|
|
29
|
+
* This "error" is safe to ignore as it is just a warning message,
|
|
30
|
+
* telling that the "looping" observation will be skipped in the current frame,
|
|
31
|
+
* and will be delivered in the next one.
|
|
32
|
+
*
|
|
33
|
+
* For some reason, it is fired as an `error` event at `window` failing Ember
|
|
34
|
+
* tests and exploding Sentry with errors that must be ignored.
|
|
35
|
+
*/
|
|
36
|
+
export default function ignoreROError(): void;
|
|
37
|
+
export {};
|
|
38
|
+
//# sourceMappingURL=on-resize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"on-resize.d.ts","sourceRoot":"","sources":["../src/on-resize.ts"],"names":[],"mappings":"AAGA,OAAO,QAAQ,EAAE,EAAE,KAAK,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAExD,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,MAAM,WAAW,SAAS;IACxB;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE;QACJ,UAAU,EAAE;YACV;;;;;eAKG;YACH,QAAQ,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI;SAC/C,CAAC;KACH,CAAC;CACH;AAED,cAAM,QAAS,SAAQ,QAAQ,CAAC,SAAS,CAAC;;gBAM5B,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,SAAS,CAAC;IAUlD,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,CAAC;CAetF;AAED,eAAO,MAAM,QAAQ,iBAAW,CAAC;AA6EjC;;;;;;;;;GASG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,SAgBpC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import Helper from '@ember/component/helper';
|
|
2
|
+
import { buildWaiter } from '@ember/test-waiters';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Initial inspo:
|
|
6
|
+
* - https://github.com/ef4/ember-set-body-class/blob/master/addon/services/body-class.js
|
|
7
|
+
* - https://github.com/ef4/ember-set-body-class/blob/master/addon/helpers/set-body-class.js
|
|
8
|
+
*/
|
|
9
|
+
const waiter = buildWaiter('ember-primitives:body-class:raf');
|
|
10
|
+
let id = 0;
|
|
11
|
+
const registrations = new Map();
|
|
12
|
+
let previousRegistrations = [];
|
|
13
|
+
function classNames() {
|
|
14
|
+
const allNames = new Set();
|
|
15
|
+
for (const classNames of registrations.values()) {
|
|
16
|
+
for (const className of classNames) {
|
|
17
|
+
allNames.add(className);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return [...allNames];
|
|
21
|
+
}
|
|
22
|
+
let frame;
|
|
23
|
+
let waiterToken;
|
|
24
|
+
function queueUpdate() {
|
|
25
|
+
waiterToken ||= waiter.beginAsync();
|
|
26
|
+
cancelAnimationFrame(frame);
|
|
27
|
+
frame = requestAnimationFrame(() => {
|
|
28
|
+
updateBodyClass();
|
|
29
|
+
waiter.endAsync(waiterToken);
|
|
30
|
+
waiterToken = undefined;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* This should only add/remove classes that we tried to maintain via the body-class helper.
|
|
36
|
+
*
|
|
37
|
+
* Folks can set classes in their html and we don't want to mess with those
|
|
38
|
+
*/
|
|
39
|
+
function updateBodyClass() {
|
|
40
|
+
const toAdd = classNames();
|
|
41
|
+
for (const name of previousRegistrations) {
|
|
42
|
+
document.body.classList.remove(name);
|
|
43
|
+
}
|
|
44
|
+
for (const name of toAdd) {
|
|
45
|
+
document.body.classList.add(name);
|
|
46
|
+
}
|
|
47
|
+
previousRegistrations = toAdd;
|
|
48
|
+
}
|
|
49
|
+
class BodyClass extends Helper {
|
|
50
|
+
localId = id++;
|
|
51
|
+
compute([classes]) {
|
|
52
|
+
const classNames = classes ? classes.split(/\s+/) : [];
|
|
53
|
+
registrations.set(this.localId, classNames);
|
|
54
|
+
queueUpdate();
|
|
55
|
+
}
|
|
56
|
+
willDestroy() {
|
|
57
|
+
registrations.delete(this.localId);
|
|
58
|
+
queueUpdate();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const bodyClass = BodyClass;
|
|
62
|
+
|
|
63
|
+
export { bodyClass, BodyClass as default };
|
|
64
|
+
//# sourceMappingURL=body-class.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"body-class.js","sources":["../../src/helpers/body-class.ts"],"sourcesContent":["/**\n * Initial inspo:\n * - https://github.com/ef4/ember-set-body-class/blob/master/addon/services/body-class.js\n * - https://github.com/ef4/ember-set-body-class/blob/master/addon/helpers/set-body-class.js\n */\nimport Helper from '@ember/component/helper';\nimport { buildWaiter } from '@ember/test-waiters';\n\nconst waiter = buildWaiter('ember-primitives:body-class:raf');\n\nlet id = 0;\nconst registrations = new Map<number, string[]>();\nlet previousRegistrations: string[] = [];\n\nfunction classNames(): string[] {\n const allNames = new Set<string>();\n\n for (const classNames of registrations.values()) {\n for (const className of classNames) {\n allNames.add(className);\n }\n }\n\n return [...allNames];\n}\n\nlet frame: number;\nlet waiterToken: unknown;\n\nfunction queueUpdate() {\n waiterToken ||= waiter.beginAsync();\n\n cancelAnimationFrame(frame);\n frame = requestAnimationFrame(() => {\n updateBodyClass();\n waiter.endAsync(waiterToken);\n waiterToken = undefined;\n });\n}\n\n/**\n * This should only add/remove classes that we tried to maintain via the body-class helper.\n *\n * Folks can set classes in their html and we don't want to mess with those\n */\nfunction updateBodyClass() {\n const toAdd = classNames();\n\n for (const name of previousRegistrations) {\n document.body.classList.remove(name);\n }\n\n for (const name of toAdd) {\n document.body.classList.add(name);\n }\n\n previousRegistrations = toAdd;\n}\n\nexport interface Signature {\n Args: {\n Positional: [\n /**\n * a space-delimited list of classes to apply when this helper is called.\n *\n * When the helper is removed from rendering, the clasess will be removed as well.\n */\n classes: string,\n ];\n };\n /**\n * This helper returns nothing, as it is a side-effect that mutates and manages external state.\n */\n Return: undefined;\n}\n\nexport default class BodyClass extends Helper<Signature> {\n localId = id++;\n\n compute([classes]: [string]): undefined {\n const classNames = classes ? classes.split(/\\s+/) : [];\n\n registrations.set(this.localId, classNames);\n\n queueUpdate();\n }\n\n willDestroy() {\n registrations.delete(this.localId);\n queueUpdate();\n }\n}\n\nexport const bodyClass = BodyClass;\n"],"names":["waiter","buildWaiter","id","registrations","Map","previousRegistrations","classNames","allNames","Set","values","className","add","frame","waiterToken","queueUpdate","beginAsync","cancelAnimationFrame","requestAnimationFrame","updateBodyClass","endAsync","undefined","toAdd","name","document","body","classList","remove","BodyClass","Helper","localId","compute","classes","split","set","willDestroy","delete","bodyClass"],"mappings":";;;AAAA;AACA;AACA;AACA;AACA;AAIA,MAAMA,MAAM,GAAGC,WAAW,CAAC,iCAAiC,CAAC;AAE7D,IAAIC,EAAE,GAAG,CAAC;AACV,MAAMC,aAAa,GAAG,IAAIC,GAAG,EAAoB;AACjD,IAAIC,qBAA+B,GAAG,EAAE;AAExC,SAASC,UAAUA,GAAa;AAC9B,EAAA,MAAMC,QAAQ,GAAG,IAAIC,GAAG,EAAU;EAElC,KAAK,MAAMF,UAAU,IAAIH,aAAa,CAACM,MAAM,EAAE,EAAE;AAC/C,IAAA,KAAK,MAAMC,SAAS,IAAIJ,UAAU,EAAE;AAClCC,MAAAA,QAAQ,CAACI,GAAG,CAACD,SAAS,CAAC;AACzB;AACF;EAEA,OAAO,CAAC,GAAGH,QAAQ,CAAC;AACtB;AAEA,IAAIK,KAAa;AACjB,IAAIC,WAAoB;AAExB,SAASC,WAAWA,GAAG;AACrBD,EAAAA,WAAW,KAAKb,MAAM,CAACe,UAAU,EAAE;EAEnCC,oBAAoB,CAACJ,KAAK,CAAC;EAC3BA,KAAK,GAAGK,qBAAqB,CAAC,MAAM;AAClCC,IAAAA,eAAe,EAAE;AACjBlB,IAAAA,MAAM,CAACmB,QAAQ,CAACN,WAAW,CAAC;AAC5BA,IAAAA,WAAW,GAAGO,SAAS;AACzB,GAAC,CAAC;AACJ;;AAEA;AACA;AACA;AACA;AACA;AACA,SAASF,eAAeA,GAAG;AACzB,EAAA,MAAMG,KAAK,GAAGf,UAAU,EAAE;AAE1B,EAAA,KAAK,MAAMgB,IAAI,IAAIjB,qBAAqB,EAAE;IACxCkB,QAAQ,CAACC,IAAI,CAACC,SAAS,CAACC,MAAM,CAACJ,IAAI,CAAC;AACtC;AAEA,EAAA,KAAK,MAAMA,IAAI,IAAID,KAAK,EAAE;IACxBE,QAAQ,CAACC,IAAI,CAACC,SAAS,CAACd,GAAG,CAACW,IAAI,CAAC;AACnC;AAEAjB,EAAAA,qBAAqB,GAAGgB,KAAK;AAC/B;AAmBe,MAAMM,SAAS,SAASC,MAAM,CAAY;EACvDC,OAAO,GAAG3B,EAAE,EAAE;AAEd4B,EAAAA,OAAOA,CAAC,CAACC,OAAO,CAAW,EAAa;IACtC,MAAMzB,UAAU,GAAGyB,OAAO,GAAGA,OAAO,CAACC,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE;IAEtD7B,aAAa,CAAC8B,GAAG,CAAC,IAAI,CAACJ,OAAO,EAAEvB,UAAU,CAAC;AAE3CQ,IAAAA,WAAW,EAAE;AACf;AAEAoB,EAAAA,WAAWA,GAAG;AACZ/B,IAAAA,aAAa,CAACgC,MAAM,CAAC,IAAI,CAACN,OAAO,CAAC;AAClCf,IAAAA,WAAW,EAAE;AACf;AACF;AAEO,MAAMsB,SAAS,GAAGT;;;;"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { assert } from '@ember/debug';
|
|
2
|
+
import { registerDestructor } from '@ember/destroyable';
|
|
3
|
+
import Modifier from 'ember-modifier';
|
|
4
|
+
|
|
5
|
+
class OnResize extends Modifier {
|
|
6
|
+
#callback = null;
|
|
7
|
+
#element = null;
|
|
8
|
+
#resizeObserver = new ResizeObserverManager();
|
|
9
|
+
constructor(owner, args) {
|
|
10
|
+
super(owner, args);
|
|
11
|
+
registerDestructor(this, () => {
|
|
12
|
+
if (this.#element && this.#callback) {
|
|
13
|
+
this.#resizeObserver.unobserve(this.#element, this.#callback);
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
modify(element, [callback]) {
|
|
18
|
+
assert(`{{onResize}}: callback must be a function, but was ${callback}`, typeof callback === 'function');
|
|
19
|
+
if (this.#element && this.#callback) {
|
|
20
|
+
this.#resizeObserver.unobserve(this.#element, this.#callback);
|
|
21
|
+
}
|
|
22
|
+
this.#resizeObserver.observe(element, callback);
|
|
23
|
+
this.#callback = callback;
|
|
24
|
+
this.#element = element;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const onResize = OnResize;
|
|
28
|
+
const errorMessages = ['ResizeObserver loop limit exceeded', 'ResizeObserver loop completed with undelivered notifications.'];
|
|
29
|
+
class ResizeObserverManager {
|
|
30
|
+
#callbacks = new WeakMap();
|
|
31
|
+
#handleResize = entries => {
|
|
32
|
+
for (const entry of entries) {
|
|
33
|
+
const callbacks = this.#callbacks.get(entry.target);
|
|
34
|
+
if (callbacks) {
|
|
35
|
+
for (const callback of callbacks) {
|
|
36
|
+
callback(entry);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
#observer = new ResizeObserver(this.#handleResize);
|
|
42
|
+
constructor() {
|
|
43
|
+
ignoreROError();
|
|
44
|
+
registerDestructor(this, () => {
|
|
45
|
+
this.#observer?.disconnect();
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Initiate the observing of the `element` or add an additional `callback`
|
|
51
|
+
* if the `element` is already observed.
|
|
52
|
+
*
|
|
53
|
+
* @param {object} element
|
|
54
|
+
* @param {function} callback The `callback` is called whenever the size of
|
|
55
|
+
* the `element` changes. It is called with `ResizeObserverEntry` object
|
|
56
|
+
* for the particular `element`.
|
|
57
|
+
*/
|
|
58
|
+
observe(element, callback) {
|
|
59
|
+
const callbacks = this.#callbacks.get(element);
|
|
60
|
+
if (callbacks) {
|
|
61
|
+
callbacks.add(callback);
|
|
62
|
+
} else {
|
|
63
|
+
this.#callbacks.set(element, new Set([callback]));
|
|
64
|
+
this.#observer.observe(element);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* End the observing of the `element` or just remove the provided `callback`.
|
|
70
|
+
*
|
|
71
|
+
* It will unobserve the `element` if the `callback` is not provided
|
|
72
|
+
* or there are no more callbacks left for this `element`.
|
|
73
|
+
*
|
|
74
|
+
* @param {object} element
|
|
75
|
+
* @param {function?} callback - The `callback` to remove from the listeners
|
|
76
|
+
* of the `element` size changes.
|
|
77
|
+
*/
|
|
78
|
+
unobserve(element, callback) {
|
|
79
|
+
const callbacks = this.#callbacks.get(element);
|
|
80
|
+
if (!callbacks) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
callbacks.delete(callback);
|
|
84
|
+
if (!callback || !callbacks.size) {
|
|
85
|
+
this.#callbacks.delete(element);
|
|
86
|
+
this.#observer.unobserve(element);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Ignores "ResizeObserver loop limit exceeded" error in Ember tests.
|
|
93
|
+
*
|
|
94
|
+
* This "error" is safe to ignore as it is just a warning message,
|
|
95
|
+
* telling that the "looping" observation will be skipped in the current frame,
|
|
96
|
+
* and will be delivered in the next one.
|
|
97
|
+
*
|
|
98
|
+
* For some reason, it is fired as an `error` event at `window` failing Ember
|
|
99
|
+
* tests and exploding Sentry with errors that must be ignored.
|
|
100
|
+
*/
|
|
101
|
+
function ignoreROError() {
|
|
102
|
+
if (typeof window.onerror !== 'function') {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const onError = window.onerror;
|
|
106
|
+
window.onerror = (...args) => {
|
|
107
|
+
const [message] = args;
|
|
108
|
+
if (typeof message === 'string') {
|
|
109
|
+
if (errorMessages.includes(message)) return true;
|
|
110
|
+
}
|
|
111
|
+
onError(...args);
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export { ignoreROError as default, onResize };
|
|
116
|
+
//# sourceMappingURL=on-resize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"on-resize.js","sources":["../src/on-resize.ts"],"sourcesContent":["import { assert } from '@ember/debug';\nimport { registerDestructor } from '@ember/destroyable';\n\nimport Modifier, { type ArgsFor } from 'ember-modifier';\n\nimport type Owner from '@ember/owner';\n\nexport interface Signature {\n /**\n * Any element that is resizable can have onResize attached\n */\n Element: Element;\n Args: {\n Positional: [\n /**\n * The ResizeObserver callback will only receive\n * one entry per resize event.\n *\n * See: [ResizeObserverEntry](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserverEntry)\n */\n callback: (entry: ResizeObserverEntry) => void,\n ];\n };\n}\n\nclass OnResize extends Modifier<Signature> {\n #callback: ((entry: ResizeObserverEntry) => void) | null = null;\n #element: Element | null = null;\n\n #resizeObserver: ResizeObserverManager = new ResizeObserverManager();\n\n constructor(owner: Owner, args: ArgsFor<Signature>) {\n super(owner, args);\n\n registerDestructor(this, () => {\n if (this.#element && this.#callback) {\n this.#resizeObserver.unobserve(this.#element, this.#callback);\n }\n });\n }\n\n modify(element: Element, [callback]: [callback: (entry: ResizeObserverEntry) => void]) {\n assert(\n `{{onResize}}: callback must be a function, but was ${callback as unknown as string}`,\n typeof callback === 'function'\n );\n\n if (this.#element && this.#callback) {\n this.#resizeObserver.unobserve(this.#element, this.#callback);\n }\n\n this.#resizeObserver.observe(element, callback);\n\n this.#callback = callback;\n this.#element = element;\n }\n}\n\nexport const onResize = OnResize;\n\nconst errorMessages = [\n 'ResizeObserver loop limit exceeded',\n 'ResizeObserver loop completed with undelivered notifications.',\n];\n\nclass ResizeObserverManager {\n #callbacks = new WeakMap<Element, Set<(entry: ResizeObserverEntry) => unknown>>();\n\n #handleResize = (entries: ResizeObserverEntry[]) => {\n for (const entry of entries) {\n const callbacks = this.#callbacks.get(entry.target);\n\n if (callbacks) {\n for (const callback of callbacks) {\n callback(entry);\n }\n }\n }\n };\n #observer = new ResizeObserver(this.#handleResize);\n\n constructor() {\n ignoreROError();\n\n registerDestructor(this, () => {\n this.#observer?.disconnect();\n });\n }\n\n /**\n * Initiate the observing of the `element` or add an additional `callback`\n * if the `element` is already observed.\n *\n * @param {object} element\n * @param {function} callback The `callback` is called whenever the size of\n * the `element` changes. It is called with `ResizeObserverEntry` object\n * for the particular `element`.\n */\n observe(element: Element, callback: (entry: ResizeObserverEntry) => unknown) {\n const callbacks = this.#callbacks.get(element);\n\n if (callbacks) {\n callbacks.add(callback);\n } else {\n this.#callbacks.set(element, new Set([callback]));\n this.#observer.observe(element);\n }\n }\n\n /**\n * End the observing of the `element` or just remove the provided `callback`.\n *\n * It will unobserve the `element` if the `callback` is not provided\n * or there are no more callbacks left for this `element`.\n *\n * @param {object} element\n * @param {function?} callback - The `callback` to remove from the listeners\n * of the `element` size changes.\n */\n unobserve(element: Element, callback: (entry: ResizeObserverEntry) => unknown) {\n const callbacks = this.#callbacks.get(element);\n\n if (!callbacks) {\n return;\n }\n\n callbacks.delete(callback);\n\n if (!callback || !callbacks.size) {\n this.#callbacks.delete(element);\n this.#observer.unobserve(element);\n }\n }\n}\n\n/**\n * Ignores \"ResizeObserver loop limit exceeded\" error in Ember tests.\n *\n * This \"error\" is safe to ignore as it is just a warning message,\n * telling that the \"looping\" observation will be skipped in the current frame,\n * and will be delivered in the next one.\n *\n * For some reason, it is fired as an `error` event at `window` failing Ember\n * tests and exploding Sentry with errors that must be ignored.\n */\nexport default function ignoreROError() {\n if (typeof window.onerror !== 'function') {\n return;\n }\n\n const onError = window.onerror;\n\n window.onerror = (...args) => {\n const [message] = args;\n\n if (typeof message === 'string') {\n if (errorMessages.includes(message)) return true;\n }\n\n onError(...args);\n };\n}\n"],"names":["OnResize","Modifier","ResizeObserverManager","constructor","owner","args","registerDestructor","unobserve","modify","element","callback","assert","observe","onResize","errorMessages","WeakMap","entries","entry","callbacks","get","target","ResizeObserver","ignoreROError","disconnect","add","set","Set","delete","size","window","onerror","onError","message","includes"],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ember-primitives",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.32.0",
|
|
4
4
|
"description": "Making apps easier to build",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"*.css"
|
|
@@ -17,37 +17,37 @@
|
|
|
17
17
|
"declarations"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@babel/runtime": "^7.27.
|
|
21
|
-
"@embroider/addon-shim": "^1.
|
|
22
|
-
"@embroider/macros": "^1.17.
|
|
23
|
-
"@floating-ui/dom": "^1.
|
|
20
|
+
"@babel/runtime": "^7.27.1",
|
|
21
|
+
"@embroider/addon-shim": "^1.10.0",
|
|
22
|
+
"@embroider/macros": "^1.17.3",
|
|
23
|
+
"@floating-ui/dom": "^1.7.0",
|
|
24
24
|
"decorator-transforms": "^2.3.0",
|
|
25
|
-
"ember-element-helper": "
|
|
25
|
+
"ember-element-helper": "^0.8.7",
|
|
26
26
|
"form-data-utils": "^0.6.0",
|
|
27
27
|
"reactiveweb": "^1.4.2",
|
|
28
28
|
"should-handle-link": "^1.2.2",
|
|
29
|
-
"tabster": "^8.5.
|
|
29
|
+
"tabster": "^8.5.5",
|
|
30
30
|
"tracked-built-ins": "^4.0.0",
|
|
31
31
|
"tracked-toolbox": "^2.0.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@arethetypeswrong/cli": "^0.17.4",
|
|
35
|
-
"@babel/core": "^7.
|
|
35
|
+
"@babel/core": "^7.27.1",
|
|
36
36
|
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
37
37
|
"@babel/plugin-proposal-decorators": "^7.25.9",
|
|
38
38
|
"@babel/plugin-proposal-object-rest-spread": "^7.20.7",
|
|
39
|
-
"@babel/plugin-syntax-decorators": "^7.
|
|
40
|
-
"@babel/plugin-transform-class-static-block": "^7.
|
|
41
|
-
"@babel/plugin-transform-private-methods": "^7.
|
|
42
|
-
"@babel/preset-typescript": "^7.27.
|
|
39
|
+
"@babel/plugin-syntax-decorators": "^7.27.1",
|
|
40
|
+
"@babel/plugin-transform-class-static-block": "^7.27.1",
|
|
41
|
+
"@babel/plugin-transform-private-methods": "^7.27.1",
|
|
42
|
+
"@babel/preset-typescript": "^7.27.1",
|
|
43
43
|
"@ember/test-helpers": "^5.2.0",
|
|
44
44
|
"@ember/test-waiters": "^4.1.0",
|
|
45
45
|
"@embroider/addon-dev": "^7.0.1",
|
|
46
46
|
"@glimmer/component": "^2.0.0",
|
|
47
47
|
"@glimmer/tracking": "^1.1.2",
|
|
48
48
|
"@glint/core": "1.5.2",
|
|
49
|
-
"@glint/environment-ember-loose": "1.
|
|
50
|
-
"@glint/environment-ember-template-imports": "1.
|
|
49
|
+
"@glint/environment-ember-loose": "1.5.2",
|
|
50
|
+
"@glint/environment-ember-template-imports": "1.4.1-unstable.5564fc2",
|
|
51
51
|
"@glint/template": "^1.5.2",
|
|
52
52
|
"@nullvoxpopuli/eslint-configs": "^5.1.1",
|
|
53
53
|
"@rollup/plugin-babel": "^6.0.4",
|
|
@@ -56,16 +56,16 @@
|
|
|
56
56
|
"concurrently": "^9.1.0",
|
|
57
57
|
"ember-modifier": "^4.1.0",
|
|
58
58
|
"ember-resources": "^7.0.4",
|
|
59
|
-
"ember-source": "6.5.0-
|
|
60
|
-
"ember-template-lint": "^7.0
|
|
61
|
-
"eslint": "^9.
|
|
59
|
+
"ember-source": "6.5.0-beta.1",
|
|
60
|
+
"ember-template-lint": "^7.6.0",
|
|
61
|
+
"eslint": "^9.26.0",
|
|
62
62
|
"fix-bad-declaration-output": "^1.1.4",
|
|
63
63
|
"prettier": "^3.2.5",
|
|
64
|
-
"prettier-plugin-ember-template-tag": "^2.0.
|
|
64
|
+
"prettier-plugin-ember-template-tag": "^2.0.5",
|
|
65
65
|
"publint": "^0.3.9",
|
|
66
|
-
"rollup": "~4.40.
|
|
66
|
+
"rollup": "~4.40.2",
|
|
67
67
|
"rollup-plugin-copy": "^3.5.0",
|
|
68
|
-
"typescript": "^5.8.
|
|
68
|
+
"typescript": "^5.8.3"
|
|
69
69
|
},
|
|
70
70
|
"publishConfig": {
|
|
71
71
|
"registry": "https://registry.npmjs.org"
|