@aglyn/aglyn 1.20.3 → 1.22.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/package.json +17 -17
- package/src/lib/app-utils/console-routes.js.map +1 -1
- package/src/lib/app-utils/docs-index.generated.js +6 -6
- package/src/lib/app-utils/docs-index.generated.js.map +1 -1
- package/src/lib/app-utils/native-besigner-back.d.ts +60 -0
- package/src/lib/app-utils/native-besigner-back.js +97 -0
- package/src/lib/app-utils/native-besigner-back.js.map +1 -0
- package/src/lib/app-utils/plain-data.d.ts +20 -0
- package/src/lib/app-utils/plain-data.js +122 -0
- package/src/lib/app-utils/plain-data.js.map +1 -0
- package/src/lib/app-utils/site-interactions.js +1 -1
- package/src/lib/app-utils/site-interactions.js.map +1 -1
- package/src/lib/app-utils/variables.js +13 -6
- package/src/lib/app-utils/variables.js.map +1 -1
- package/src/lib/app-utils/visitor-consent.js +1 -1
- package/src/lib/app-utils/visitor-consent.js.map +1 -1
- package/src/lib/canvas-manager/canvas-manager.d.ts +1 -1
- package/src/lib/canvas-manager/canvas-manager.js +7 -8
- package/src/lib/canvas-manager/canvas-manager.js.map +1 -1
- package/src/lib/emit-manager/emit-manager.js.map +1 -1
- package/src/lib/foundation/constants/components.js.map +1 -1
- package/src/lib/foundation/constants/shared.js.map +1 -1
- package/src/lib/foundation/constants/symbol.js.map +1 -1
- package/src/lib/foundation/definitions/components.types.d.ts +11 -0
- package/src/lib/foundation/definitions/components.types.js.map +1 -1
- package/src/lib/foundation/definitions/platform.types.js.map +1 -1
- package/src/lib/plugin-manager/enabled-plugins.d.ts +12 -4
- package/src/lib/plugin-manager/enabled-plugins.js +16 -12
- package/src/lib/plugin-manager/enabled-plugins.js.map +1 -1
- package/src/lib/plugin-manager/first-party-plugin-interactions.generated.d.ts +22 -0
- package/src/lib/plugin-manager/first-party-plugin-interactions.generated.js +242 -0
- package/src/lib/plugin-manager/first-party-plugin-interactions.generated.js.map +1 -0
- package/src/lib/plugin-manager/first-party-plugin-switchboard.generated.d.ts +32 -0
- package/src/lib/plugin-manager/first-party-plugin-switchboard.generated.js +307 -0
- package/src/lib/plugin-manager/first-party-plugin-switchboard.generated.js.map +1 -0
- package/src/lib/plugin-manager/first-party-plugins.generated.d.ts +3 -33
- package/src/lib/plugin-manager/first-party-plugins.generated.js +6 -311
- package/src/lib/plugin-manager/first-party-plugins.generated.js.map +1 -1
- package/src/lib/plugin-manager/interaction-recipes.js +1 -1
- package/src/lib/plugin-manager/interaction-recipes.js.map +1 -1
- package/src/lib/plugin-manager/plugin-manager.js.map +1 -1
- package/src/lib/types/nodes.d.ts +18 -2
- package/src/lib/types/nodes.js.map +1 -1
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* The Besigner's own way back inside the native apps (AGL-4056).
|
|
19
|
+
*
|
|
20
|
+
* In the apps the editor has no native head and no Done button: the editor's
|
|
21
|
+
* own back control is the one way out, and the apps' Esc, ⌘[ (Ctrl+[) and
|
|
22
|
+
* back gesture all press it, so whatever that control does first (a prompt,
|
|
23
|
+
* a save) happens the same for every one of them. The control goes to the
|
|
24
|
+
* document's `/view`, which the apps read as "leave the editor".
|
|
25
|
+
*
|
|
26
|
+
* The apps reach the control by this id: native code clicks it from a script
|
|
27
|
+
* (`BesignerEntry.backScript` in the Swift and Kotlin kits), and this file's
|
|
28
|
+
* hook clicks it for the keys the web view receives itself.
|
|
29
|
+
*/
|
|
30
|
+
export declare const NATIVE_BESIGNER_BACK_CONTROL_ID = "aglyn-besigner-back";
|
|
31
|
+
/** What a key event needs for the decision, so a spec can hand in a plain object. */
|
|
32
|
+
export interface BackKeyEvent {
|
|
33
|
+
key: string;
|
|
34
|
+
metaKey: boolean;
|
|
35
|
+
ctrlKey: boolean;
|
|
36
|
+
altKey: boolean;
|
|
37
|
+
shiftKey: boolean;
|
|
38
|
+
defaultPrevented: boolean;
|
|
39
|
+
target: EventTarget | null;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Whether a key leaves the editor through its back control: Esc on its own
|
|
43
|
+
* when nothing else wanted it, or ⌘[ (Ctrl+[ off a Mac) at any time.
|
|
44
|
+
*
|
|
45
|
+
* Esc never leaves while a field has the focus, while something is open over
|
|
46
|
+
* the editor, or when the page already handled it (a pick in progress, an
|
|
47
|
+
* inline editor reverting): those are the Esc a person meant for them.
|
|
48
|
+
*/
|
|
49
|
+
export declare function backKeyLeavesEditor(event: BackKeyEvent, doc: Pick<Document, 'querySelectorAll'>, mac: boolean): boolean;
|
|
50
|
+
/** Presses the editor's back control; false when the page has none. */
|
|
51
|
+
export declare function pressBesignerBack(doc: Pick<Document, 'getElementById'>): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Inside the apps' web view, Esc and ⌘[ press the editor's back control.
|
|
54
|
+
* Off (`enabled` false) it adds nothing, so a browser tab keeps Esc and ⌘[
|
|
55
|
+
* exactly as they were.
|
|
56
|
+
*
|
|
57
|
+
* It listens after the page's own handlers (bubbling, on the window), so a
|
|
58
|
+
* handler that took the key first stops it reaching here.
|
|
59
|
+
*/
|
|
60
|
+
export declare function useNativeBesignerBackKeys(enabled: boolean): void;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/ import { useEffect } from "react";
|
|
17
|
+
/**
|
|
18
|
+
* The Besigner's own way back inside the native apps (AGL-4056).
|
|
19
|
+
*
|
|
20
|
+
* In the apps the editor has no native head and no Done button: the editor's
|
|
21
|
+
* own back control is the one way out, and the apps' Esc, ⌘[ (Ctrl+[) and
|
|
22
|
+
* back gesture all press it, so whatever that control does first (a prompt,
|
|
23
|
+
* a save) happens the same for every one of them. The control goes to the
|
|
24
|
+
* document's `/view`, which the apps read as "leave the editor".
|
|
25
|
+
*
|
|
26
|
+
* The apps reach the control by this id: native code clicks it from a script
|
|
27
|
+
* (`BesignerEntry.backScript` in the Swift and Kotlin kits), and this file's
|
|
28
|
+
* hook clicks it for the keys the web view receives itself.
|
|
29
|
+
*/ export const NATIVE_BESIGNER_BACK_CONTROL_ID = 'aglyn-besigner-back';
|
|
30
|
+
/** Whether `target` takes typing: a field, a select, or editable content. */ function takesTyping(target) {
|
|
31
|
+
const element = target;
|
|
32
|
+
if (!element || typeof element.tagName !== 'string') return false;
|
|
33
|
+
const tag = element.tagName.toLowerCase();
|
|
34
|
+
if (tag === 'input' || tag === 'textarea' || tag === 'select') return true;
|
|
35
|
+
return Boolean(element.isContentEditable) || (element.getAttribute == null ? void 0 : element.getAttribute.call(element, 'contenteditable')) === 'true';
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Something open over the editor that Esc should close first: a dialog, a
|
|
39
|
+
* menu, a popover or a picker's list. MUI marks every one of them with these
|
|
40
|
+
* roles; one kept mounted while closed sits inside a hidden modal.
|
|
41
|
+
*/ const OPEN_OVER_EDITOR = '[role="dialog"], [role="alertdialog"], [role="menu"], [role="listbox"], .MuiPopover-root';
|
|
42
|
+
const CLOSED = '.MuiModal-hidden, [aria-hidden="true"], [hidden]';
|
|
43
|
+
function somethingOpenOverEditor(doc) {
|
|
44
|
+
return Array.from(doc.querySelectorAll(OPEN_OVER_EDITOR)).some((element)=>!element.closest(CLOSED));
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Whether a key leaves the editor through its back control: Esc on its own
|
|
48
|
+
* when nothing else wanted it, or ⌘[ (Ctrl+[ off a Mac) at any time.
|
|
49
|
+
*
|
|
50
|
+
* Esc never leaves while a field has the focus, while something is open over
|
|
51
|
+
* the editor, or when the page already handled it (a pick in progress, an
|
|
52
|
+
* inline editor reverting): those are the Esc a person meant for them.
|
|
53
|
+
*/ export function backKeyLeavesEditor(event, doc, mac) {
|
|
54
|
+
if (event.defaultPrevented) return false;
|
|
55
|
+
if (event.key === '[') {
|
|
56
|
+
const command = mac ? event.metaKey : event.ctrlKey;
|
|
57
|
+
return command && !event.altKey && !event.shiftKey;
|
|
58
|
+
}
|
|
59
|
+
if (event.key !== 'Escape' && event.key !== 'Esc') return false;
|
|
60
|
+
if (event.metaKey || event.ctrlKey || event.altKey || event.shiftKey) return false;
|
|
61
|
+
if (takesTyping(event.target)) return false;
|
|
62
|
+
return !somethingOpenOverEditor(doc);
|
|
63
|
+
}
|
|
64
|
+
/** Presses the editor's back control; false when the page has none. */ export function pressBesignerBack(doc) {
|
|
65
|
+
const control = doc.getElementById(NATIVE_BESIGNER_BACK_CONTROL_ID);
|
|
66
|
+
if (!control) return false;
|
|
67
|
+
control.click();
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
/** Whether this browser is on a Mac (where ⌘ is the command key). */ function onMac() {
|
|
71
|
+
if (typeof navigator === 'undefined') return false;
|
|
72
|
+
return /Mac|iPhone|iPad|iPod/.test(navigator.platform || navigator.userAgent || '');
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Inside the apps' web view, Esc and ⌘[ press the editor's back control.
|
|
76
|
+
* Off (`enabled` false) it adds nothing, so a browser tab keeps Esc and ⌘[
|
|
77
|
+
* exactly as they were.
|
|
78
|
+
*
|
|
79
|
+
* It listens after the page's own handlers (bubbling, on the window), so a
|
|
80
|
+
* handler that took the key first stops it reaching here.
|
|
81
|
+
*/ export function useNativeBesignerBackKeys(enabled) {
|
|
82
|
+
useEffect(()=>{
|
|
83
|
+
if (!enabled || typeof window === 'undefined') return;
|
|
84
|
+
const mac = onMac();
|
|
85
|
+
const onKeyDown = (event)=>{
|
|
86
|
+
if (!backKeyLeavesEditor(event, document, mac)) return;
|
|
87
|
+
if (!pressBesignerBack(document)) return;
|
|
88
|
+
event.preventDefault();
|
|
89
|
+
};
|
|
90
|
+
window.addEventListener('keydown', onKeyDown);
|
|
91
|
+
return ()=>window.removeEventListener('keydown', onKeyDown);
|
|
92
|
+
}, [
|
|
93
|
+
enabled
|
|
94
|
+
]);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
//# sourceMappingURL=native-besigner-back.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/native-besigner-back.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useEffect } from 'react'\n\n/**\n * The Besigner's own way back inside the native apps (AGL-4056).\n *\n * In the apps the editor has no native head and no Done button: the editor's\n * own back control is the one way out, and the apps' Esc, ⌘[ (Ctrl+[) and\n * back gesture all press it, so whatever that control does first (a prompt,\n * a save) happens the same for every one of them. The control goes to the\n * document's `/view`, which the apps read as \"leave the editor\".\n *\n * The apps reach the control by this id: native code clicks it from a script\n * (`BesignerEntry.backScript` in the Swift and Kotlin kits), and this file's\n * hook clicks it for the keys the web view receives itself.\n */\nexport const NATIVE_BESIGNER_BACK_CONTROL_ID = 'aglyn-besigner-back'\n\n/** What a key event needs for the decision, so a spec can hand in a plain object. */\nexport interface BackKeyEvent {\n key: string\n metaKey: boolean\n ctrlKey: boolean\n altKey: boolean\n shiftKey: boolean\n defaultPrevented: boolean\n target: EventTarget | null\n}\n\n/** Whether `target` takes typing: a field, a select, or editable content. */\nfunction takesTyping(target: EventTarget | null): boolean {\n const element = target as HTMLElement | null\n if (!element || typeof element.tagName !== 'string') return false\n const tag = element.tagName.toLowerCase()\n if (tag === 'input' || tag === 'textarea' || tag === 'select') return true\n return Boolean(element.isContentEditable) || element.getAttribute?.('contenteditable') === 'true'\n}\n\n/**\n * Something open over the editor that Esc should close first: a dialog, a\n * menu, a popover or a picker's list. MUI marks every one of them with these\n * roles; one kept mounted while closed sits inside a hidden modal.\n */\nconst OPEN_OVER_EDITOR =\n '[role=\"dialog\"], [role=\"alertdialog\"], [role=\"menu\"], [role=\"listbox\"], .MuiPopover-root'\nconst CLOSED = '.MuiModal-hidden, [aria-hidden=\"true\"], [hidden]'\n\nfunction somethingOpenOverEditor(doc: Pick<Document, 'querySelectorAll'>): boolean {\n return Array.from(doc.querySelectorAll(OPEN_OVER_EDITOR)).some(\n (element) => !element.closest(CLOSED),\n )\n}\n\n/**\n * Whether a key leaves the editor through its back control: Esc on its own\n * when nothing else wanted it, or ⌘[ (Ctrl+[ off a Mac) at any time.\n *\n * Esc never leaves while a field has the focus, while something is open over\n * the editor, or when the page already handled it (a pick in progress, an\n * inline editor reverting): those are the Esc a person meant for them.\n */\nexport function backKeyLeavesEditor(\n event: BackKeyEvent,\n doc: Pick<Document, 'querySelectorAll'>,\n mac: boolean,\n): boolean {\n if (event.defaultPrevented) return false\n if (event.key === '[') {\n const command = mac ? event.metaKey : event.ctrlKey\n return command && !event.altKey && !event.shiftKey\n }\n if (event.key !== 'Escape' && event.key !== 'Esc') return false\n if (event.metaKey || event.ctrlKey || event.altKey || event.shiftKey) return false\n if (takesTyping(event.target)) return false\n return !somethingOpenOverEditor(doc)\n}\n\n/** Presses the editor's back control; false when the page has none. */\nexport function pressBesignerBack(doc: Pick<Document, 'getElementById'>): boolean {\n const control = doc.getElementById(NATIVE_BESIGNER_BACK_CONTROL_ID)\n if (!control) return false\n control.click()\n return true\n}\n\n/** Whether this browser is on a Mac (where ⌘ is the command key). */\nfunction onMac(): boolean {\n if (typeof navigator === 'undefined') return false\n return /Mac|iPhone|iPad|iPod/.test(navigator.platform || navigator.userAgent || '')\n}\n\n/**\n * Inside the apps' web view, Esc and ⌘[ press the editor's back control.\n * Off (`enabled` false) it adds nothing, so a browser tab keeps Esc and ⌘[\n * exactly as they were.\n *\n * It listens after the page's own handlers (bubbling, on the window), so a\n * handler that took the key first stops it reaching here.\n */\nexport function useNativeBesignerBackKeys(enabled: boolean): void {\n useEffect(() => {\n if (!enabled || typeof window === 'undefined') return\n const mac = onMac()\n const onKeyDown = (event: KeyboardEvent) => {\n if (!backKeyLeavesEditor(event, document, mac)) return\n if (!pressBesignerBack(document)) return\n event.preventDefault()\n }\n window.addEventListener('keydown', onKeyDown)\n return () => window.removeEventListener('keydown', onKeyDown)\n }, [enabled])\n}\n"],"names":["useEffect","NATIVE_BESIGNER_BACK_CONTROL_ID","takesTyping","target","element","tagName","tag","toLowerCase","Boolean","isContentEditable","getAttribute","OPEN_OVER_EDITOR","CLOSED","somethingOpenOverEditor","doc","Array","from","querySelectorAll","some","closest","backKeyLeavesEditor","event","mac","defaultPrevented","key","command","metaKey","ctrlKey","altKey","shiftKey","pressBesignerBack","control","getElementById","click","onMac","navigator","test","platform","userAgent","useNativeBesignerBackKeys","enabled","window","onKeyDown","document","preventDefault","addEventListener","removeEventListener"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,SAAS,QAAQ,QAAO;AAEjC;;;;;;;;;;;;CAYC,GACD,OAAO,MAAMC,kCAAkC,sBAAqB;AAapE,2EAA2E,GAC3E,SAASC,YAAYC,MAA0B;IAC7C,MAAMC,UAAUD;IAChB,IAAI,CAACC,WAAW,OAAOA,QAAQC,OAAO,KAAK,UAAU,OAAO;IAC5D,MAAMC,MAAMF,QAAQC,OAAO,CAACE,WAAW;IACvC,IAAID,QAAQ,WAAWA,QAAQ,cAAcA,QAAQ,UAAU,OAAO;IACtE,OAAOE,QAAQJ,QAAQK,iBAAiB,KAAKL,CAAAA,QAAQM,YAAY,oBAApBN,QAAQM,YAAY,MAApBN,SAAuB,wBAAuB;AAC7F;AAEA;;;;CAIC,GACD,MAAMO,mBACJ;AACF,MAAMC,SAAS;AAEf,SAASC,wBAAwBC,GAAuC;IACtE,OAAOC,MAAMC,IAAI,CAACF,IAAIG,gBAAgB,CAACN,mBAAmBO,IAAI,CAC5D,CAACd,UAAY,CAACA,QAAQe,OAAO,CAACP;AAElC;AAEA;;;;;;;CAOC,GACD,OAAO,SAASQ,oBACdC,KAAmB,EACnBP,GAAuC,EACvCQ,GAAY;IAEZ,IAAID,MAAME,gBAAgB,EAAE,OAAO;IACnC,IAAIF,MAAMG,GAAG,KAAK,KAAK;QACrB,MAAMC,UAAUH,MAAMD,MAAMK,OAAO,GAAGL,MAAMM,OAAO;QACnD,OAAOF,WAAW,CAACJ,MAAMO,MAAM,IAAI,CAACP,MAAMQ,QAAQ;IACpD;IACA,IAAIR,MAAMG,GAAG,KAAK,YAAYH,MAAMG,GAAG,KAAK,OAAO,OAAO;IAC1D,IAAIH,MAAMK,OAAO,IAAIL,MAAMM,OAAO,IAAIN,MAAMO,MAAM,IAAIP,MAAMQ,QAAQ,EAAE,OAAO;IAC7E,IAAI3B,YAAYmB,MAAMlB,MAAM,GAAG,OAAO;IACtC,OAAO,CAACU,wBAAwBC;AAClC;AAEA,qEAAqE,GACrE,OAAO,SAASgB,kBAAkBhB,GAAqC;IACrE,MAAMiB,UAAUjB,IAAIkB,cAAc,CAAC/B;IACnC,IAAI,CAAC8B,SAAS,OAAO;IACrBA,QAAQE,KAAK;IACb,OAAO;AACT;AAEA,mEAAmE,GACnE,SAASC;IACP,IAAI,OAAOC,cAAc,aAAa,OAAO;IAC7C,OAAO,uBAAuBC,IAAI,CAACD,UAAUE,QAAQ,IAAIF,UAAUG,SAAS,IAAI;AAClF;AAEA;;;;;;;CAOC,GACD,OAAO,SAASC,0BAA0BC,OAAgB;IACxDxC,UAAU;QACR,IAAI,CAACwC,WAAW,OAAOC,WAAW,aAAa;QAC/C,MAAMnB,MAAMY;QACZ,MAAMQ,YAAY,CAACrB;YACjB,IAAI,CAACD,oBAAoBC,OAAOsB,UAAUrB,MAAM;YAChD,IAAI,CAACQ,kBAAkBa,WAAW;YAClCtB,MAAMuB,cAAc;QACtB;QACAH,OAAOI,gBAAgB,CAAC,WAAWH;QACnC,OAAO,IAAMD,OAAOK,mBAAmB,CAAC,WAAWJ;IACrD,GAAG;QAACF;KAAQ;AACd"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
/** Deep equality for node data, matching lodash's `isEqual` on it. */
|
|
18
|
+
export declare function plainDataEqual(left: unknown, right: unknown): boolean;
|
|
19
|
+
/** A deep copy of node data, matching lodash's `cloneDeep` on it. */
|
|
20
|
+
export declare function clonePlainData<T>(value: T): T;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/ /**
|
|
17
|
+
* Deep equality and a deep copy for node data, sized for every published page
|
|
18
|
+
* (AGL-4220).
|
|
19
|
+
*
|
|
20
|
+
* The canvas store is constructed on every published page, and it used
|
|
21
|
+
* lodash's `isEqual` and `cloneDeep` for this. Between them those two pulled
|
|
22
|
+
* about 120 lodash modules — tag tables, typed-array and buffer cloning,
|
|
23
|
+
* `Map`/`Set` caches and a cycle stack — onto the page, about 5 KB of the
|
|
24
|
+
* every-page wire weight, for values that are node documents: JSON-shaped
|
|
25
|
+
* objects and arrays, sometimes read through mobx proxies, occasionally a
|
|
26
|
+
* `Date`.
|
|
27
|
+
*
|
|
28
|
+
* Both functions answer what lodash answered for those values, and the spec
|
|
29
|
+
* holds them to lodash on the shapes nodes carry:
|
|
30
|
+
*
|
|
31
|
+
* - `NaN` equals `NaN`; `+0` equals `-0`.
|
|
32
|
+
* - An own key whose value is `undefined` is a key: `{ a: undefined }` is not
|
|
33
|
+
* `{}`.
|
|
34
|
+
* - Two objects with different prototypes differ; arrays never equal objects.
|
|
35
|
+
* - `Date`s compare by time and are copied as new `Date`s; `Map`s and `Set`s
|
|
36
|
+
* compare and copy by entries.
|
|
37
|
+
* - A function is kept by reference in a copy, as lodash keeps a nested one.
|
|
38
|
+
* - An object that is not an array, a `Date`, a `Map` or a `Set` is copied
|
|
39
|
+
* onto a fresh object with the same prototype, as lodash copies a class
|
|
40
|
+
* instance, own enumerable string and symbol keys included.
|
|
41
|
+
*
|
|
42
|
+
* Neither follows cycles: a node document has none, and lodash's stack for
|
|
43
|
+
* them is part of what this replaces.
|
|
44
|
+
*/ const ownKeys = (value)=>[
|
|
45
|
+
...Object.keys(value),
|
|
46
|
+
...Object.getOwnPropertySymbols(value).filter((symbol)=>Object.prototype.propertyIsEnumerable.call(value, symbol))
|
|
47
|
+
];
|
|
48
|
+
/** Deep equality for node data, matching lodash's `isEqual` on it. */ export function plainDataEqual(left, right) {
|
|
49
|
+
if (left === right) return true;
|
|
50
|
+
// NaN is the one value unequal to itself.
|
|
51
|
+
if (left !== left && right !== right) return true;
|
|
52
|
+
if (typeof left !== 'object' || typeof right !== 'object' || left === null || right === null) {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
if (Array.isArray(left) || Array.isArray(right)) {
|
|
56
|
+
if (!Array.isArray(left) || !Array.isArray(right)) return false;
|
|
57
|
+
if (left.length !== right.length) return false;
|
|
58
|
+
for(let at = 0; at < left.length; at++){
|
|
59
|
+
if (!plainDataEqual(left[at], right[at])) return false;
|
|
60
|
+
}
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
if (Object.getPrototypeOf(left) !== Object.getPrototypeOf(right)) return false;
|
|
64
|
+
if (left instanceof Date) {
|
|
65
|
+
return plainDataEqual(left.getTime(), right.getTime());
|
|
66
|
+
}
|
|
67
|
+
if (left instanceof Map) {
|
|
68
|
+
const other = right;
|
|
69
|
+
if (left.size !== other.size) return false;
|
|
70
|
+
for (const [key, value] of left){
|
|
71
|
+
if (!other.has(key) || !plainDataEqual(value, other.get(key))) return false;
|
|
72
|
+
}
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
if (left instanceof Set) {
|
|
76
|
+
const other = right;
|
|
77
|
+
if (left.size !== other.size) return false;
|
|
78
|
+
const unmatched = [
|
|
79
|
+
...other
|
|
80
|
+
];
|
|
81
|
+
for (const value of left){
|
|
82
|
+
const at = unmatched.findIndex((entry)=>plainDataEqual(value, entry));
|
|
83
|
+
if (at < 0) return false;
|
|
84
|
+
unmatched.splice(at, 1);
|
|
85
|
+
}
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
const keys = ownKeys(left);
|
|
89
|
+
if (keys.length !== ownKeys(right).length) return false;
|
|
90
|
+
for (const key of keys){
|
|
91
|
+
if (!Object.prototype.hasOwnProperty.call(right, key)) return false;
|
|
92
|
+
if (!plainDataEqual(left[key], right[key])) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
/** A deep copy of node data, matching lodash's `cloneDeep` on it. */ export function clonePlainData(value) {
|
|
99
|
+
if (typeof value !== 'object' || value === null) return value;
|
|
100
|
+
if (Array.isArray(value)) return value.map(clonePlainData);
|
|
101
|
+
if (value instanceof Date) return new Date(value.getTime());
|
|
102
|
+
if (value instanceof Map) {
|
|
103
|
+
return new Map([
|
|
104
|
+
...value
|
|
105
|
+
].map(([key, entry])=>[
|
|
106
|
+
key,
|
|
107
|
+
clonePlainData(entry)
|
|
108
|
+
]));
|
|
109
|
+
}
|
|
110
|
+
if (value instanceof Set) {
|
|
111
|
+
return new Set([
|
|
112
|
+
...value
|
|
113
|
+
].map(clonePlainData));
|
|
114
|
+
}
|
|
115
|
+
const copy = Object.create(Object.getPrototypeOf(value));
|
|
116
|
+
for (const key of ownKeys(value)){
|
|
117
|
+
copy[key] = clonePlainData(value[key]);
|
|
118
|
+
}
|
|
119
|
+
return copy;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
//# sourceMappingURL=plain-data.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/plain-data.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Deep equality and a deep copy for node data, sized for every published page\n * (AGL-4220).\n *\n * The canvas store is constructed on every published page, and it used\n * lodash's `isEqual` and `cloneDeep` for this. Between them those two pulled\n * about 120 lodash modules — tag tables, typed-array and buffer cloning,\n * `Map`/`Set` caches and a cycle stack — onto the page, about 5 KB of the\n * every-page wire weight, for values that are node documents: JSON-shaped\n * objects and arrays, sometimes read through mobx proxies, occasionally a\n * `Date`.\n *\n * Both functions answer what lodash answered for those values, and the spec\n * holds them to lodash on the shapes nodes carry:\n *\n * - `NaN` equals `NaN`; `+0` equals `-0`.\n * - An own key whose value is `undefined` is a key: `{ a: undefined }` is not\n * `{}`.\n * - Two objects with different prototypes differ; arrays never equal objects.\n * - `Date`s compare by time and are copied as new `Date`s; `Map`s and `Set`s\n * compare and copy by entries.\n * - A function is kept by reference in a copy, as lodash keeps a nested one.\n * - An object that is not an array, a `Date`, a `Map` or a `Set` is copied\n * onto a fresh object with the same prototype, as lodash copies a class\n * instance, own enumerable string and symbol keys included.\n *\n * Neither follows cycles: a node document has none, and lodash's stack for\n * them is part of what this replaces.\n */\n\nconst ownKeys = (value: object): PropertyKey[] => [\n ...Object.keys(value),\n ...Object.getOwnPropertySymbols(value).filter((symbol) =>\n Object.prototype.propertyIsEnumerable.call(value, symbol),\n ),\n]\n\n/** Deep equality for node data, matching lodash's `isEqual` on it. */\nexport function plainDataEqual(left: unknown, right: unknown): boolean {\n if (left === right) return true\n // NaN is the one value unequal to itself.\n if (left !== left && right !== right) return true\n if (\n typeof left !== 'object' ||\n typeof right !== 'object' ||\n left === null ||\n right === null\n ) {\n return false\n }\n if (Array.isArray(left) || Array.isArray(right)) {\n if (!Array.isArray(left) || !Array.isArray(right)) return false\n if (left.length !== right.length) return false\n for (let at = 0; at < left.length; at++) {\n if (!plainDataEqual(left[at], right[at])) return false\n }\n return true\n }\n if (Object.getPrototypeOf(left) !== Object.getPrototypeOf(right)) return false\n if (left instanceof Date) {\n return plainDataEqual(left.getTime(), (right as Date).getTime())\n }\n if (left instanceof Map) {\n const other = right as Map<unknown, unknown>\n if (left.size !== other.size) return false\n for (const [key, value] of left) {\n if (!other.has(key) || !plainDataEqual(value, other.get(key)))\n return false\n }\n return true\n }\n if (left instanceof Set) {\n const other = right as Set<unknown>\n if (left.size !== other.size) return false\n const unmatched = [...other]\n for (const value of left) {\n const at = unmatched.findIndex((entry) => plainDataEqual(value, entry))\n if (at < 0) return false\n unmatched.splice(at, 1)\n }\n return true\n }\n const keys = ownKeys(left)\n if (keys.length !== ownKeys(right).length) return false\n for (const key of keys) {\n if (!Object.prototype.hasOwnProperty.call(right, key)) return false\n if (\n !plainDataEqual(\n (left as Record<PropertyKey, unknown>)[key],\n (right as Record<PropertyKey, unknown>)[key],\n )\n ) {\n return false\n }\n }\n return true\n}\n\n/** A deep copy of node data, matching lodash's `cloneDeep` on it. */\nexport function clonePlainData<T>(value: T): T {\n if (typeof value !== 'object' || value === null) return value\n if (Array.isArray(value)) return value.map(clonePlainData) as T\n if (value instanceof Date) return new Date(value.getTime()) as T\n if (value instanceof Map) {\n return new Map(\n [...value].map(([key, entry]) => [key, clonePlainData(entry)]),\n ) as T\n }\n if (value instanceof Set) {\n return new Set([...value].map(clonePlainData)) as T\n }\n const copy = Object.create(Object.getPrototypeOf(value)) as Record<\n PropertyKey,\n unknown\n >\n for (const key of ownKeys(value)) {\n copy[key] = clonePlainData((value as Record<PropertyKey, unknown>)[key])\n }\n return copy as T\n}\n"],"names":["ownKeys","value","Object","keys","getOwnPropertySymbols","filter","symbol","prototype","propertyIsEnumerable","call","plainDataEqual","left","right","Array","isArray","length","at","getPrototypeOf","Date","getTime","Map","other","size","key","has","get","Set","unmatched","findIndex","entry","splice","hasOwnProperty","clonePlainData","map","copy","create"],"mappings":"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"}
|
|
@@ -18,7 +18,7 @@ import { _ as _object_without_properties_loose } from "@swc/helpers/_/_object_wi
|
|
|
18
18
|
*/ import { resolveAuthoredEventName, sanitizeEventParams } from "./analytics-events.js";
|
|
19
19
|
import { sanitizeAuthorHtml } from "./author-html.js";
|
|
20
20
|
import { expressionSyntaxError } from "./functions.js";
|
|
21
|
-
import { PLUGIN_INTERACTION_STEPS_DECLARED } from "../plugin-manager/first-party-
|
|
21
|
+
import { PLUGIN_INTERACTION_STEPS_DECLARED } from "../plugin-manager/first-party-plugin-interactions.generated.js";
|
|
22
22
|
import { isKnownInteractionRecipe } from "../plugin-manager/interaction-recipes.js";
|
|
23
23
|
/**
|
|
24
24
|
* SITE INTERACTIONS: what a published page does when a visitor does something.
|