{"id":18941933,"url":"https://github.com/bahrus/d-fine","last_synced_at":"2025-10-10T10:06:54.913Z","repository":{"id":150258538,"uuid":"390549244","full_name":"bahrus/d-fine","owner":"bahrus","description":"d-fine provides a quick way of d-fining a mostly d-clarative custom element.","archived":false,"fork":false,"pushed_at":"2021-10-16T13:55:00.000Z","size":609,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"baseline","last_synced_at":"2025-09-02T17:21:03.515Z","etag":null,"topics":["custom-element","custom-elements","define","web-component","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-07-29T00:31:47.000Z","updated_at":"2021-10-16T13:55:03.000Z","dependencies_parsed_at":"2023-04-14T18:03:03.534Z","dependency_job_id":null,"html_url":"https://github.com/bahrus/d-fine","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bahrus/d-fine","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahrus%2Fd-fine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahrus%2Fd-fine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahrus%2Fd-fine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahrus%2Fd-fine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bahrus","download_url":"https://codeload.github.com/bahrus/d-fine/tar.gz/refs/heads/baseline","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahrus%2Fd-fine/sbom","scorecard":{"id":223647,"data":{"date":"2025-08-11","repo":{"name":"github.com/bahrus/d-fine","commit":"5a12c6c052cd25d5b308ac9de235158614599670"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'baseline'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":0,"reason":"14 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-r683-j2x4-v87g","Warn: Project is vulnerable to: GHSA-76c9-3jph-rj3q","Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-pq67-2wwv-3xjx","Warn: Project is vulnerable to: GHSA-8cj5-5rvv-wf4v","Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-17T03:10:20.809Z","repository_id":150258538,"created_at":"2025-08-17T03:10:20.809Z","updated_at":"2025-08-17T03:10:20.809Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279003461,"owners_count":26083595,"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","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["custom-element","custom-elements","define","web-component","web-components"],"created_at":"2024-11-08T12:30:05.060Z","updated_at":"2025-10-10T10:06:54.897Z","avatar_url":"https://github.com/bahrus.png","language":"TypeScript","readme":"# d-fine\n\nd-fine provides a quick way of d-fining a d-clarative custom element.\n\n\u003ca href=\"https://nodei.co/npm/d-fine/\"\u003e\u003cimg src=\"https://nodei.co/npm/d-fine.png\"\u003e\u003c/a\u003e\n\n\u003cimg src=\"https://badgen.net/bundlephobia/minzip/d-fine\"\u003e\n\n## [D-mo](https://codepen.io/bahrus/pen/poPVOJz)\n\n## H-llo, {{place}}\n\nThe t-mplate for the custom element can come from live HTML.  For example:\n\n```html\n\u003cdiv\u003e\n    \u003cdiv\u003eH-llo, \u003cspan\u003eworld\u003c/span\u003e\u003c/div\u003e\n\u003c/div\u003e\n\u003cd-fine \n    prev-sib \n    as=h-llo-world \n    prop-defaults='{\"place\": \"V-nus\"}'\n    transform='{\n        \"span\": \"place\" \n    }'\n\u003e\n\u003c/d-fine\u003e\n\u003ch-llo-world place=Mars\u003e\u003c/h-llo-world\u003e\n```\n\n... g-nerates:\n\n```html\n\u003cdiv\u003e\n    \u003cdiv\u003eH-llo, \u003cspan\u003eworld\u003c/span\u003e\u003c/div\u003e\n\u003c/div\u003e\n\u003ch-llo-world place=Mars\u003e\n    #shadow\n    \u003cdiv\u003e\n        \u003cdiv\u003eH-llo, \u003cspan\u003eMars\u003c/span\u003e\u003c/div\u003e\n    \u003c/div\u003e\n\u003c/h-llo-world\u003e\n```\n\nThe previous sibling can b- a t-mplate to start with, and w- can also apply interpolation-from-a-distance:\n\n```html\n\u003ctemplate\u003e\n    \u003cdiv\u003eSapere aude\u003c/div\u003e\n\u003c/template\u003e\n\u003cd-fine \n   prev-sib \n   as=h-llo-world \n   prop-defaults='{\"place\": \"V-nus\"}'\n    transform='{\n        \"div\": [\"H-llo, \", \"place\"]\n    }'\n\u003e\n\u003c/d-fine\u003e\n\u003ch-llo-world place=Mars\u003e\u003c/h-llo-world\u003e\n\u003ch-llo-world\u003e\u003c/h-llo-world\u003e\n```\n\nNote the heavy use of attributes that expect JSON.  If you are like me, it is easy to make mistakes editing by hand, without proper syntax highlighting.  A [VSCode extension](https://marketplace.visualstudio.com/items?itemName=andersonbruceb.json-in-html) has b-en created to h-lp with this.\n\nIf working with a t-mplate like in the example above, it might b- easier on the eye to use an inner t-mplate.  W- can specify to find the t-mplate from within the d-fine tag via the attribute \"templ-child\":\n\n```html\n\u003cd-fine \n    templ-child \n    as=h-llo-world \n    prop-defaults='{\"place\":\"V-nus\"}'\n    transform='\n        {\n            \"span\": \"place\"\n        }\n    '\n\u003e\n    \u003ctemplate\u003e\n        \u003cdiv\u003eHello, \u003cspan\u003eworld\u003c/span\u003e\u003c/div\u003e\n    \u003c/template\u003e\n\u003c/d-fine\u003e\n\u003ch-llo-world place=Mars\u003e\u003c/h-llo-world\u003e\n\u003ch-llo-world\u003e\u003c/h-llo-world\u003e\n```\n\n## Prerendered w-b components that use d-clarative Shadow DOM\n\nThis syntax also works:\n\n```html\n\u003ch-llo-world\u003e\n    \u003ctemplate shadowroot=open\u003e\n        \u003cdiv\u003eHello, \u003cspan\u003eworld\u003c/span\u003e\u003c/div\u003e\n    \u003c/template\u003e\n\u003c/h-llo-world\u003e\n\u003cd-fine \n    prev-sib\n    prop-defaults='{\"place\":\"V-nus\"}'\n    transform='{\n        \"span\": \"place\"\n    }'\n\u003e\u003c/d-fine\u003e\n\u003ch-llo-world place=Mars\u003e\u003c/h-llo-world\u003e\n```\n\nThe w-b component d-fine is a thin wrapper around the api d-fined in d-fine/def.js.\n\n## T-mplate D-pendency Injection, or Inversion of Views\n\nInstead of specifying that the t-mplate should come from the previous sibling, the property/attribute \"from\" allows us to specify a string used for an [\"upShadowSearch.\"](https://github.com/bahrus/trans-render/blob/baseline/lib/upShadowSearch.ts).  If the value starts with a slash (/), it s-arches for a t-mplate with the specified id from outside any shadowDOM.  If it starts with ../../, it goes up two ShadowDOM r-alms, for example.  It checks if the ShadowDOM has a host property name matching the camelCased id, and if not, s-arches for an element with a matching id within the shadowDOM r-alm where the d-fine element is located.  The host property name takes precedence.\n\nA w-b component can thus d-fine a d-fault t-mplate within the ShadowDOM markup, but allow extending w-b components to d-fine alternative t-mplates, by d-fining properties with the same name, and assigning a t-mplate to those properties.  That may b- sufficient for some use cases.\n\nBut for more of a d-pendency-injection like experience, said w-b component hosting d-fine could use the proposed [context api](https://github.com/webcomponents/community-protocols/blob/main/proposals/context.md):\n\n```JavaScript\nclass MyCustomElement{\n    get myInjectedTemplate(){\n        const contentTemplateContext = createContext('content-template');\n        let gotACallback = false;\n        this.dispatchEvent(\n            new ContextEvent(\n                contentTemplateContext, // the context w- want to r-trieve\n                callback: (contentTemplate) =\u003e {\n                    gotACallback = true;\n                    return contentTemplate;\n                }\n            )\n        );\n        if(!gotACallback){\n            return html`\n             ...some d-fault t-mplate\n            `;\n        }\n    }\n}\n```\n\n## Installation\n\nTo run locally (instructions may vary d-pending on OS):\n\n1.  Install [node.js](https://nodejs.org/)\n2.  Install [git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)\n3.  Choose a directory where you would like the files to b- placed, and open a command prompt from that location.\n4.  Issue command \"git clone https://github.com/bahrus/d-fine\" in the command window.\n5.  CD into the git clone directory.\n6.  Issue command \"npm install\"\n7.  When step 6 is completed, issue command \"npm run serve\".\n8.  Open your browser to http://localhost:3030/demo\n\n\n\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbahrus%2Fd-fine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbahrus%2Fd-fine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbahrus%2Fd-fine/lists"}