groove-dev 0.15.0 → 0.16.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/docs/FILE-EDITOR-PLAN.md +253 -0
- package/node_modules/@codemirror/autocomplete/.github/workflows/dispatch.yml +16 -0
- package/node_modules/@codemirror/autocomplete/CHANGELOG.md +639 -0
- package/node_modules/@codemirror/autocomplete/LICENSE +21 -0
- package/node_modules/@codemirror/autocomplete/README.md +43 -0
- package/node_modules/@codemirror/autocomplete/dist/index.cjs +2151 -0
- package/node_modules/@codemirror/autocomplete/dist/index.d.cts +648 -0
- package/node_modules/@codemirror/autocomplete/dist/index.d.ts +648 -0
- package/node_modules/@codemirror/autocomplete/dist/index.js +2120 -0
- package/node_modules/@codemirror/autocomplete/package.json +41 -0
- package/node_modules/@codemirror/commands/.github/workflows/dispatch.yml +16 -0
- package/node_modules/@codemirror/commands/CHANGELOG.md +386 -0
- package/node_modules/@codemirror/commands/LICENSE +21 -0
- package/node_modules/@codemirror/commands/README.md +35 -0
- package/node_modules/@codemirror/commands/dist/index.cjs +1909 -0
- package/node_modules/@codemirror/commands/dist/index.d.cts +650 -0
- package/node_modules/@codemirror/commands/dist/index.d.ts +650 -0
- package/node_modules/@codemirror/commands/dist/index.js +1795 -0
- package/node_modules/@codemirror/commands/package.json +42 -0
- package/node_modules/@codemirror/lang-css/.github/workflows/dispatch.yml +16 -0
- package/node_modules/@codemirror/lang-css/CHANGELOG.md +106 -0
- package/node_modules/@codemirror/lang-css/LICENSE +21 -0
- package/node_modules/@codemirror/lang-css/README.md +50 -0
- package/node_modules/@codemirror/lang-css/dist/index.cjs +269 -0
- package/node_modules/@codemirror/lang-css/dist/index.d.cts +28 -0
- package/node_modules/@codemirror/lang-css/dist/index.d.ts +28 -0
- package/node_modules/@codemirror/lang-css/dist/index.js +264 -0
- package/node_modules/@codemirror/lang-css/package.json +42 -0
- package/node_modules/@codemirror/lang-html/.github/workflows/dispatch.yml +16 -0
- package/node_modules/@codemirror/lang-html/CHANGELOG.md +210 -0
- package/node_modules/@codemirror/lang-html/LICENSE +21 -0
- package/node_modules/@codemirror/lang-html/README.md +147 -0
- package/node_modules/@codemirror/lang-html/dist/index.cjs +667 -0
- package/node_modules/@codemirror/lang-html/dist/index.d.cts +115 -0
- package/node_modules/@codemirror/lang-html/dist/index.d.ts +115 -0
- package/node_modules/@codemirror/lang-html/dist/index.js +661 -0
- package/node_modules/@codemirror/lang-html/package.json +46 -0
- package/node_modules/@codemirror/lang-javascript/.github/workflows/dispatch.yml +16 -0
- package/node_modules/@codemirror/lang-javascript/CHANGELOG.md +206 -0
- package/node_modules/@codemirror/lang-javascript/LICENSE +21 -0
- package/node_modules/@codemirror/lang-javascript/README.md +125 -0
- package/node_modules/@codemirror/lang-javascript/dist/index.cjs +526 -0
- package/node_modules/@codemirror/lang-javascript/dist/index.d.cts +93 -0
- package/node_modules/@codemirror/lang-javascript/dist/index.d.ts +93 -0
- package/node_modules/@codemirror/lang-javascript/dist/index.js +513 -0
- package/node_modules/@codemirror/lang-javascript/package.json +45 -0
- package/node_modules/@codemirror/lang-json/.github/workflows/dispatch.yml +16 -0
- package/node_modules/@codemirror/lang-json/CHANGELOG.md +59 -0
- package/node_modules/@codemirror/lang-json/LICENSE +21 -0
- package/node_modules/@codemirror/lang-json/README.md +56 -0
- package/node_modules/@codemirror/lang-json/dist/index.cjs +68 -0
- package/node_modules/@codemirror/lang-json/dist/index.d.cts +22 -0
- package/node_modules/@codemirror/lang-json/dist/index.d.ts +22 -0
- package/node_modules/@codemirror/lang-json/dist/index.js +64 -0
- package/node_modules/@codemirror/lang-json/package.json +39 -0
- package/node_modules/@codemirror/lang-markdown/.github/workflows/dispatch.yml +16 -0
- package/node_modules/@codemirror/lang-markdown/CHANGELOG.md +246 -0
- package/node_modules/@codemirror/lang-markdown/LICENSE +21 -0
- package/node_modules/@codemirror/lang-markdown/README.md +162 -0
- package/node_modules/@codemirror/lang-markdown/dist/index.cjs +501 -0
- package/node_modules/@codemirror/lang-markdown/dist/index.d.cts +124 -0
- package/node_modules/@codemirror/lang-markdown/dist/index.d.ts +124 -0
- package/node_modules/@codemirror/lang-markdown/dist/index.js +492 -0
- package/node_modules/@codemirror/lang-markdown/package.json +44 -0
- package/node_modules/@codemirror/lang-python/.github/workflows/dispatch.yml +16 -0
- package/node_modules/@codemirror/lang-python/CHANGELOG.md +174 -0
- package/node_modules/@codemirror/lang-python/LICENSE +21 -0
- package/node_modules/@codemirror/lang-python/README.md +61 -0
- package/node_modules/@codemirror/lang-python/dist/index.cjs +313 -0
- package/node_modules/@codemirror/lang-python/dist/index.d.cts +26 -0
- package/node_modules/@codemirror/lang-python/dist/index.d.ts +26 -0
- package/node_modules/@codemirror/lang-python/dist/index.js +308 -0
- package/node_modules/@codemirror/lang-python/package.json +42 -0
- package/node_modules/@codemirror/language/.github/workflows/dispatch.yml +16 -0
- package/node_modules/@codemirror/language/CHANGELOG.md +412 -0
- package/node_modules/@codemirror/language/LICENSE +21 -0
- package/node_modules/@codemirror/language/README.md +66 -0
- package/node_modules/@codemirror/language/dist/index.cjs +2742 -0
- package/node_modules/@codemirror/language/dist/index.d.cts +1220 -0
- package/node_modules/@codemirror/language/dist/index.d.ts +1220 -0
- package/node_modules/@codemirror/language/dist/index.js +2687 -0
- package/node_modules/@codemirror/language/package.json +44 -0
- package/node_modules/@codemirror/lint/.github/workflows/dispatch.yml +16 -0
- package/node_modules/@codemirror/lint/CHANGELOG.md +318 -0
- package/node_modules/@codemirror/lint/LICENSE +21 -0
- package/node_modules/@codemirror/lint/README.md +18 -0
- package/node_modules/@codemirror/lint/dist/index.cjs +958 -0
- package/node_modules/@codemirror/lint/dist/index.d.cts +195 -0
- package/node_modules/@codemirror/lint/dist/index.d.ts +195 -0
- package/node_modules/@codemirror/lint/dist/index.js +945 -0
- package/node_modules/@codemirror/lint/package.json +40 -0
- package/node_modules/@codemirror/search/.github/workflows/dispatch.yml +16 -0
- package/node_modules/@codemirror/search/CHANGELOG.md +324 -0
- package/node_modules/@codemirror/search/LICENSE +21 -0
- package/node_modules/@codemirror/search/README.md +18 -0
- package/node_modules/@codemirror/search/dist/index.cjs +1237 -0
- package/node_modules/@codemirror/search/dist/index.d.cts +385 -0
- package/node_modules/@codemirror/search/dist/index.d.ts +385 -0
- package/node_modules/@codemirror/search/dist/index.js +1217 -0
- package/node_modules/@codemirror/search/package.json +40 -0
- package/node_modules/@codemirror/state/.github/workflows/dispatch.yml +16 -0
- package/node_modules/@codemirror/state/CHANGELOG.md +308 -0
- package/node_modules/@codemirror/state/LICENSE +21 -0
- package/node_modules/@codemirror/state/README.md +18 -0
- package/node_modules/@codemirror/state/dist/index.cjs +3922 -0
- package/node_modules/@codemirror/state/dist/index.d.cts +1713 -0
- package/node_modules/@codemirror/state/dist/index.d.ts +1713 -0
- package/node_modules/@codemirror/state/dist/index.js +3892 -0
- package/node_modules/@codemirror/state/package.json +38 -0
- package/node_modules/@codemirror/theme-one-dark/.github/workflows/dispatch.yml +16 -0
- package/node_modules/@codemirror/theme-one-dark/CHANGELOG.md +97 -0
- package/node_modules/@codemirror/theme-one-dark/LICENSE +21 -0
- package/node_modules/@codemirror/theme-one-dark/README.md +46 -0
- package/node_modules/@codemirror/theme-one-dark/dist/index.cjs +139 -0
- package/node_modules/@codemirror/theme-one-dark/dist/index.d.cts +39 -0
- package/node_modules/@codemirror/theme-one-dark/dist/index.d.ts +39 -0
- package/node_modules/@codemirror/theme-one-dark/dist/index.js +134 -0
- package/node_modules/@codemirror/theme-one-dark/package.json +41 -0
- package/node_modules/@codemirror/view/.github/workflows/dispatch.yml +16 -0
- package/node_modules/@codemirror/view/CHANGELOG.md +2284 -0
- package/node_modules/@codemirror/view/LICENSE +21 -0
- package/node_modules/@codemirror/view/README.md +37 -0
- package/node_modules/@codemirror/view/dist/index.cjs +11796 -0
- package/node_modules/@codemirror/view/dist/index.d.cts +2389 -0
- package/node_modules/@codemirror/view/dist/index.d.ts +2389 -0
- package/node_modules/@codemirror/view/dist/index.js +11745 -0
- package/node_modules/@codemirror/view/package.json +41 -0
- package/node_modules/@groove-dev/daemon/src/api.js +157 -2
- package/node_modules/@groove-dev/daemon/src/filewatcher.js +59 -0
- package/node_modules/@groove-dev/daemon/src/index.js +28 -1
- package/node_modules/@groove-dev/daemon/src/skills.js +20 -0
- package/node_modules/@groove-dev/gui/dist/assets/index-Dxg9hdf3.js +103 -0
- package/node_modules/@groove-dev/gui/dist/index.html +1 -1
- package/node_modules/@groove-dev/gui/package.json +15 -2
- package/node_modules/@groove-dev/gui/src/App.jsx +3 -0
- package/node_modules/@groove-dev/gui/src/components/CodeEditor.jsx +143 -0
- package/node_modules/@groove-dev/gui/src/components/EditorTabs.jsx +83 -0
- package/node_modules/@groove-dev/gui/src/components/FileTree.jsx +193 -0
- package/node_modules/@groove-dev/gui/src/stores/groove.js +158 -1
- package/node_modules/@groove-dev/gui/src/views/FileEditor.jsx +142 -0
- package/node_modules/@groove-dev/gui/src/views/SkillsMarketplace.jsx +112 -1
- package/node_modules/@lezer/common/LICENSE +21 -0
- package/node_modules/@lezer/common/README.md +14 -0
- package/node_modules/@lezer/common/dist/index.cjs +2209 -0
- package/node_modules/@lezer/common/dist/index.d.cts +1174 -0
- package/node_modules/@lezer/common/dist/index.d.ts +1174 -0
- package/node_modules/@lezer/common/dist/index.js +2196 -0
- package/node_modules/@lezer/common/package.json +32 -0
- package/node_modules/@lezer/css/CHANGELOG.md +307 -0
- package/node_modules/@lezer/css/LICENSE +21 -0
- package/node_modules/@lezer/css/README.md +6 -0
- package/node_modules/@lezer/css/dist/index.cjs +151 -0
- package/node_modules/@lezer/css/dist/index.d.cts +3 -0
- package/node_modules/@lezer/css/dist/index.d.ts +3 -0
- package/node_modules/@lezer/css/dist/index.js +147 -0
- package/node_modules/@lezer/css/package.json +36 -0
- package/node_modules/@lezer/css/rollup.config.js +16 -0
- package/node_modules/@lezer/css/src/css.grammar +290 -0
- package/node_modules/@lezer/css/src/highlight.js +36 -0
- package/node_modules/@lezer/css/src/parser.js +31 -0
- package/node_modules/@lezer/css/src/parser.terms.js +63 -0
- package/node_modules/@lezer/css/src/tokens.js +75 -0
- package/node_modules/@lezer/css/test/declarations.txt +241 -0
- package/node_modules/@lezer/css/test/selector.txt +178 -0
- package/node_modules/@lezer/css/test/statements.txt +227 -0
- package/node_modules/@lezer/css/test/test-css.js +16 -0
- package/node_modules/@lezer/highlight/LICENSE +21 -0
- package/node_modules/@lezer/highlight/README.md +14 -0
- package/node_modules/@lezer/highlight/dist/index.cjs +936 -0
- package/node_modules/@lezer/highlight/dist/index.d.cts +623 -0
- package/node_modules/@lezer/highlight/dist/index.d.ts +623 -0
- package/node_modules/@lezer/highlight/dist/index.js +927 -0
- package/node_modules/@lezer/highlight/package.json +31 -0
- package/node_modules/@lezer/html/CHANGELOG.md +303 -0
- package/node_modules/@lezer/html/LICENSE +21 -0
- package/node_modules/@lezer/html/README.md +37 -0
- package/node_modules/@lezer/html/dist/index.cjs +354 -0
- package/node_modules/@lezer/html/dist/index.d.cts +14 -0
- package/node_modules/@lezer/html/dist/index.d.ts +14 -0
- package/node_modules/@lezer/html/dist/index.js +349 -0
- package/node_modules/@lezer/html/package.json +37 -0
- package/node_modules/@lezer/html/rollup.config.js +16 -0
- package/node_modules/@lezer/html/src/.tern-port +1 -0
- package/node_modules/@lezer/html/src/content.js +87 -0
- package/node_modules/@lezer/html/src/highlight.js +15 -0
- package/node_modules/@lezer/html/src/html.grammar +181 -0
- package/node_modules/@lezer/html/src/index.js +2 -0
- package/node_modules/@lezer/html/src/parser.js +27 -0
- package/node_modules/@lezer/html/src/parser.terms.js +53 -0
- package/node_modules/@lezer/html/src/tokens.js +199 -0
- package/node_modules/@lezer/html/test/mixed.txt +69 -0
- package/node_modules/@lezer/html/test/tags.txt +370 -0
- package/node_modules/@lezer/html/test/test-html.js +29 -0
- package/node_modules/@lezer/html/test/test-incremental.js +97 -0
- package/node_modules/@lezer/html/test/vue.txt +56 -0
- package/node_modules/@lezer/javascript/CHANGELOG.md +485 -0
- package/node_modules/@lezer/javascript/LICENSE +21 -0
- package/node_modules/@lezer/javascript/README.md +14 -0
- package/node_modules/@lezer/javascript/dist/index.cjs +196 -0
- package/node_modules/@lezer/javascript/dist/index.d.cts +3 -0
- package/node_modules/@lezer/javascript/dist/index.d.ts +3 -0
- package/node_modules/@lezer/javascript/dist/index.js +192 -0
- package/node_modules/@lezer/javascript/package.json +36 -0
- package/node_modules/@lezer/javascript/rollup.config.js +16 -0
- package/node_modules/@lezer/javascript/src/highlight.js +62 -0
- package/node_modules/@lezer/javascript/src/javascript.grammar +735 -0
- package/node_modules/@lezer/javascript/src/parser.js +33 -0
- package/node_modules/@lezer/javascript/src/parser.terms.js +177 -0
- package/node_modules/@lezer/javascript/src/tokens.js +87 -0
- package/node_modules/@lezer/javascript/test/decorator.txt +64 -0
- package/node_modules/@lezer/javascript/test/expression.txt +686 -0
- package/node_modules/@lezer/javascript/test/jsx.txt +79 -0
- package/node_modules/@lezer/javascript/test/semicolon.txt +77 -0
- package/node_modules/@lezer/javascript/test/statement.txt +404 -0
- package/node_modules/@lezer/javascript/test/test-javascript.js +17 -0
- package/node_modules/@lezer/javascript/test/typescript.txt +401 -0
- package/node_modules/@lezer/json/CHANGELOG.md +79 -0
- package/node_modules/@lezer/json/LICENSE +21 -0
- package/node_modules/@lezer/json/README.md +7 -0
- package/node_modules/@lezer/json/dist/index.cjs +41 -0
- package/node_modules/@lezer/json/dist/index.d.cts +3 -0
- package/node_modules/@lezer/json/dist/index.d.ts +3 -0
- package/node_modules/@lezer/json/dist/index.js +37 -0
- package/node_modules/@lezer/json/package.json +36 -0
- package/node_modules/@lezer/json/rollup.config.js +15 -0
- package/node_modules/@lezer/json/src/highlight.js +12 -0
- package/node_modules/@lezer/json/src/json.grammar +38 -0
- package/node_modules/@lezer/json/src/parser.js +23 -0
- package/node_modules/@lezer/json/src/parser.terms.js +12 -0
- package/node_modules/@lezer/json/test/arrays.txt +34 -0
- package/node_modules/@lezer/json/test/literals.txt +23 -0
- package/node_modules/@lezer/json/test/numbers.txt +87 -0
- package/node_modules/@lezer/json/test/objects.txt +34 -0
- package/node_modules/@lezer/json/test/strings.txt +50 -0
- package/node_modules/@lezer/json/test/test-json.js +17 -0
- package/node_modules/@lezer/lr/LICENSE +21 -0
- package/node_modules/@lezer/lr/README.md +25 -0
- package/node_modules/@lezer/lr/dist/constants.d.ts +45 -0
- package/node_modules/@lezer/lr/dist/constants.js +5 -0
- package/node_modules/@lezer/lr/dist/index.cjs +1891 -0
- package/node_modules/@lezer/lr/dist/index.d.cts +303 -0
- package/node_modules/@lezer/lr/dist/index.d.ts +303 -0
- package/node_modules/@lezer/lr/dist/index.js +1884 -0
- package/node_modules/@lezer/lr/package.json +32 -0
- package/node_modules/@lezer/markdown/CHANGELOG.md +279 -0
- package/node_modules/@lezer/markdown/LICENSE +21 -0
- package/node_modules/@lezer/markdown/README.md +725 -0
- package/node_modules/@lezer/markdown/bin/build-readme.cjs +39 -0
- package/node_modules/@lezer/markdown/build.js +16 -0
- package/node_modules/@lezer/markdown/dist/index.cjs +2352 -0
- package/node_modules/@lezer/markdown/dist/index.d.cts +600 -0
- package/node_modules/@lezer/markdown/dist/index.d.ts +600 -0
- package/node_modules/@lezer/markdown/dist/index.js +2335 -0
- package/node_modules/@lezer/markdown/package.json +37 -0
- package/node_modules/@lezer/markdown/src/README.md +83 -0
- package/node_modules/@lezer/markdown/src/extension.ts +301 -0
- package/node_modules/@lezer/markdown/src/index.ts +5 -0
- package/node_modules/@lezer/markdown/src/markdown.ts +1961 -0
- package/node_modules/@lezer/markdown/src/nest.ts +46 -0
- package/node_modules/@lezer/markdown/test/compare-tree.ts +14 -0
- package/node_modules/@lezer/markdown/test/spec.ts +79 -0
- package/node_modules/@lezer/markdown/test/test-extension.ts +269 -0
- package/node_modules/@lezer/markdown/test/test-incremental.ts +265 -0
- package/node_modules/@lezer/markdown/test/test-markdown.ts +3574 -0
- package/node_modules/@lezer/markdown/test/test-nesting.ts +86 -0
- package/node_modules/@lezer/markdown/test/tsconfig.json +12 -0
- package/node_modules/@lezer/markdown/tsconfig.json +14 -0
- package/node_modules/@lezer/python/CHANGELOG.md +243 -0
- package/node_modules/@lezer/python/LICENSE +21 -0
- package/node_modules/@lezer/python/README.md +6 -0
- package/node_modules/@lezer/python/dist/index.cjs +330 -0
- package/node_modules/@lezer/python/dist/index.d.cts +3 -0
- package/node_modules/@lezer/python/dist/index.d.ts +3 -0
- package/node_modules/@lezer/python/dist/index.js +326 -0
- package/node_modules/@lezer/python/package.json +36 -0
- package/node_modules/@lezer/python/rollup.config.js +16 -0
- package/node_modules/@lezer/python/src/highlight.js +35 -0
- package/node_modules/@lezer/python/src/python.grammar +381 -0
- package/node_modules/@lezer/python/src/tokens.js +224 -0
- package/node_modules/@lezer/python/test/expression.txt +231 -0
- package/node_modules/@lezer/python/test/statement.txt +442 -0
- package/node_modules/@lezer/python/test/test-incremental.js +33 -0
- package/node_modules/@lezer/python/test/test-python.js +17 -0
- package/node_modules/@marijn/find-cluster-break/LICENSE +21 -0
- package/node_modules/@marijn/find-cluster-break/README.md +28 -0
- package/node_modules/@marijn/find-cluster-break/dist/index.cjs +85 -0
- package/node_modules/@marijn/find-cluster-break/dist/index.d.cts +15 -0
- package/node_modules/@marijn/find-cluster-break/package.json +35 -0
- package/node_modules/@marijn/find-cluster-break/rollup.config.js +7 -0
- package/node_modules/@marijn/find-cluster-break/src/index.d.ts +15 -0
- package/node_modules/@marijn/find-cluster-break/src/index.js +87 -0
- package/node_modules/@marijn/find-cluster-break/test/test-cluster.js +30 -0
- package/node_modules/crelt/LICENSE +19 -0
- package/node_modules/crelt/README.md +23 -0
- package/node_modules/crelt/dist/index.cjs +31 -0
- package/node_modules/crelt/dist/index.d.cts +4 -0
- package/node_modules/crelt/index.d.ts +4 -0
- package/node_modules/crelt/index.js +28 -0
- package/node_modules/crelt/package.json +35 -0
- package/node_modules/crelt/rollup.config.js +13 -0
- package/node_modules/style-mod/LICENSE +19 -0
- package/node_modules/style-mod/README.md +98 -0
- package/node_modules/style-mod/dist/style-mod.cjs +165 -0
- package/node_modules/style-mod/dist/style-mod.d.cts +16 -0
- package/node_modules/style-mod/package.json +39 -0
- package/node_modules/style-mod/src/README.md +34 -0
- package/node_modules/style-mod/src/style-mod.d.ts +16 -0
- package/node_modules/style-mod/src/style-mod.js +172 -0
- package/node_modules/style-mod/test/test-style-mod.js +104 -0
- package/node_modules/w3c-keyname/.tern-port +1 -0
- package/node_modules/w3c-keyname/LICENSE +19 -0
- package/node_modules/w3c-keyname/README.md +18 -0
- package/node_modules/w3c-keyname/index.cjs +127 -0
- package/node_modules/w3c-keyname/index.d.cts +5 -0
- package/node_modules/w3c-keyname/index.d.ts +5 -0
- package/node_modules/w3c-keyname/index.js +119 -0
- package/node_modules/w3c-keyname/package.json +37 -0
- package/package.json +1 -1
- package/packages/daemon/src/api.js +157 -2
- package/packages/daemon/src/filewatcher.js +59 -0
- package/packages/daemon/src/index.js +28 -1
- package/packages/daemon/src/skills.js +20 -0
- package/packages/gui/dist/assets/index-Dxg9hdf3.js +103 -0
- package/packages/gui/dist/index.html +1 -1
- package/packages/gui/package.json +15 -2
- package/packages/gui/src/App.jsx +3 -0
- package/packages/gui/src/components/CodeEditor.jsx +143 -0
- package/packages/gui/src/components/EditorTabs.jsx +83 -0
- package/packages/gui/src/components/FileTree.jsx +193 -0
- package/packages/gui/src/stores/groove.js +158 -1
- package/packages/gui/src/views/FileEditor.jsx +142 -0
- package/packages/gui/src/views/SkillsMarketplace.jsx +112 -1
- package/node_modules/@groove-dev/gui/dist/assets/index-CNCSwHwH.js +0 -74
- package/packages/gui/dist/assets/index-CNCSwHwH.js +0 -74
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (C) 2024 by Marijn Haverbeke <marijn@haverbeke.berlin>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# @marijn/find-cluster-break
|
|
2
|
+
|
|
3
|
+
Small JavaScript module for finding grapheme cluster breaks in
|
|
4
|
+
strings, scanning from a given position.
|
|
5
|
+
|
|
6
|
+
```javascript
|
|
7
|
+
import {findClusterBreak} from "@marijn/find-cluster-break"
|
|
8
|
+
console.log(findClusterBreak("💪🏽🦋", 0))
|
|
9
|
+
// → 4
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
This code is open source, released under an MIT license.
|
|
13
|
+
|
|
14
|
+
## Documentation
|
|
15
|
+
|
|
16
|
+
**`findClusterBreak`**`(str: string, pos: number, forward = true, includeExtending = true): number`
|
|
17
|
+
|
|
18
|
+
Returns a next grapheme cluster break _after_ (not equal to) `pos`,
|
|
19
|
+
if `forward` is true, or before otherwise. Returns `pos` itself if no
|
|
20
|
+
further cluster break is available in the string. Moves across
|
|
21
|
+
surrogate pairs, extending characters (when `includeExtending` is
|
|
22
|
+
true, which is the default), characters joined with zero-width joiners,
|
|
23
|
+
and flag emoji.
|
|
24
|
+
|
|
25
|
+
**`isExtendingChar`**`(code: number): boolean`
|
|
26
|
+
|
|
27
|
+
Query whether the given character has a `Grapheme_Cluster_Break` value
|
|
28
|
+
of `Extend` in Unicode.
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// These are filled with ranges (rangeFrom[i] up to but not including
|
|
4
|
+
// rangeTo[i]) of code points that count as extending characters.
|
|
5
|
+
let rangeFrom = [], rangeTo = []
|
|
6
|
+
|
|
7
|
+
;(() => {
|
|
8
|
+
// Compressed representation of the Grapheme_Cluster_Break=Extend
|
|
9
|
+
// information from
|
|
10
|
+
// http://www.unicode.org/Public/16.0.0/ucd/auxiliary/GraphemeBreakProperty.txt.
|
|
11
|
+
// Each pair of elements represents a range, as an offet from the
|
|
12
|
+
// previous range and a length. Numbers are in base-36, with the empty
|
|
13
|
+
// string being a shorthand for 1.
|
|
14
|
+
let numbers = "lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(s => s ? parseInt(s, 36) : 1);
|
|
15
|
+
for (let i = 0, n = 0; i < numbers.length; i++)
|
|
16
|
+
(i % 2 ? rangeTo : rangeFrom).push(n = n + numbers[i]);
|
|
17
|
+
})();
|
|
18
|
+
|
|
19
|
+
function isExtendingChar(code) {
|
|
20
|
+
if (code < 768) return false
|
|
21
|
+
for (let from = 0, to = rangeFrom.length;;) {
|
|
22
|
+
let mid = (from + to) >> 1;
|
|
23
|
+
if (code < rangeFrom[mid]) to = mid;
|
|
24
|
+
else if (code >= rangeTo[mid]) from = mid + 1;
|
|
25
|
+
else return true
|
|
26
|
+
if (from == to) return false
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function isRegionalIndicator(code) {
|
|
31
|
+
return code >= 0x1F1E6 && code <= 0x1F1FF
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const ZWJ = 0x200d;
|
|
35
|
+
|
|
36
|
+
function findClusterBreak(str, pos, forward = true, includeExtending = true) {
|
|
37
|
+
return (forward ? nextClusterBreak : prevClusterBreak)(str, pos, includeExtending)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function nextClusterBreak(str, pos, includeExtending) {
|
|
41
|
+
if (pos == str.length) return pos
|
|
42
|
+
// If pos is in the middle of a surrogate pair, move to its start
|
|
43
|
+
if (pos && surrogateLow(str.charCodeAt(pos)) && surrogateHigh(str.charCodeAt(pos - 1))) pos--;
|
|
44
|
+
let prev = codePointAt(str, pos);
|
|
45
|
+
pos += codePointSize(prev);
|
|
46
|
+
while (pos < str.length) {
|
|
47
|
+
let next = codePointAt(str, pos);
|
|
48
|
+
if (prev == ZWJ || next == ZWJ || includeExtending && isExtendingChar(next)) {
|
|
49
|
+
pos += codePointSize(next);
|
|
50
|
+
prev = next;
|
|
51
|
+
} else if (isRegionalIndicator(next)) {
|
|
52
|
+
let countBefore = 0, i = pos - 2;
|
|
53
|
+
while (i >= 0 && isRegionalIndicator(codePointAt(str, i))) { countBefore++; i -= 2; }
|
|
54
|
+
if (countBefore % 2 == 0) break
|
|
55
|
+
else pos += 2;
|
|
56
|
+
} else {
|
|
57
|
+
break
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return pos
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function prevClusterBreak(str, pos, includeExtending) {
|
|
64
|
+
while (pos > 0) {
|
|
65
|
+
let found = nextClusterBreak(str, pos - 2, includeExtending);
|
|
66
|
+
if (found < pos) return found
|
|
67
|
+
pos--;
|
|
68
|
+
}
|
|
69
|
+
return 0
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function codePointAt(str, pos) {
|
|
73
|
+
let code0 = str.charCodeAt(pos);
|
|
74
|
+
if (!surrogateHigh(code0) || pos + 1 == str.length) return code0
|
|
75
|
+
let code1 = str.charCodeAt(pos + 1);
|
|
76
|
+
if (!surrogateLow(code1)) return code0
|
|
77
|
+
return ((code0 - 0xd800) << 10) + (code1 - 0xdc00) + 0x10000
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function surrogateLow(ch) { return ch >= 0xDC00 && ch < 0xE000 }
|
|
81
|
+
function surrogateHigh(ch) { return ch >= 0xD800 && ch < 0xDC00 }
|
|
82
|
+
function codePointSize(code) { return code < 0x10000 ? 1 : 2 }
|
|
83
|
+
|
|
84
|
+
exports.findClusterBreak = findClusterBreak;
|
|
85
|
+
exports.isExtendingChar = isExtendingChar;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Query whether the given character has a `Grapheme_Cluster_Break`
|
|
3
|
+
value of `Extend` in Unicode.
|
|
4
|
+
*/
|
|
5
|
+
export declare function isExtendingChar(code: number): boolean
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
Returns a next grapheme cluster break _after_ (not equal to) `pos`,
|
|
9
|
+
if `forward` is true, or before otherwise. Returns `pos` itself if no
|
|
10
|
+
further cluster break is available in the string. Moves across
|
|
11
|
+
surrogate pairs, extending characters (when `includeExtending` is
|
|
12
|
+
true, which is the default), characters joined with zero-width joiners,
|
|
13
|
+
and flag emoji.
|
|
14
|
+
*/
|
|
15
|
+
export declare function findClusterBreak(str: string, pos: number, forward?: boolean, includeExtending?: boolean): number
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@marijn/find-cluster-break",
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Find the position of grapheme cluster breaks in a string",
|
|
6
|
+
"main": "src/index.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
"import": "./src/index.js",
|
|
9
|
+
"require": "./dist/index.cjs"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"test": "mocha test/*.js",
|
|
13
|
+
"prepare": "rollup -c"
|
|
14
|
+
},
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/marijnh/find-cluster-break.git"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"unicode",
|
|
21
|
+
"grapheme",
|
|
22
|
+
"cluster",
|
|
23
|
+
"break"
|
|
24
|
+
],
|
|
25
|
+
"author": "Marijn Haverbeke <marijn@haverbeke.berlin>",
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"bugs": {
|
|
28
|
+
"url": "https://github.com/marijnh/find-cluster-break/issues"
|
|
29
|
+
},
|
|
30
|
+
"homepage": "https://github.com/marijnh/find-cluster-break#readme",
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"mocha": "^10.7.3",
|
|
33
|
+
"rollup": "^4.28.1"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Query whether the given character has a `Grapheme_Cluster_Break`
|
|
3
|
+
value of `Extend` in Unicode.
|
|
4
|
+
*/
|
|
5
|
+
export declare function isExtendingChar(code: number): boolean
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
Returns a next grapheme cluster break _after_ (not equal to) `pos`,
|
|
9
|
+
if `forward` is true, or before otherwise. Returns `pos` itself if no
|
|
10
|
+
further cluster break is available in the string. Moves across
|
|
11
|
+
surrogate pairs, extending characters (when `includeExtending` is
|
|
12
|
+
true, which is the default), characters joined with zero-width joiners,
|
|
13
|
+
and flag emoji.
|
|
14
|
+
*/
|
|
15
|
+
export declare function findClusterBreak(str: string, pos: number, forward?: boolean, includeExtending?: boolean): number
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// These are filled with ranges (rangeFrom[i] up to but not including
|
|
2
|
+
// rangeTo[i]) of code points that count as extending characters.
|
|
3
|
+
let rangeFrom = [], rangeTo = []
|
|
4
|
+
|
|
5
|
+
;(() => {
|
|
6
|
+
// Compressed representation of the Grapheme_Cluster_Break=Extend
|
|
7
|
+
// information from
|
|
8
|
+
// http://www.unicode.org/Public/16.0.0/ucd/auxiliary/GraphemeBreakProperty.txt.
|
|
9
|
+
// Each pair of elements represents a range, as an offet from the
|
|
10
|
+
// previous range and a length. Numbers are in base-36, with the empty
|
|
11
|
+
// string being a shorthand for 1.
|
|
12
|
+
let numbers = "lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(s => s ? parseInt(s, 36) : 1)
|
|
13
|
+
for (let i = 0, n = 0; i < numbers.length; i++)
|
|
14
|
+
(i % 2 ? rangeTo : rangeFrom).push(n = n + numbers[i])
|
|
15
|
+
})()
|
|
16
|
+
|
|
17
|
+
export function isExtendingChar(code) {
|
|
18
|
+
if (code < 768) return false
|
|
19
|
+
for (let from = 0, to = rangeFrom.length;;) {
|
|
20
|
+
let mid = (from + to) >> 1
|
|
21
|
+
if (code < rangeFrom[mid]) to = mid
|
|
22
|
+
else if (code >= rangeTo[mid]) from = mid + 1
|
|
23
|
+
else return true
|
|
24
|
+
if (from == to) return false
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function isRegionalIndicator(code) {
|
|
29
|
+
return code >= 0x1F1E6 && code <= 0x1F1FF
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function check(code) {
|
|
33
|
+
for (let i = 0; i < rangeFrom.length; i++) {
|
|
34
|
+
if (rangeTo[i] > code) return rangeFrom[i] <= code
|
|
35
|
+
}
|
|
36
|
+
return false
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const ZWJ = 0x200d
|
|
40
|
+
|
|
41
|
+
export function findClusterBreak(str, pos, forward = true, includeExtending = true) {
|
|
42
|
+
return (forward ? nextClusterBreak : prevClusterBreak)(str, pos, includeExtending)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function nextClusterBreak(str, pos, includeExtending) {
|
|
46
|
+
if (pos == str.length) return pos
|
|
47
|
+
// If pos is in the middle of a surrogate pair, move to its start
|
|
48
|
+
if (pos && surrogateLow(str.charCodeAt(pos)) && surrogateHigh(str.charCodeAt(pos - 1))) pos--
|
|
49
|
+
let prev = codePointAt(str, pos)
|
|
50
|
+
pos += codePointSize(prev)
|
|
51
|
+
while (pos < str.length) {
|
|
52
|
+
let next = codePointAt(str, pos)
|
|
53
|
+
if (prev == ZWJ || next == ZWJ || includeExtending && isExtendingChar(next)) {
|
|
54
|
+
pos += codePointSize(next)
|
|
55
|
+
prev = next
|
|
56
|
+
} else if (isRegionalIndicator(next)) {
|
|
57
|
+
let countBefore = 0, i = pos - 2
|
|
58
|
+
while (i >= 0 && isRegionalIndicator(codePointAt(str, i))) { countBefore++; i -= 2 }
|
|
59
|
+
if (countBefore % 2 == 0) break
|
|
60
|
+
else pos += 2
|
|
61
|
+
} else {
|
|
62
|
+
break
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return pos
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function prevClusterBreak(str, pos, includeExtending) {
|
|
69
|
+
while (pos > 0) {
|
|
70
|
+
let found = nextClusterBreak(str, pos - 2, includeExtending)
|
|
71
|
+
if (found < pos) return found
|
|
72
|
+
pos--
|
|
73
|
+
}
|
|
74
|
+
return 0
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function codePointAt(str, pos) {
|
|
78
|
+
let code0 = str.charCodeAt(pos)
|
|
79
|
+
if (!surrogateHigh(code0) || pos + 1 == str.length) return code0
|
|
80
|
+
let code1 = str.charCodeAt(pos + 1)
|
|
81
|
+
if (!surrogateLow(code1)) return code0
|
|
82
|
+
return ((code0 - 0xd800) << 10) + (code1 - 0xdc00) + 0x10000
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function surrogateLow(ch) { return ch >= 0xDC00 && ch < 0xE000 }
|
|
86
|
+
function surrogateHigh(ch) { return ch >= 0xD800 && ch < 0xDC00 }
|
|
87
|
+
function codePointSize(code) { return code < 0x10000 ? 1 : 2 }
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {findClusterBreak} from "../src/index.js"
|
|
2
|
+
|
|
3
|
+
function assertEq(a, b) {
|
|
4
|
+
if (a !== b) throw new Error(`${a} !== ${b}`)
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
describe("findClusterBreak", () => {
|
|
8
|
+
function test(spec) {
|
|
9
|
+
it(spec, () => {
|
|
10
|
+
let breaks = [], next
|
|
11
|
+
while ((next = spec.indexOf("|")) > -1) {
|
|
12
|
+
breaks.push(next)
|
|
13
|
+
spec = spec.slice(0, next) + spec.slice(next + 1)
|
|
14
|
+
}
|
|
15
|
+
let found = []
|
|
16
|
+
for (let i = 0;;) {
|
|
17
|
+
let next = findClusterBreak(spec, i)
|
|
18
|
+
if (next == spec.length) break
|
|
19
|
+
found.push(i = next)
|
|
20
|
+
}
|
|
21
|
+
assertEq(found.join(","), breaks.join(","))
|
|
22
|
+
})
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
test("a|b|c|d")
|
|
26
|
+
test("a|é̠|ő|x")
|
|
27
|
+
test("😎|🙉")
|
|
28
|
+
test("👨🎤|💪🏽|👩👩👧👦|❤")
|
|
29
|
+
test("🇩🇪|🇫🇷|🇪🇸|x|🇮🇹")
|
|
30
|
+
})
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (C) 2020 by Marijn Haverbeke <marijn@haverbeke.berlin>
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
|
11
|
+
all copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# CRELT
|
|
2
|
+
|
|
3
|
+
Tiny DOM-element creation utility. Exports a single (default) value,
|
|
4
|
+
which is a function that you call with:
|
|
5
|
+
|
|
6
|
+
- A tag name string or DOM element.
|
|
7
|
+
|
|
8
|
+
- Optionally an attribute object mapping names to values. When the
|
|
9
|
+
values are strings, they are added to the element with
|
|
10
|
+
`setAttribute`. When they have another type, they are assigned as
|
|
11
|
+
regular properties (mostly useful for event handlers via `onclick`
|
|
12
|
+
and such). When an attribute's value is null or undefined, it is
|
|
13
|
+
not assigned.
|
|
14
|
+
|
|
15
|
+
- Any number of children, which may be null (ignored), strings (added
|
|
16
|
+
as text nodes), DOM nodes (added), or arrays (each element is added
|
|
17
|
+
separately).
|
|
18
|
+
|
|
19
|
+
The function returns a DOM element.
|
|
20
|
+
|
|
21
|
+
## License
|
|
22
|
+
|
|
23
|
+
This software is licensed under an MIT license.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function crelt() {
|
|
4
|
+
var elt = arguments[0];
|
|
5
|
+
if (typeof elt == "string") elt = document.createElement(elt);
|
|
6
|
+
var i = 1, next = arguments[1];
|
|
7
|
+
if (next && typeof next == "object" && next.nodeType == null && !Array.isArray(next)) {
|
|
8
|
+
for (var name in next) if (Object.prototype.hasOwnProperty.call(next, name)) {
|
|
9
|
+
var value = next[name];
|
|
10
|
+
if (typeof value == "string") elt.setAttribute(name, value);
|
|
11
|
+
else if (value != null) elt[name] = value;
|
|
12
|
+
}
|
|
13
|
+
i++;
|
|
14
|
+
}
|
|
15
|
+
for (; i < arguments.length; i++) add(elt, arguments[i]);
|
|
16
|
+
return elt
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function add(elt, child) {
|
|
20
|
+
if (typeof child == "string") {
|
|
21
|
+
elt.appendChild(document.createTextNode(child));
|
|
22
|
+
} else if (child == null) ; else if (child.nodeType != null) {
|
|
23
|
+
elt.appendChild(child);
|
|
24
|
+
} else if (Array.isArray(child)) {
|
|
25
|
+
for (var i = 0; i < child.length; i++) add(elt, child[i]);
|
|
26
|
+
} else {
|
|
27
|
+
throw new RangeError("Unsupported child node: " + child)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
module.exports = crelt;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
type Child = string | Node | null | undefined | readonly Child[]
|
|
2
|
+
|
|
3
|
+
export default function crelt(elt: string | HTMLElement, attrs: {[attr: string]: any}, ...children: Child[]): HTMLElement
|
|
4
|
+
export default function crelt(elt: string | HTMLElement, ...children: Child[]): HTMLElement
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
type Child = string | Node | null | undefined | readonly Child[]
|
|
2
|
+
|
|
3
|
+
export default function crelt(elt: string | HTMLElement, attrs: {[attr: string]: any}, ...children: Child[]): HTMLElement
|
|
4
|
+
export default function crelt(elt: string | HTMLElement, ...children: Child[]): HTMLElement
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export default function crelt() {
|
|
2
|
+
var elt = arguments[0]
|
|
3
|
+
if (typeof elt == "string") elt = document.createElement(elt)
|
|
4
|
+
var i = 1, next = arguments[1]
|
|
5
|
+
if (next && typeof next == "object" && next.nodeType == null && !Array.isArray(next)) {
|
|
6
|
+
for (var name in next) if (Object.prototype.hasOwnProperty.call(next, name)) {
|
|
7
|
+
var value = next[name]
|
|
8
|
+
if (typeof value == "string") elt.setAttribute(name, value)
|
|
9
|
+
else if (value != null) elt[name] = value
|
|
10
|
+
}
|
|
11
|
+
i++
|
|
12
|
+
}
|
|
13
|
+
for (; i < arguments.length; i++) add(elt, arguments[i])
|
|
14
|
+
return elt
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function add(elt, child) {
|
|
18
|
+
if (typeof child == "string") {
|
|
19
|
+
elt.appendChild(document.createTextNode(child))
|
|
20
|
+
} else if (child == null) {
|
|
21
|
+
} else if (child.nodeType != null) {
|
|
22
|
+
elt.appendChild(child)
|
|
23
|
+
} else if (Array.isArray(child)) {
|
|
24
|
+
for (var i = 0; i < child.length; i++) add(elt, child[i])
|
|
25
|
+
} else {
|
|
26
|
+
throw new RangeError("Unsupported child node: " + child)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "crelt",
|
|
3
|
+
"version": "1.0.6",
|
|
4
|
+
"description": "Tiny DOM-element-creation utility",
|
|
5
|
+
"main": "dist/index.cjs",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"exports": {
|
|
8
|
+
"import": "./index.js",
|
|
9
|
+
"require": "./dist/index.cjs"
|
|
10
|
+
},
|
|
11
|
+
"module": "index.js",
|
|
12
|
+
"types": "index.d.ts",
|
|
13
|
+
"scripts": {
|
|
14
|
+
"prepare": "rollup -c"
|
|
15
|
+
},
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/marijnh/crelt.git"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"dom",
|
|
22
|
+
"creation",
|
|
23
|
+
"crel"
|
|
24
|
+
],
|
|
25
|
+
"author": "Marijn Haverbeke <marijn@haverbeke.berlin>",
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"bugs": {
|
|
28
|
+
"url": "https://github.com/marijnh/crelt/issues"
|
|
29
|
+
},
|
|
30
|
+
"homepage": "https://github.com/marijnh/crelt#readme",
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"rollup": "^2.0.5",
|
|
33
|
+
"rollup-plugin-copy": "^3.4.0"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import copy from "rollup-plugin-copy"
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
input: "index.js",
|
|
5
|
+
output: {
|
|
6
|
+
file: "dist/index.cjs",
|
|
7
|
+
format: "cjs",
|
|
8
|
+
exports: "default"
|
|
9
|
+
},
|
|
10
|
+
plugins: [
|
|
11
|
+
copy({targets: [{src: "index.d.ts", dest: "dist", rename: () => "index.d.cts"}]})
|
|
12
|
+
]
|
|
13
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (C) 2018 by Marijn Haverbeke <marijn@haverbeke.berlin> and others
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
|
11
|
+
all copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
<!-- To edit this file, edit /src/README.md, not /README.md -->
|
|
2
|
+
|
|
3
|
+
# style-mod
|
|
4
|
+
|
|
5
|
+
Minimal CSS module shim for generating CSS rules for sets of style
|
|
6
|
+
-declarations and attaching such a set to a document or shadow root.
|
|
7
|
+
|
|
8
|
+
Using it would look something like this:
|
|
9
|
+
|
|
10
|
+
```javascript
|
|
11
|
+
const {StyleModule} = require("style-mod")
|
|
12
|
+
const myModule = new StyleModule({
|
|
13
|
+
"#main": {
|
|
14
|
+
fontFamily: "Georgia, 'Nimbus Roman No9 L'",
|
|
15
|
+
margin: "0"
|
|
16
|
+
},
|
|
17
|
+
".callout": {
|
|
18
|
+
color: "red",
|
|
19
|
+
fontWeight: "bold",
|
|
20
|
+
"&:hover": {color: "orange"}
|
|
21
|
+
}
|
|
22
|
+
})
|
|
23
|
+
StyleModule.mount(document, myModule)
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
This code is open source, released under an MIT license.
|
|
27
|
+
|
|
28
|
+
## Documentation
|
|
29
|
+
|
|
30
|
+
### class StyleModule
|
|
31
|
+
|
|
32
|
+
Style modules encapsulate a set of CSS rules defined from
|
|
33
|
+
JavaScript. Their definitions are only available in a given DOM
|
|
34
|
+
root after it has been _mounted_ there with `StyleModule.mount`.
|
|
35
|
+
|
|
36
|
+
Style modules should be created once and stored somewhere, as
|
|
37
|
+
opposed to re-creating them every time you need them. The amount of
|
|
38
|
+
CSS rules generated for a given DOM root is bounded by the amount
|
|
39
|
+
of style modules that were used. So to avoid leaking rules, don't
|
|
40
|
+
create these dynamically, but treat them as one-time allocations.
|
|
41
|
+
|
|
42
|
+
* `new `**`StyleModule`**`(spec: Object< Style >, options: ?{finish: ?fn(string) → string})`\
|
|
43
|
+
Create a style module from the given spec.
|
|
44
|
+
|
|
45
|
+
When `finish` is given, it is called on regular (non-`@`)
|
|
46
|
+
selectors (after `&` expansion) to compute the final selector.
|
|
47
|
+
|
|
48
|
+
* **`getRules`**`() → string`\
|
|
49
|
+
Returns a string containing the module's CSS rules.
|
|
50
|
+
|
|
51
|
+
* `static `**`newName`**`() → string`\
|
|
52
|
+
Generate a new unique CSS class name.
|
|
53
|
+
|
|
54
|
+
* `static `**`mount`**`(root: Document | ShadowRoot, modules: [StyleModule] | StyleModule, options: ?{nonce: ?string})`\
|
|
55
|
+
Mount the given set of modules in the given DOM root, which ensures
|
|
56
|
+
that the CSS rules defined by the module are available in that
|
|
57
|
+
context.
|
|
58
|
+
|
|
59
|
+
Rules are only added to the document once per root.
|
|
60
|
+
|
|
61
|
+
Rule order will follow the order of the modules, so that rules from
|
|
62
|
+
modules later in the array take precedence of those from earlier
|
|
63
|
+
modules. If you call this function multiple times for the same root
|
|
64
|
+
in a way that changes the order of already mounted modules, the old
|
|
65
|
+
order will be changed.
|
|
66
|
+
|
|
67
|
+
If a Content Security Policy nonce is provided, it is added to
|
|
68
|
+
the `<style>` tag generated by the library.
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
Where the `Style` type is defined as:
|
|
72
|
+
|
|
73
|
+
* **`Style`**`: Object< Style | string >`\
|
|
74
|
+
A style is an object that, in the simple case, maps CSS property
|
|
75
|
+
names to strings holding their values, as in `{color: "red",
|
|
76
|
+
fontWeight: "bold"}`. The property names can be given in
|
|
77
|
+
camel-case—the library will insert a dash before capital letters
|
|
78
|
+
when converting them to CSS.
|
|
79
|
+
|
|
80
|
+
If you include an underscore in a property name, it and everything
|
|
81
|
+
after it will be removed from the output, which can be useful when
|
|
82
|
+
providing a property multiple times, for browser compatibility
|
|
83
|
+
reasons.
|
|
84
|
+
|
|
85
|
+
A property in a style object can also be a sub-selector, which
|
|
86
|
+
extends the current context to add a pseudo-selector or a child
|
|
87
|
+
selector. Such a property should contain a `&` character, which
|
|
88
|
+
will be replaced by the current selector. For example `{"&:before":
|
|
89
|
+
{content: '"hi"'}}`. Sub-selectors and regular properties can
|
|
90
|
+
freely be mixed in a given object. Any property containing a `&` is
|
|
91
|
+
assumed to be a sub-selector.
|
|
92
|
+
|
|
93
|
+
Finally, a property can specify an @-block to be wrapped around the
|
|
94
|
+
styles defined inside the object that's the property's value. For
|
|
95
|
+
example to create a media query you can do `{"@media screen and
|
|
96
|
+
(min-width: 400px)": {...}}`.
|
|
97
|
+
|
|
98
|
+
|