treeloom 0.0.0-stage → 2.1.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.
Files changed (289) hide show
  1. package/LICENSE +373 -0
  2. package/README.md +91 -2
  3. package/browser/treeloom.js +11232 -0
  4. package/browser/treeloom.min.js +1 -0
  5. package/browser/treeloomRenderOnly.js +11115 -0
  6. package/browser/treeloomRenderOnly.min.js +1 -0
  7. package/dist/deflate/domItemToJson.d.ts +14 -0
  8. package/dist/deflate/domItemToJson.js +43 -0
  9. package/dist/deflate/domItemToJson.min.js +1 -0
  10. package/dist/deflate/index.d.ts +7 -0
  11. package/dist/deflate/index.js +19 -0
  12. package/dist/deflate/index.min.js +1 -0
  13. package/dist/deflate/removeEmptyProperties.d.ts +8 -0
  14. package/dist/deflate/removeEmptyProperties.js +43 -0
  15. package/dist/deflate/removeEmptyProperties.min.js +1 -0
  16. package/dist/diff/appliedSnapshot.d.ts +34 -0
  17. package/dist/diff/appliedSnapshot.js +134 -0
  18. package/dist/diff/appliedSnapshot.min.js +1 -0
  19. package/dist/diff/createChangeList.d.ts +9 -0
  20. package/dist/diff/createChangeList.js +44 -0
  21. package/dist/diff/createChangeList.min.js +1 -0
  22. package/dist/diff/domItemChanges.d.ts +9 -0
  23. package/dist/diff/domItemChanges.js +167 -0
  24. package/dist/diff/domItemChanges.min.js +1 -0
  25. package/dist/diff/domItemHasAttribute.d.ts +11 -0
  26. package/dist/diff/domItemHasAttribute.js +63 -0
  27. package/dist/diff/domItemHasAttribute.min.js +1 -0
  28. package/dist/diff/elementChanges.d.ts +10 -0
  29. package/dist/diff/elementChanges.js +151 -0
  30. package/dist/diff/elementChanges.min.js +1 -0
  31. package/dist/diff/elementHasAttribute.d.ts +10 -0
  32. package/dist/diff/elementHasAttribute.js +70 -0
  33. package/dist/diff/elementHasAttribute.min.js +1 -0
  34. package/dist/diff/getAssignedStyles.d.ts +9 -0
  35. package/dist/diff/getAssignedStyles.js +22 -0
  36. package/dist/diff/getAssignedStyles.min.js +1 -0
  37. package/dist/diff/index.d.ts +9 -0
  38. package/dist/diff/index.js +27 -0
  39. package/dist/diff/index.min.js +1 -0
  40. package/dist/diff/types.d.ts +17 -0
  41. package/dist/diff/types.js +8 -0
  42. package/dist/diff/types.min.js +1 -0
  43. package/dist/domItem/index.d.ts +34 -0
  44. package/dist/domItem/index.js +81 -0
  45. package/dist/domItem/index.min.js +1 -0
  46. package/dist/domItem/objects/addDomItemProperties.d.ts +7 -0
  47. package/dist/domItem/objects/addDomItemProperties.js +27 -0
  48. package/dist/domItem/objects/addDomItemProperties.min.js +1 -0
  49. package/dist/domItem/objects/createCoreItem.d.ts +9 -0
  50. package/dist/domItem/objects/createCoreItem.js +53 -0
  51. package/dist/domItem/objects/createCoreItem.min.js +1 -0
  52. package/dist/domItem/objects/createDomItem.d.ts +10 -0
  53. package/dist/domItem/objects/createDomItem.js +40 -0
  54. package/dist/domItem/objects/createDomItem.min.js +1 -0
  55. package/dist/domItem/objects/documentDomItem.d.ts +12 -0
  56. package/dist/domItem/objects/documentDomItem.js +36 -0
  57. package/dist/domItem/objects/documentDomItem.min.js +1 -0
  58. package/dist/domItem/objects/documentItem.d.ts +18 -0
  59. package/dist/domItem/objects/documentItem.js +40 -0
  60. package/dist/domItem/objects/documentItem.min.js +1 -0
  61. package/dist/domItem/objects/initChildren.d.ts +6 -0
  62. package/dist/domItem/objects/initChildren.js +44 -0
  63. package/dist/domItem/objects/initChildren.min.js +1 -0
  64. package/dist/domItem/objects/initRoot.d.ts +9 -0
  65. package/dist/domItem/objects/initRoot.js +32 -0
  66. package/dist/domItem/objects/initRoot.min.js +1 -0
  67. package/dist/domItem/query/gatherChildItems.d.ts +12 -0
  68. package/dist/domItem/query/gatherChildItems.js +19 -0
  69. package/dist/domItem/query/gatherChildItems.min.js +1 -0
  70. package/dist/domItem/query/getChildTest.d.ts +8 -0
  71. package/dist/domItem/query/getChildTest.js +15 -0
  72. package/dist/domItem/query/getChildTest.min.js +1 -0
  73. package/dist/domItem/query/getChildrenByClass.d.ts +11 -0
  74. package/dist/domItem/query/getChildrenByClass.js +26 -0
  75. package/dist/domItem/query/getChildrenByClass.min.js +1 -0
  76. package/dist/domItem/query/getChildrenByName.d.ts +9 -0
  77. package/dist/domItem/query/getChildrenByName.js +23 -0
  78. package/dist/domItem/query/getChildrenByName.min.js +1 -0
  79. package/dist/domItem/query/getChildrenFromAttribute.d.ts +13 -0
  80. package/dist/domItem/query/getChildrenFromAttribute.js +28 -0
  81. package/dist/domItem/query/getChildrenFromAttribute.min.js +1 -0
  82. package/dist/domItem/query/getItemByElement.d.ts +11 -0
  83. package/dist/domItem/query/getItemByElement.js +29 -0
  84. package/dist/domItem/query/getItemByElement.min.js +1 -0
  85. package/dist/domItem/query/getParentsByClass.d.ts +12 -0
  86. package/dist/domItem/query/getParentsByClass.js +40 -0
  87. package/dist/domItem/query/getParentsByClass.min.js +1 -0
  88. package/dist/domItem/query/getParentsByName.d.ts +9 -0
  89. package/dist/domItem/query/getParentsByName.js +23 -0
  90. package/dist/domItem/query/getParentsByName.min.js +1 -0
  91. package/dist/domItem/query/getParentsByTagName.d.ts +9 -0
  92. package/dist/domItem/query/getParentsByTagName.js +23 -0
  93. package/dist/domItem/query/getParentsByTagName.min.js +1 -0
  94. package/dist/domItem/query/getParentsFromAttribute.d.ts +13 -0
  95. package/dist/domItem/query/getParentsFromAttribute.js +39 -0
  96. package/dist/domItem/query/getParentsFromAttribute.min.js +1 -0
  97. package/dist/domItem/traits/defineTrait.d.ts +10 -0
  98. package/dist/domItem/traits/defineTrait.js +26 -0
  99. package/dist/domItem/traits/defineTrait.min.js +1 -0
  100. package/dist/domItem/traits/definitions.d.ts +7 -0
  101. package/dist/domItem/traits/definitions.js +20 -0
  102. package/dist/domItem/traits/definitions.min.js +1 -0
  103. package/dist/domItem/traits/getNonSerializableKeys.d.ts +9 -0
  104. package/dist/domItem/traits/getNonSerializableKeys.js +25 -0
  105. package/dist/domItem/traits/getNonSerializableKeys.min.js +1 -0
  106. package/dist/domItem/traits/getTraitDefinition.d.ts +7 -0
  107. package/dist/domItem/traits/getTraitDefinition.js +20 -0
  108. package/dist/domItem/traits/getTraitDefinition.min.js +1 -0
  109. package/dist/domItem/traits/hasTrait.d.ts +8 -0
  110. package/dist/domItem/traits/hasTrait.js +15 -0
  111. package/dist/domItem/traits/hasTrait.min.js +1 -0
  112. package/dist/domItem/traits/hasTraits.d.ts +9 -0
  113. package/dist/domItem/traits/hasTraits.js +16 -0
  114. package/dist/domItem/traits/hasTraits.min.js +1 -0
  115. package/dist/domItem/traits/isDomItem.d.ts +8 -0
  116. package/dist/domItem/traits/isDomItem.js +21 -0
  117. package/dist/domItem/traits/isDomItem.min.js +1 -0
  118. package/dist/domItem/traits/withTrait.d.ts +11 -0
  119. package/dist/domItem/traits/withTrait.js +30 -0
  120. package/dist/domItem/traits/withTrait.min.js +1 -0
  121. package/dist/domItem/tree/appendChild.d.ts +8 -0
  122. package/dist/domItem/tree/appendChild.js +19 -0
  123. package/dist/domItem/tree/appendChild.min.js +1 -0
  124. package/dist/domItem/tree/getItemByPath.d.ts +10 -0
  125. package/dist/domItem/tree/getItemByPath.js +23 -0
  126. package/dist/domItem/tree/getItemByPath.min.js +1 -0
  127. package/dist/domItem/tree/getItemPath.d.ts +9 -0
  128. package/dist/domItem/tree/getItemPath.js +31 -0
  129. package/dist/domItem/tree/getItemPath.min.js +1 -0
  130. package/dist/domItem/tree/getTopParentItem.d.ts +8 -0
  131. package/dist/domItem/tree/getTopParentItem.js +29 -0
  132. package/dist/domItem/tree/getTopParentItem.min.js +1 -0
  133. package/dist/domItem/tree/insertChild.d.ts +11 -0
  134. package/dist/domItem/tree/insertChild.js +22 -0
  135. package/dist/domItem/tree/insertChild.min.js +1 -0
  136. package/dist/domItem/tree/itemIdIndex.d.ts +43 -0
  137. package/dist/domItem/tree/itemIdIndex.js +118 -0
  138. package/dist/domItem/tree/itemIdIndex.min.js +1 -0
  139. package/dist/domItem/tree/removeChild.d.ts +8 -0
  140. package/dist/domItem/tree/removeChild.js +21 -0
  141. package/dist/domItem/tree/removeChild.min.js +1 -0
  142. package/dist/domItem/tree/setParentItemReferences.d.ts +7 -0
  143. package/dist/domItem/tree/setParentItemReferences.js +24 -0
  144. package/dist/domItem/tree/setParentItemReferences.min.js +1 -0
  145. package/dist/domItem/types.d.ts +131 -0
  146. package/dist/domItem/types.js +8 -0
  147. package/dist/domItem/types.min.js +1 -0
  148. package/dist/events/functions/activateListener.d.ts +10 -0
  149. package/dist/events/functions/activateListener.js +45 -0
  150. package/dist/events/functions/activateListener.min.js +1 -0
  151. package/dist/events/functions/addEventListener.d.ts +23 -0
  152. package/dist/events/functions/addEventListener.js +54 -0
  153. package/dist/events/functions/addEventListener.min.js +1 -0
  154. package/dist/events/functions/applyActiveListeners.d.ts +9 -0
  155. package/dist/events/functions/applyActiveListeners.js +52 -0
  156. package/dist/events/functions/applyActiveListeners.min.js +1 -0
  157. package/dist/events/functions/assignListener.d.ts +12 -0
  158. package/dist/events/functions/assignListener.js +39 -0
  159. package/dist/events/functions/assignListener.min.js +1 -0
  160. package/dist/events/functions/bindAllListeners.d.ts +10 -0
  161. package/dist/events/functions/bindAllListeners.js +28 -0
  162. package/dist/events/functions/bindAllListeners.min.js +1 -0
  163. package/dist/events/functions/bindElementListeners.d.ts +7 -0
  164. package/dist/events/functions/bindElementListeners.js +34 -0
  165. package/dist/events/functions/bindElementListeners.min.js +1 -0
  166. package/dist/events/functions/bindListeners.d.ts +9 -0
  167. package/dist/events/functions/bindListeners.js +23 -0
  168. package/dist/events/functions/bindListeners.min.js +1 -0
  169. package/dist/events/functions/deactivateListener.d.ts +13 -0
  170. package/dist/events/functions/deactivateListener.js +58 -0
  171. package/dist/events/functions/deactivateListener.min.js +1 -0
  172. package/dist/events/functions/deactivateListeners.d.ts +7 -0
  173. package/dist/events/functions/deactivateListeners.js +22 -0
  174. package/dist/events/functions/deactivateListeners.min.js +1 -0
  175. package/dist/events/functions/findEventListener.d.ts +22 -0
  176. package/dist/events/functions/findEventListener.js +61 -0
  177. package/dist/events/functions/findEventListener.min.js +1 -0
  178. package/dist/events/functions/fullAddEventListener.d.ts +20 -0
  179. package/dist/events/functions/fullAddEventListener.js +45 -0
  180. package/dist/events/functions/fullAddEventListener.min.js +1 -0
  181. package/dist/events/functions/fullRemoveEventListener.d.ts +22 -0
  182. package/dist/events/functions/fullRemoveEventListener.js +37 -0
  183. package/dist/events/functions/fullRemoveEventListener.min.js +1 -0
  184. package/dist/events/functions/listenerOptions.d.ts +12 -0
  185. package/dist/events/functions/listenerOptions.js +31 -0
  186. package/dist/events/functions/listenerOptions.min.js +1 -0
  187. package/dist/events/functions/makeEventHandler.d.ts +10 -0
  188. package/dist/events/functions/makeEventHandler.js +23 -0
  189. package/dist/events/functions/makeEventHandler.min.js +1 -0
  190. package/dist/events/functions/makeForwardingListener.d.ts +11 -0
  191. package/dist/events/functions/makeForwardingListener.js +46 -0
  192. package/dist/events/functions/makeForwardingListener.min.js +1 -0
  193. package/dist/events/functions/receiveForwardedEvent.d.ts +23 -0
  194. package/dist/events/functions/receiveForwardedEvent.js +40 -0
  195. package/dist/events/functions/receiveForwardedEvent.min.js +1 -0
  196. package/dist/events/functions/registerListener.d.ts +11 -0
  197. package/dist/events/functions/registerListener.js +25 -0
  198. package/dist/events/functions/registerListener.min.js +1 -0
  199. package/dist/events/functions/registerListeners.d.ts +10 -0
  200. package/dist/events/functions/registerListeners.js +26 -0
  201. package/dist/events/functions/registerListeners.min.js +1 -0
  202. package/dist/events/functions/removeEventListener.d.ts +18 -0
  203. package/dist/events/functions/removeEventListener.js +42 -0
  204. package/dist/events/functions/removeEventListener.min.js +1 -0
  205. package/dist/events/functions/retrieveListener.d.ts +14 -0
  206. package/dist/events/functions/retrieveListener.js +39 -0
  207. package/dist/events/functions/retrieveListener.min.js +1 -0
  208. package/dist/events/functions/revokeActiveListeners.d.ts +12 -0
  209. package/dist/events/functions/revokeActiveListeners.js +54 -0
  210. package/dist/events/functions/revokeActiveListeners.min.js +1 -0
  211. package/dist/events/functions/setForwardEvents.d.ts +11 -0
  212. package/dist/events/functions/setForwardEvents.js +26 -0
  213. package/dist/events/functions/setForwardEvents.min.js +1 -0
  214. package/dist/events/functions/unassignListener.d.ts +12 -0
  215. package/dist/events/functions/unassignListener.js +32 -0
  216. package/dist/events/functions/unassignListener.min.js +1 -0
  217. package/dist/events/index.d.ts +37 -0
  218. package/dist/events/index.js +72 -0
  219. package/dist/events/index.min.js +1 -0
  220. package/dist/events/objects/createEventListener.d.ts +13 -0
  221. package/dist/events/objects/createEventListener.js +30 -0
  222. package/dist/events/objects/createEventListener.min.js +1 -0
  223. package/dist/events/objects/createEventProxy.d.ts +10 -0
  224. package/dist/events/objects/createEventProxy.js +48 -0
  225. package/dist/events/objects/createEventProxy.min.js +1 -0
  226. package/dist/events/objects/createEventResponder.d.ts +8 -0
  227. package/dist/events/objects/createEventResponder.js +27 -0
  228. package/dist/events/objects/createEventResponder.min.js +1 -0
  229. package/dist/events/objects/options/getListenerOptions.d.ts +6 -0
  230. package/dist/events/objects/options/getListenerOptions.js +22 -0
  231. package/dist/events/objects/options/getListenerOptions.min.js +1 -0
  232. package/dist/events/objects/options/numberToOptions.d.ts +8 -0
  233. package/dist/events/objects/options/numberToOptions.js +21 -0
  234. package/dist/events/objects/options/numberToOptions.min.js +1 -0
  235. package/dist/events/objects/options/optionsToNumber.d.ts +9 -0
  236. package/dist/events/objects/options/optionsToNumber.js +27 -0
  237. package/dist/events/objects/options/optionsToNumber.min.js +1 -0
  238. package/dist/events/objects/options.d.ts +6 -0
  239. package/dist/events/objects/options.js +24 -0
  240. package/dist/events/objects/options.min.js +1 -0
  241. package/dist/events/types.d.ts +87 -0
  242. package/dist/events/types.js +8 -0
  243. package/dist/events/types.min.js +1 -0
  244. package/dist/inflate/index.d.ts +4 -0
  245. package/dist/inflate/index.js +17 -0
  246. package/dist/inflate/index.min.js +1 -0
  247. package/dist/inflate/jsonToDomItem.d.ts +7 -0
  248. package/dist/inflate/jsonToDomItem.js +30 -0
  249. package/dist/inflate/jsonToDomItem.min.js +1 -0
  250. package/dist/main.d.ts +2 -0
  251. package/dist/main.js +24 -0
  252. package/dist/main.min.js +1 -0
  253. package/dist/render/generateElement.d.ts +7 -0
  254. package/dist/render/generateElement.js +41 -0
  255. package/dist/render/generateElement.min.js +1 -0
  256. package/dist/render/index.d.ts +9 -0
  257. package/dist/render/index.js +27 -0
  258. package/dist/render/index.min.js +1 -0
  259. package/dist/render/reconcile.d.ts +16 -0
  260. package/dist/render/reconcile.js +169 -0
  261. package/dist/render/reconcile.min.js +1 -0
  262. package/dist/render/renderHtml.d.ts +16 -0
  263. package/dist/render/renderHtml.js +57 -0
  264. package/dist/render/renderHtml.min.js +1 -0
  265. package/dist/render/updateChildNodes.d.ts +7 -0
  266. package/dist/render/updateChildNodes.js +53 -0
  267. package/dist/render/updateChildNodes.min.js +1 -0
  268. package/dist/render/updateElement.d.ts +14 -0
  269. package/dist/render/updateElement.js +113 -0
  270. package/dist/render/updateElement.min.js +1 -0
  271. package/dist/render/updateElements.d.ts +9 -0
  272. package/dist/render/updateElements.js +33 -0
  273. package/dist/render/updateElements.min.js +1 -0
  274. package/dist/renderOnly.d.ts +2 -0
  275. package/dist/renderOnly.js +27 -0
  276. package/dist/renderOnly.min.js +1 -0
  277. package/dist/sync/index.d.ts +6 -0
  278. package/dist/sync/index.js +21 -0
  279. package/dist/sync/index.min.js +1 -0
  280. package/dist/sync/updateChildren.d.ts +7 -0
  281. package/dist/sync/updateChildren.js +38 -0
  282. package/dist/sync/updateChildren.min.js +1 -0
  283. package/dist/sync/updateDomItem.d.ts +8 -0
  284. package/dist/sync/updateDomItem.js +53 -0
  285. package/dist/sync/updateDomItem.min.js +1 -0
  286. package/dist/sync/updateDomItems.d.ts +9 -0
  287. package/dist/sync/updateDomItems.js +33 -0
  288. package/dist/sync/updateDomItems.min.js +1 -0
  289. package/package.json +74 -4
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ /* This Source Code Form is subject to the terms of the Mozilla Public
4
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
5
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
6
+ var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
7
+ return mod && mod.__esModule ? mod : {
8
+ "default": mod
9
+ };
10
+ };
11
+ Object.defineProperty(exports, "__esModule", {
12
+ value: true
13
+ });
14
+ const createDomItem_1 = __importDefault(require("./createDomItem"));
15
+ const onBodyLoad_1 = __importDefault(require("si-funciona/dist/helpers/functions/onBodyLoad"));
16
+ /**
17
+ * Initiate the children of Root / DocumentItem. This is a helper for {@link documentDomItem}.
18
+ */
19
+ const initChildren = () => {
20
+ const head = document.head;
21
+ const body = document.body;
22
+ const children = [(0, createDomItem_1.default)({
23
+ nodeName: 'head',
24
+ attributes: {},
25
+ element: head,
26
+ children: []
27
+ }), (0, createDomItem_1.default)({
28
+ nodeName: 'body',
29
+ attributes: {},
30
+ element: body,
31
+ children: []
32
+ })];
33
+ if (!head || !body) {
34
+ (0, onBodyLoad_1.default)(() => {
35
+ if (children[1].element === null) {
36
+ children[0].element = document.head;
37
+ children[1].element = document.body;
38
+ }
39
+ return children;
40
+ });
41
+ }
42
+ return children;
43
+ };
44
+ exports.default = initChildren;
@@ -0,0 +1 @@
1
+ "use strict";var __importDefault=function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});const createDomItem_1=__importDefault(require("./createDomItem")),onBodyLoad_1=__importDefault(require("si-funciona/dist/helpers/functions/onBodyLoad")),initChildren=()=>{const e=document.head,t=document.body,o=[(0,createDomItem_1.default)({nodeName:"head",attributes:{},element:e,children:[]}),(0,createDomItem_1.default)({nodeName:"body",attributes:{},element:t,children:[]})];return e&&t||(0,onBodyLoad_1.default)(()=>(null===o[1].element&&(o[0].element=document.head,o[1].element=document.body),o)),o};exports.default=initChildren;
@@ -0,0 +1,9 @@
1
+ import type { DomItem, DomItemRoot } from '../types';
2
+ import type { ListenerFunction } from '../../events/types';
3
+ /**
4
+ * Initiate the Root for DocumentItem. This is primary a helper for {@link documentDomItem}.
5
+ * @param children - Provide an array of Head and Body (usually via {@link initChildren})
6
+ * @param listeners - An object of all event listeners to be registered in the Dom
7
+ */
8
+ declare const initRoot: (children?: DomItem[], listeners?: Record<string, ListenerFunction>) => DomItemRoot;
9
+ export default initRoot;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ /* This Source Code Form is subject to the terms of the Mozilla Public
4
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
5
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
6
+ var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
7
+ return mod && mod.__esModule ? mod : {
8
+ "default": mod
9
+ };
10
+ };
11
+ Object.defineProperty(exports, "__esModule", {
12
+ value: true
13
+ });
14
+ const createDomItem_1 = __importDefault(require("./createDomItem"));
15
+ /**
16
+ * Initiate the Root for DocumentItem. This is primary a helper for {@link documentDomItem}.
17
+ * @param children - Provide an array of Head and Body (usually via {@link initChildren})
18
+ * @param listeners - An object of all event listeners to be registered in the Dom
19
+ */
20
+ const initRoot = (children = [{}, {}], listeners = {}) => (0, createDomItem_1.default)({
21
+ nodeName: '#document',
22
+ nodeValue: null,
23
+ attributes: {},
24
+ element: document,
25
+ eventActions: listeners,
26
+ eventListeners: {},
27
+ children,
28
+ parentItem: {},
29
+ head: children[0],
30
+ body: children[1]
31
+ });
32
+ exports.default = initRoot;
@@ -0,0 +1 @@
1
+ "use strict";var __importDefault=function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});const createDomItem_1=__importDefault(require("./createDomItem")),initRoot=(e=[{},{}],t={})=>(0,createDomItem_1.default)({nodeName:"#document",nodeValue:null,attributes:{},element:document,eventActions:t,eventListeners:{},children:e,parentItem:{},head:e[0],body:e[1]});exports.default=initRoot;
@@ -0,0 +1,12 @@
1
+ import type { ChildTest, DomItem } from '../types';
2
+ /**
3
+ * A selector function for retrieving existing child domGeneral.DomItems from the given parent item.
4
+ * This function will check all the children starting from and including item, and run the test function on each
5
+ * child encountered. The return array contains children returned from the test from all levels.
6
+ * WARNING: This is a recursive function.
7
+ * @param item - The DomItem which may have child items matching the attribute
8
+ * criteria
9
+ * @param test - Assess each child, and return the ones which qualify
10
+ */
11
+ declare const gatherChildItems: (item: DomItem, test: ChildTest) => DomItem[];
12
+ export default gatherChildItems;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ /* This Source Code Form is subject to the terms of the Mozilla Public
4
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
5
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
6
+ Object.defineProperty(exports, "__esModule", {
7
+ value: true
8
+ });
9
+ /**
10
+ * A selector function for retrieving existing child domGeneral.DomItems from the given parent item.
11
+ * This function will check all the children starting from and including item, and run the test function on each
12
+ * child encountered. The return array contains children returned from the test from all levels.
13
+ * WARNING: This is a recursive function.
14
+ * @param item - The DomItem which may have child items matching the attribute
15
+ * criteria
16
+ * @param test - Assess each child, and return the ones which qualify
17
+ */
18
+ const gatherChildItems = (item, test) => test(item, item.children.reduce((a, b) => a.concat(gatherChildItems(b, test)), []));
19
+ exports.default = gatherChildItems;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const gatherChildItems=(e,t)=>t(e,e.children.reduce((e,r)=>e.concat(gatherChildItems(r,t)),[]));exports.default=gatherChildItems;
@@ -0,0 +1,8 @@
1
+ import type { ChildTest } from '../types';
2
+ /**
3
+ * Retrieve the {@link module:domGeneral~testChildItem} function by providing an attribute and value to check.
4
+ * @param attr - Provide the attribute name to be searched
5
+ * @param value - The attribute value to be compared
6
+ */
7
+ declare const getChildTest: (attr: string, value: unknown) => ChildTest;
8
+ export default getChildTest;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ /* This Source Code Form is subject to the terms of the Mozilla Public
4
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
5
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
6
+ Object.defineProperty(exports, "__esModule", {
7
+ value: true
8
+ });
9
+ /**
10
+ * Retrieve the {@link module:domGeneral~testChildItem} function by providing an attribute and value to check.
11
+ * @param attr - Provide the attribute name to be searched
12
+ * @param value - The attribute value to be compared
13
+ */
14
+ const getChildTest = (attr, value) => (item, gatheredResults) => item.attributes[attr] && item.attributes[attr] === value ? gatheredResults.concat([item]) : gatheredResults;
15
+ exports.default = getChildTest;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const getChildTest=(t,e)=>(s,r)=>s.attributes[t]&&s.attributes[t]===e?r.concat([s]):r;exports.default=getChildTest;
@@ -0,0 +1,11 @@
1
+ import type { DomItem } from '../types';
2
+ /**
3
+ * Helper for getting all domGeneral.DomItems starting at item and carrying the given class, among possibly several
4
+ * space-separated classes on that item - the same membership check as the real DOM's classList.contains, not an
5
+ * exact match of the whole className attribute string (which getChildrenFromAttribute does, and which would miss
6
+ * an item that also carries other classes).
7
+ * @param className - The one class being searched for
8
+ * @param item - The DomItem which may have child items carrying the class
9
+ */
10
+ declare const getChildrenByClass: (className: string, item?: DomItem) => DomItem[];
11
+ export default getChildrenByClass;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ /* This Source Code Form is subject to the terms of the Mozilla Public
4
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
5
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
6
+ require("core-js/modules/es.array.includes.js");
7
+ var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
8
+ return mod && mod.__esModule ? mod : {
9
+ "default": mod
10
+ };
11
+ };
12
+ Object.defineProperty(exports, "__esModule", {
13
+ value: true
14
+ });
15
+ const documentItem_1 = __importDefault(require("../objects/documentItem"));
16
+ const gatherChildItems_1 = __importDefault(require("./gatherChildItems"));
17
+ /**
18
+ * Helper for getting all domGeneral.DomItems starting at item and carrying the given class, among possibly several
19
+ * space-separated classes on that item - the same membership check as the real DOM's classList.contains, not an
20
+ * exact match of the whole className attribute string (which getChildrenFromAttribute does, and which would miss
21
+ * an item that also carries other classes).
22
+ * @param className - The one class being searched for
23
+ * @param item - The DomItem which may have child items carrying the class
24
+ */
25
+ const getChildrenByClass = (className, item = (0, documentItem_1.default)().body) => (0, gatherChildItems_1.default)(item, (child, gatheredResults) => (child.attributes.className ?? '').split(' ').includes(className) ? gatheredResults.concat([child]) : gatheredResults);
26
+ exports.default = getChildrenByClass;
@@ -0,0 +1 @@
1
+ "use strict";require("core-js/modules/es.array.includes.js");var __importDefault=function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});const documentItem_1=__importDefault(require("../objects/documentItem")),gatherChildItems_1=__importDefault(require("./gatherChildItems")),getChildrenByClass=(e,t=(0,documentItem_1.default)().body)=>(0,gatherChildItems_1.default)(t,(t,r)=>(t.attributes.className??"").split(" ").includes(e)?r.concat([t]):r);exports.default=getChildrenByClass;
@@ -0,0 +1,9 @@
1
+ import type { DomItem } from '../types';
2
+ /**
3
+ * Helper for getting all domGeneral.DomItems starting at parent and having specified name attribute
4
+ * @param name - The name searched for
5
+ * @param item - The DomItem which may have child items matching the attribute
6
+ * criteria
7
+ */
8
+ declare const getChildrenByName: (name: string, item?: DomItem) => DomItem[];
9
+ export default getChildrenByName;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ /* This Source Code Form is subject to the terms of the Mozilla Public
4
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
5
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
6
+ var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
7
+ return mod && mod.__esModule ? mod : {
8
+ "default": mod
9
+ };
10
+ };
11
+ Object.defineProperty(exports, "__esModule", {
12
+ value: true
13
+ });
14
+ const si_funciona_1 = __importDefault(require("si-funciona"));
15
+ const getChildrenFromAttribute_1 = __importDefault(require("./getChildrenFromAttribute"));
16
+ /**
17
+ * Helper for getting all domGeneral.DomItems starting at parent and having specified name attribute
18
+ * @param name - The name searched for
19
+ * @param item - The DomItem which may have child items matching the attribute
20
+ * criteria
21
+ */
22
+ const getChildrenByName = si_funciona_1.default.curry(getChildrenFromAttribute_1.default)('name');
23
+ exports.default = getChildrenByName;
@@ -0,0 +1 @@
1
+ "use strict";var __importDefault=function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});const si_funciona_1=__importDefault(require("si-funciona")),getChildrenFromAttribute_1=__importDefault(require("./getChildrenFromAttribute")),getChildrenByName=si_funciona_1.default.curry(getChildrenFromAttribute_1.default)("name");exports.default=getChildrenByName;
@@ -0,0 +1,13 @@
1
+ import type { DomItem } from '../types';
2
+ /**
3
+ * A selector function for retrieving existing child domGeneral.DomItems from the given parent item.
4
+ * This function will check all the children starting from item, and scan the attributes
5
+ * property for matches. The returned array contains children matching from all levels.
6
+ * WARNING: This calls a recursive function.
7
+ * @param attr - Provide the attribute name to be searched
8
+ * @param value - The attribute value to be compared
9
+ * @param item - The DomItem which may have child items matching the attribute
10
+ * criteria
11
+ */
12
+ declare const getChildrenFromAttribute: (attr: string, value: unknown, item?: DomItem) => DomItem[];
13
+ export default getChildrenFromAttribute;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ /* This Source Code Form is subject to the terms of the Mozilla Public
4
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
5
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
6
+ var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
7
+ return mod && mod.__esModule ? mod : {
8
+ "default": mod
9
+ };
10
+ };
11
+ Object.defineProperty(exports, "__esModule", {
12
+ value: true
13
+ });
14
+ const documentItem_1 = __importDefault(require("../objects/documentItem"));
15
+ const gatherChildItems_1 = __importDefault(require("./gatherChildItems"));
16
+ const getChildTest_1 = __importDefault(require("./getChildTest"));
17
+ /**
18
+ * A selector function for retrieving existing child domGeneral.DomItems from the given parent item.
19
+ * This function will check all the children starting from item, and scan the attributes
20
+ * property for matches. The returned array contains children matching from all levels.
21
+ * WARNING: This calls a recursive function.
22
+ * @param attr - Provide the attribute name to be searched
23
+ * @param value - The attribute value to be compared
24
+ * @param item - The DomItem which may have child items matching the attribute
25
+ * criteria
26
+ */
27
+ const getChildrenFromAttribute = (attr, value, item = (0, documentItem_1.default)().body) => (0, gatherChildItems_1.default)(item, (0, getChildTest_1.default)(attr, value));
28
+ exports.default = getChildrenFromAttribute;
@@ -0,0 +1 @@
1
+ "use strict";var __importDefault=function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});const documentItem_1=__importDefault(require("../objects/documentItem")),gatherChildItems_1=__importDefault(require("./gatherChildItems")),getChildTest_1=__importDefault(require("./getChildTest")),getChildrenFromAttribute=(e,t,r=(0,documentItem_1.default)().body)=>(0,gatherChildItems_1.default)(r,(0,getChildTest_1.default)(e,t));exports.default=getChildrenFromAttribute;
@@ -0,0 +1,11 @@
1
+ import type { DomItem } from '../types';
2
+ /**
3
+ * Find the item (item itself, or one of its descendants) whose element is the one given, or null when none match.
4
+ * Only searches item and its own subtree: an event's target is always the item a listener is attached to, or one of
5
+ * its descendants (that is what bubbling means), so there is never a reason to search outside it.
6
+ * WARNING: This is a recursive function.
7
+ * @param item - The DomItem (and its subtree) to search.
8
+ * @param element - The real element to match against each item's element.
9
+ */
10
+ declare const getItemByElement: (item: DomItem, element: EventTarget | null) => DomItem | null;
11
+ export default getItemByElement;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ /* This Source Code Form is subject to the terms of the Mozilla Public
4
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
5
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
6
+ Object.defineProperty(exports, "__esModule", {
7
+ value: true
8
+ });
9
+ /**
10
+ * Find the item (item itself, or one of its descendants) whose element is the one given, or null when none match.
11
+ * Only searches item and its own subtree: an event's target is always the item a listener is attached to, or one of
12
+ * its descendants (that is what bubbling means), so there is never a reason to search outside it.
13
+ * WARNING: This is a recursive function.
14
+ * @param item - The DomItem (and its subtree) to search.
15
+ * @param element - The real element to match against each item's element.
16
+ */
17
+ const getItemByElement = (item, element) => {
18
+ if (item.element === element) {
19
+ return item;
20
+ }
21
+ for (const child of item.children) {
22
+ const found = getItemByElement(child, element);
23
+ if (found) {
24
+ return found;
25
+ }
26
+ }
27
+ return null;
28
+ };
29
+ exports.default = getItemByElement;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const getItemByElement=(e,t)=>{if(e.element===t)return e;for(const n of e.children){const e=getItemByElement(n,t);if(e)return e}return null};exports.default=getItemByElement;
@@ -0,0 +1,12 @@
1
+ import type { DomItem } from '../types';
2
+ /**
3
+ * Helper for getting all domGeneral.DomItems going up from item's parent, each one carrying the given class, among
4
+ * possibly several space-separated classes on that item - the same membership check as the real DOM's
5
+ * classList.contains, not an exact match of the whole className attribute string (which getParentsFromAttribute
6
+ * does, and which would miss a parent that also carries other classes).
7
+ * WARNING: This is a recursive function.
8
+ * @param className - The one class being searched for
9
+ * @param item - The DomItem which may have parent items carrying the class
10
+ */
11
+ declare const getParentsByClass: (className: string, item?: DomItem) => DomItem[];
12
+ export default getParentsByClass;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ /* This Source Code Form is subject to the terms of the Mozilla Public
4
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
5
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
6
+ require("core-js/modules/es.array.includes.js");
7
+ var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
8
+ return mod && mod.__esModule ? mod : {
9
+ "default": mod
10
+ };
11
+ };
12
+ Object.defineProperty(exports, "__esModule", {
13
+ value: true
14
+ });
15
+ const documentItem_1 = __importDefault(require("../objects/documentItem"));
16
+ const si_funciona_1 = __importDefault(require("si-funciona"));
17
+ /**
18
+ * Helper for getting all domGeneral.DomItems going up from item's parent, each one carrying the given class, among
19
+ * possibly several space-separated classes on that item - the same membership check as the real DOM's
20
+ * classList.contains, not an exact match of the whole className attribute string (which getParentsFromAttribute
21
+ * does, and which would miss a parent that also carries other classes).
22
+ * WARNING: This is a recursive function.
23
+ * @param className - The one class being searched for
24
+ * @param item - The DomItem which may have parent items carrying the class
25
+ */
26
+ const getParentsByClass = (className, item = (0, documentItem_1.default)().body) => {
27
+ if (item.parentItem === null) {
28
+ if (item.nodeName === '#document') {
29
+ throw new Error('Root parent item must be an empty object, null reference found.');
30
+ }
31
+ throw new Error('Detached child, missing parentItem reference. Use empty object if this is the root item.');
32
+ }
33
+ if (si_funciona_1.default.emptyObject(item.parentItem)) {
34
+ return [];
35
+ }
36
+ const parent = item.parentItem;
37
+ const carriesClass = (parent.attributes.className ?? '').split(' ').includes(className);
38
+ return carriesClass ? getParentsByClass(className, parent).concat([parent]) : getParentsByClass(className, parent);
39
+ };
40
+ exports.default = getParentsByClass;
@@ -0,0 +1 @@
1
+ "use strict";require("core-js/modules/es.array.includes.js");var __importDefault=function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});const documentItem_1=__importDefault(require("../objects/documentItem")),si_funciona_1=__importDefault(require("si-funciona")),getParentsByClass=(e,t=(0,documentItem_1.default)().body)=>{if(null===t.parentItem){if("#document"===t.nodeName)throw new Error("Root parent item must be an empty object, null reference found.");throw new Error("Detached child, missing parentItem reference. Use empty object if this is the root item.")}if(si_funciona_1.default.emptyObject(t.parentItem))return[];const r=t.parentItem;return(r.attributes.className??"").split(" ").includes(e)?getParentsByClass(e,r).concat([r]):getParentsByClass(e,r)};exports.default=getParentsByClass;
@@ -0,0 +1,9 @@
1
+ import type { DomItem } from '../types';
2
+ /**
3
+ * Helper for getting all domGeneral.DomItems starting at child and having specified name attribute
4
+ * @param name - The name to search for
5
+ * @param item - The DomItem which may have parent items matching the
6
+ * attribute criteria
7
+ */
8
+ declare const getParentsByName: (name: string, item?: DomItem) => DomItem[];
9
+ export default getParentsByName;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ /* This Source Code Form is subject to the terms of the Mozilla Public
4
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
5
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
6
+ var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
7
+ return mod && mod.__esModule ? mod : {
8
+ "default": mod
9
+ };
10
+ };
11
+ Object.defineProperty(exports, "__esModule", {
12
+ value: true
13
+ });
14
+ const si_funciona_1 = __importDefault(require("si-funciona"));
15
+ const getParentsFromAttribute_1 = __importDefault(require("./getParentsFromAttribute"));
16
+ /**
17
+ * Helper for getting all domGeneral.DomItems starting at child and having specified name attribute
18
+ * @param name - The name to search for
19
+ * @param item - The DomItem which may have parent items matching the
20
+ * attribute criteria
21
+ */
22
+ const getParentsByName = si_funciona_1.default.curry(getParentsFromAttribute_1.default)('name');
23
+ exports.default = getParentsByName;
@@ -0,0 +1 @@
1
+ "use strict";var __importDefault=function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});const si_funciona_1=__importDefault(require("si-funciona")),getParentsFromAttribute_1=__importDefault(require("./getParentsFromAttribute")),getParentsByName=si_funciona_1.default.curry(getParentsFromAttribute_1.default)("name");exports.default=getParentsByName;
@@ -0,0 +1,9 @@
1
+ import type { DomItem } from '../types';
2
+ /**
3
+ * Helper for getting all domGeneral.DomItems starting at child and having specified nodeName
4
+ * @param nodeName - The nodeName to search for
5
+ * @param item - The DomItem which may have parent items matching the
6
+ * attribute criteria
7
+ */
8
+ declare const getParentsByTagName: (nodeName: string, item?: DomItem) => DomItem[];
9
+ export default getParentsByTagName;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ /* This Source Code Form is subject to the terms of the Mozilla Public
4
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
5
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
6
+ var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
7
+ return mod && mod.__esModule ? mod : {
8
+ "default": mod
9
+ };
10
+ };
11
+ Object.defineProperty(exports, "__esModule", {
12
+ value: true
13
+ });
14
+ const si_funciona_1 = __importDefault(require("si-funciona"));
15
+ const getParentsFromAttribute_1 = __importDefault(require("./getParentsFromAttribute"));
16
+ /**
17
+ * Helper for getting all domGeneral.DomItems starting at child and having specified nodeName
18
+ * @param nodeName - The nodeName to search for
19
+ * @param item - The DomItem which may have parent items matching the
20
+ * attribute criteria
21
+ */
22
+ const getParentsByTagName = si_funciona_1.default.curry(getParentsFromAttribute_1.default)('nodeName');
23
+ exports.default = getParentsByTagName;
@@ -0,0 +1 @@
1
+ "use strict";var __importDefault=function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});const si_funciona_1=__importDefault(require("si-funciona")),getParentsFromAttribute_1=__importDefault(require("./getParentsFromAttribute")),getParentsByTagName=si_funciona_1.default.curry(getParentsFromAttribute_1.default)("nodeName");exports.default=getParentsByTagName;
@@ -0,0 +1,13 @@
1
+ import type { DomItem } from '../types';
2
+ /**
3
+ * A selector function for retrieving existing child domGeneral.DomItems from the given parent item.
4
+ * This function will check all the children starting from item, and scan the attributes
5
+ * property for matches. The return array contains children matching from all levels.
6
+ * WARNING: This is a recursive function.
7
+ * @param attr - Provide the attribute name to be searched
8
+ * @param value - The attribute value to be compared
9
+ * @param item - The DomItem which may have parent items matching the
10
+ * attribute criteria
11
+ */
12
+ declare const getParentsFromAttribute: (attr: string, value: unknown, item?: DomItem) => DomItem[];
13
+ export default getParentsFromAttribute;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ /* This Source Code Form is subject to the terms of the Mozilla Public
4
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
5
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
6
+ var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
7
+ return mod && mod.__esModule ? mod : {
8
+ "default": mod
9
+ };
10
+ };
11
+ Object.defineProperty(exports, "__esModule", {
12
+ value: true
13
+ });
14
+ const documentItem_1 = __importDefault(require("../objects/documentItem"));
15
+ const si_funciona_1 = __importDefault(require("si-funciona"));
16
+ /**
17
+ * A selector function for retrieving existing child domGeneral.DomItems from the given parent item.
18
+ * This function will check all the children starting from item, and scan the attributes
19
+ * property for matches. The return array contains children matching from all levels.
20
+ * WARNING: This is a recursive function.
21
+ * @param attr - Provide the attribute name to be searched
22
+ * @param value - The attribute value to be compared
23
+ * @param item - The DomItem which may have parent items matching the
24
+ * attribute criteria
25
+ */
26
+ const getParentsFromAttribute = (attr, value, item = (0, documentItem_1.default)().body) => {
27
+ if (item.parentItem === null) {
28
+ if (item.nodeName === '#document') {
29
+ throw new Error('Root parent item must be an empty object, null reference found.');
30
+ }
31
+ throw new Error('Detached child, missing parentItem reference. Use empty object if this is the root item.');
32
+ }
33
+ if (si_funciona_1.default.emptyObject(item.parentItem)) {
34
+ return [];
35
+ }
36
+ const parent = item.parentItem;
37
+ return (parent.attributes[attr] || item[attr] || false) === value ? getParentsFromAttribute(attr, value, parent).concat([parent]) : getParentsFromAttribute(attr, value, parent);
38
+ };
39
+ exports.default = getParentsFromAttribute;
@@ -0,0 +1 @@
1
+ "use strict";var __importDefault=function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});const documentItem_1=__importDefault(require("../objects/documentItem")),si_funciona_1=__importDefault(require("si-funciona")),getParentsFromAttribute=(e,t,r=(0,documentItem_1.default)().body)=>{if(null===r.parentItem){if("#document"===r.nodeName)throw new Error("Root parent item must be an empty object, null reference found.");throw new Error("Detached child, missing parentItem reference. Use empty object if this is the root item.")}if(si_funciona_1.default.emptyObject(r.parentItem))return[];const n=r.parentItem;return(n.attributes[e]||r[e]||!1)===t?getParentsFromAttribute(e,t,n).concat([n]):getParentsFromAttribute(e,t,n)};exports.default=getParentsFromAttribute;
@@ -0,0 +1,10 @@
1
+ import type { TraitDefinition } from '../types';
2
+ /**
3
+ * Describe a trait so treeloom knows what it is at runtime: the properties it puts on an item (so they can be left out
4
+ * of json when they only make sense where the item lives), and the defaults a new item gets. Types are added
5
+ * separately, by merging into TraitRegistry.
6
+ * @param name - The name of the trait, prefixed by the package which defines it: matrix.row
7
+ * @param definition - The properties the trait puts on an item, whether they are serializable and the defaults.
8
+ */
9
+ declare const defineTrait: (name: string, definition: TraitDefinition) => TraitDefinition;
10
+ export default defineTrait;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ /* This Source Code Form is subject to the terms of the Mozilla Public
4
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
5
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
6
+ var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
7
+ return mod && mod.__esModule ? mod : {
8
+ "default": mod
9
+ };
10
+ };
11
+ Object.defineProperty(exports, "__esModule", {
12
+ value: true
13
+ });
14
+ const definitions_1 = __importDefault(require("./definitions"));
15
+ /**
16
+ * Describe a trait so treeloom knows what it is at runtime: the properties it puts on an item (so they can be left out
17
+ * of json when they only make sense where the item lives), and the defaults a new item gets. Types are added
18
+ * separately, by merging into TraitRegistry.
19
+ * @param name - The name of the trait, prefixed by the package which defines it: matrix.row
20
+ * @param definition - The properties the trait puts on an item, whether they are serializable and the defaults.
21
+ */
22
+ const defineTrait = (name, definition) => {
23
+ definitions_1.default.set(name, definition);
24
+ return definition;
25
+ };
26
+ exports.default = defineTrait;
@@ -0,0 +1 @@
1
+ "use strict";var __importDefault=function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});const definitions_1=__importDefault(require("./definitions")),defineTrait=(e,t)=>(definitions_1.default.set(e,t),t);exports.default=defineTrait;
@@ -0,0 +1,7 @@
1
+ import type { TraitDefinition } from '../types';
2
+ /**
3
+ * What each trait is at runtime, by name. render is the one treeloom brings; other libraries add theirs with
4
+ * defineTrait.
5
+ */
6
+ declare const definitions: Map<string, TraitDefinition>;
7
+ export default definitions;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ /* This Source Code Form is subject to the terms of the Mozilla Public
4
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
5
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
6
+ Object.defineProperty(exports, "__esModule", {
7
+ value: true
8
+ });
9
+ /**
10
+ * What each trait is at runtime, by name. render is the one treeloom brings; other libraries add theirs with
11
+ * defineTrait.
12
+ */
13
+ const definitions = new Map([['render', {
14
+ keys: ['element', 'activeListeners'],
15
+ serializable: false,
16
+ defaults: () => ({
17
+ element: null
18
+ })
19
+ }]]);
20
+ exports.default = definitions;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const definitions=new Map([["render",{keys:["element","activeListeners"],serializable:!1,defaults:()=>({element:null})}]]);exports.default=definitions;
@@ -0,0 +1,9 @@
1
+ import type { CoreItem } from '../types';
2
+ /**
3
+ * The properties an item has only because of its traits, and which do not belong in json (the element of the render
4
+ * trait, for one).
5
+ * @param item - The item to look at.
6
+ * @private
7
+ */
8
+ declare const getNonSerializableKeys: (item: CoreItem) => string[];
9
+ export default getNonSerializableKeys;