{"id":18941866,"url":"https://github.com/bahrus/be-hive","last_synced_at":"2025-08-24T19:12:12.865Z","repository":{"id":41471328,"uuid":"417090331","full_name":"bahrus/be-hive","owner":"bahrus","description":"be-hive allows us to manage and coordinate the family, or HTML frimework of be-enhanced element behiviors / decorators.","archived":false,"fork":false,"pushed_at":"2024-05-19T17:22:42.000Z","size":789,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"baseline","last_synced_at":"2024-05-22T15:08:16.031Z","etag":null,"topics":["behaviors","custom-elements","web-components"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bahrus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-10-14T10:43:03.000Z","updated_at":"2024-05-27T18:02:39.674Z","dependencies_parsed_at":"2023-11-19T10:21:56.587Z","dependency_job_id":"e2dda2c0-7951-4590-b2b5-f53264d404e3","html_url":"https://github.com/bahrus/be-hive","commit_stats":{"total_commits":245,"total_committers":1,"mean_commits":245.0,"dds":0.0,"last_synced_commit":"1313ea0fa0ab537d7e987b8270e6c10621eb0a79"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahrus%2Fbe-hive","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahrus%2Fbe-hive/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahrus%2Fbe-hive/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahrus%2Fbe-hive/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bahrus","download_url":"https://codeload.github.com/bahrus/be-hive/tar.gz/refs/heads/baseline","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242667531,"owners_count":20166311,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["behaviors","custom-elements","web-components"],"created_at":"2024-11-08T12:29:50.218Z","updated_at":"2025-03-09T09:06:04.320Z","avatar_url":"https://github.com/bahrus.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# be-hive [WIP]\n\n[![Published on webcomponents.org](https://img.shields.io/badge/webcomponents.org-published-blue.svg)](https://www.webcomponents.org/element/bahrus/be-hive)\n[![How big is this package in your project?](https://img.shields.io/bundlephobia/minzip/be-hive?style=for-the-badge)](https://bundlephobia.com/result?p=be-hive)\n\u003cimg src=\"http://img.badgesize.io/https://cdn.jsdelivr.net/npm/be-hive?compression=gzip\"\u003e\n[![NPM version](https://badge.fury.io/js/be-hive.png)](http://badge.fury.io/js/be-hive)\n\n## Inheriting behiviors\n\n[be-hive](https://www.youtube.com/watch?v=SQoOwosJWns) lets it [snow in August](https://www.youtube.com/watch?v=m3dmnOtqrV0).\n\nbe-hive allows us to manage and coordinate the [family, or HTML frimework](https://github.com/bahrus/may-it-be) of [be-enhanced](https://github.com/bahrus/be-enhanced) custom enhancements.  \n\nWithout be-hive, the developer is burdened with plopping an instance of each enhancement inside each shadow DOM realm.\n\nWith the help of the be-hive component, the developer only has to plop a single instance of be-hive inside the Shadow DOM realm, like so:\n\n```html\n\u003cbe-hive\u003e\u003c/be-hive\u003e\n```\n\nThis signals that the Shadow DOM realm is opting-in, and allowing element behiviors, and will inherit all the behiviors from the parent Shadow DOM realm, by default.\n\nBut the child Shadow DOM realm can develop a personality of its own by:\n\n1.  Adding additional behiviors by adding specific be-enhanced based enhancement instructions inside the be-hive instance tag.\n2.  Avoiding naming conflicts by overriding the attribute associated with the inherited behivior.\n3.  Preventing inheriting unwanted behiviors from affecting the child Shadow DOM realm.\n4.  Start over.  Only decorator elements manually added inside the Shadow DOM (preferably inside the be-hive tag, for inheritance to work within)\n\n## Syntax for customizations of inherited behiviors [WIP]\n\n```html\n\u003cbe-hive passthrough\u003e\u003c/be-hive\u003e\n```\n\nallows behiviors to flow though the ShadowDOM realm to child ShadowDOM realms, but skips over the one in question.\n\n```html\n\u003cbe-hive include=... exclude=...\u003e\n```\n\nallows for blocking or specifying which behiviors to enable within the ShadowDOM realm, while allowing them to flow through to the child ShadowDOM realms, unaffected.\n\n```html\n\u003cbe-hive overrides='{\n    \"be-sharing\":{\n        \"becomes\": \"be-familial\"\n    },\n    \"be-gracious\": {\n        \"becomes\": \"be-respectful\"\n    },\n    \"be-disobedient-without-facing-the-consequences\": {\n        \"block\": \"true\"\n    }\n}'\u003e\u003c/be-hive\u003e\n```\n\n\n\n## Be like Sirius Black\n\nIf the inherited behiviors are all just too odious to inherit, there's an option to start again:\n\n```html\n\u003cbe-hive be-severed\u003e\n\u003c/be-hive\u003e\n```\n\n## Adding back a personality trait [TODO]\n\nIf one Shadow DOM blocks an inherited behivior, child Shadow DOMs can bring it back within their (and descendent) shadow DOM realms thusly:\n\n```html\n\u003cbe-hive overrides='{\n    \"be-disobedient-without-facing-the-consequences\": {\n        \"unblock\": \"true\"\n    }\n}'\u003e\u003c/be-hive\u003e\n```\n\n\n## The \"Emcee\" script files\n\nTo make the ceremony of establishing DOM enhancements go as smoothly as possible, *be-hive* rests on a key object structure that should accompany each enhancement -- the  \"EMC\" object.  \n\nEMC stands for \"Enhancement Mount Configuration\".\n\nThese objects are small, and most of it can be turned into a JSON import:\n\nFor example:\n\n```TypeScript\nexport const emc: EMC = {\n    base: 'be-based',\n    map: {\n        '0.0': 'base'\n    },\n    enhPropKey: 'beBased',\n    importEnh: async () =\u003e {\n        const {BeBased} = await import('./behance.js');\n        return BeBased;\n    }\n};\n```\n\nThis provides a kind of \"entrance ticket\" that can then be used to enhance an element programmatically:\n\n```TypeScript\nconst beBasedEnhancement = await oDivElement.beEnhanced.whenResolved(emc);\n```\n\nIt also contains all the needed information for how to parse the the behavior/enhancement attributes, into an object that can be passed in to the behavior/enhancement during template instantiation.\n\nTo see a more complex example along those lines, see [be-switched](https://github.com/bahrus/be-switched/blob/baseline/behivior.ts).\n\n\n\nPotentially, an alternative EMC definition can be used inside different Shadow DOM roots in order to avoid clashes between two libraries that use the same names.\n\nSo we can synchronously load these small files (or a bundle of such small files), which would block being able to do template instantiation on a first load. but at least the files are as small (and as parsable) as possible.\n\nThe thinking is we can take a template filled with lots of inline behavior/enhancement attributes, where that template is going to be cloned repeatedly.  In order to avoid excessive string parsing, we can analyze the template:\n\nIf the EMC's \"cache\" setting is set to true, then it will look at the initial attribute settings, and see if it matches something that is already in the cache, and if so, do a (structural clone?) of the object without re-parsing.  Maybe this should only be done if the root fragment isn't connected?\n\n## Behivior aspects [WIP]\n\nThere may be some cases, especially for enhancements with many equally important parameters where a developer may prefer to break up the settings into separate attributes. [Here's an example](https://github.com/bahrus/be-intl) where I can definitely see the appeal.  So instead of:\n\n```html\n\u003ctime lang=\"ar-EG\" datetime=2011-11-18T14:54:39.929Z be-intl='{ \"weekday\": \"long\", \"year\": \"numeric\", \"month\": \"long\", \"day\": \"numeric\" }'\u003e\u003c/time\u003e\n```\n\nwe can write:\n\n```html\n\u003ctime lang=\"ar-EG\" \n    datetime=2011-11-18T14:54:39.929Z \n    be-intl-weekday=long be-intl-year=numeric be-intl-month=long\n    be-intl-day=numeric\u003e\n\u003c/time\u003e\n```\n\nThis is especially useful in environments where the consumer of the behivior prefers to use attributes, rather than properties, for updating a property of the behivior.\n\n\n\n  \n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbahrus%2Fbe-hive","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbahrus%2Fbe-hive","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbahrus%2Fbe-hive/lists"}