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,165 @@
|
|
|
1
|
+
var C = "\u037c"
|
|
2
|
+
var COUNT = typeof Symbol == "undefined" ? "__" + C : Symbol.for(C)
|
|
3
|
+
var SET = typeof Symbol == "undefined" ? "__styleSet" + Math.floor(Math.random() * 1e8) : Symbol("styleSet")
|
|
4
|
+
var top = typeof globalThis != "undefined" ? globalThis : typeof window != "undefined" ? window : {}
|
|
5
|
+
|
|
6
|
+
// :: - Style modules encapsulate a set of CSS rules defined from
|
|
7
|
+
// JavaScript. Their definitions are only available in a given DOM
|
|
8
|
+
// root after it has been _mounted_ there with `StyleModule.mount`.
|
|
9
|
+
//
|
|
10
|
+
// Style modules should be created once and stored somewhere, as
|
|
11
|
+
// opposed to re-creating them every time you need them. The amount of
|
|
12
|
+
// CSS rules generated for a given DOM root is bounded by the amount
|
|
13
|
+
// of style modules that were used. So to avoid leaking rules, don't
|
|
14
|
+
// create these dynamically, but treat them as one-time allocations.
|
|
15
|
+
var StyleModule = exports.StyleModule = function StyleModule(spec, options) {
|
|
16
|
+
this.rules = []
|
|
17
|
+
var ref = options || {};
|
|
18
|
+
var finish = ref.finish;
|
|
19
|
+
|
|
20
|
+
function splitSelector(selector) {
|
|
21
|
+
return /^@/.test(selector) ? [selector] : selector.split(/,\s*/)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function render(selectors, spec, target, isKeyframes) {
|
|
25
|
+
var local = [], isAt = /^@(\w+)\b/.exec(selectors[0]), keyframes = isAt && isAt[1] == "keyframes"
|
|
26
|
+
if (isAt && spec == null) { return target.push(selectors[0] + ";") }
|
|
27
|
+
for (var prop in spec) {
|
|
28
|
+
var value = spec[prop]
|
|
29
|
+
if (/&/.test(prop)) {
|
|
30
|
+
render(prop.split(/,\s*/).map(function (part) { return selectors.map(function (sel) { return part.replace(/&/, sel); }); }).reduce(function (a, b) { return a.concat(b); }),
|
|
31
|
+
value, target)
|
|
32
|
+
} else if (value && typeof value == "object") {
|
|
33
|
+
if (!isAt) { throw new RangeError("The value of a property (" + prop + ") should be a primitive value.") }
|
|
34
|
+
render(splitSelector(prop), value, local, keyframes)
|
|
35
|
+
} else if (value != null) {
|
|
36
|
+
local.push(prop.replace(/_.*/, "").replace(/[A-Z]/g, function (l) { return "-" + l.toLowerCase(); }) + ": " + value + ";")
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (local.length || keyframes) {
|
|
40
|
+
target.push((finish && !isAt && !isKeyframes ? selectors.map(finish) : selectors).join(", ") +
|
|
41
|
+
" {" + local.join(" ") + "}")
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
for (var prop in spec) { render(splitSelector(prop), spec[prop], this.rules) }
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// :: () → string
|
|
49
|
+
// Returns a string containing the module's CSS rules.
|
|
50
|
+
StyleModule.prototype.getRules = function getRules () { return this.rules.join("\n") };
|
|
51
|
+
|
|
52
|
+
// :: () → string
|
|
53
|
+
// Generate a new unique CSS class name.
|
|
54
|
+
StyleModule.newName = function newName () {
|
|
55
|
+
var id = top[COUNT] || 1
|
|
56
|
+
top[COUNT] = id + 1
|
|
57
|
+
return C + id.toString(36)
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
// :: (union<Document, ShadowRoot>, union<[StyleModule], StyleModule>, ?{nonce: ?string})
|
|
61
|
+
//
|
|
62
|
+
// Mount the given set of modules in the given DOM root, which ensures
|
|
63
|
+
// that the CSS rules defined by the module are available in that
|
|
64
|
+
// context.
|
|
65
|
+
//
|
|
66
|
+
// Rules are only added to the document once per root.
|
|
67
|
+
//
|
|
68
|
+
// Rule order will follow the order of the modules, so that rules from
|
|
69
|
+
// modules later in the array take precedence of those from earlier
|
|
70
|
+
// modules. If you call this function multiple times for the same root
|
|
71
|
+
// in a way that changes the order of already mounted modules, the old
|
|
72
|
+
// order will be changed.
|
|
73
|
+
//
|
|
74
|
+
// If a Content Security Policy nonce is provided, it is added to
|
|
75
|
+
// the `<style>` tag generated by the library.
|
|
76
|
+
StyleModule.mount = function mount (root, modules, options) {
|
|
77
|
+
var set = root[SET], nonce = options && options.nonce
|
|
78
|
+
if (!set) { set = new StyleSet(root, nonce) }
|
|
79
|
+
else if (nonce) { set.setNonce(nonce) }
|
|
80
|
+
set.mount(Array.isArray(modules) ? modules : [modules], root)
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
var adoptedSet = new Map //<Document, StyleSet>
|
|
84
|
+
|
|
85
|
+
var StyleSet = function StyleSet(root, nonce) {
|
|
86
|
+
var doc = root.ownerDocument || root, win = doc.defaultView
|
|
87
|
+
if (!root.head && root.adoptedStyleSheets && win.CSSStyleSheet) {
|
|
88
|
+
var adopted = adoptedSet.get(doc)
|
|
89
|
+
if (adopted) { return root[SET] = adopted }
|
|
90
|
+
this.sheet = new win.CSSStyleSheet
|
|
91
|
+
adoptedSet.set(doc, this)
|
|
92
|
+
} else {
|
|
93
|
+
this.styleTag = doc.createElement("style")
|
|
94
|
+
if (nonce) { this.styleTag.setAttribute("nonce", nonce) }
|
|
95
|
+
}
|
|
96
|
+
this.modules = []
|
|
97
|
+
root[SET] = this
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
StyleSet.prototype.mount = function mount (modules, root) {
|
|
101
|
+
var sheet = this.sheet
|
|
102
|
+
var pos = 0 /* Current rule offset */, j = 0 /* Index into this.modules */
|
|
103
|
+
for (var i = 0; i < modules.length; i++) {
|
|
104
|
+
var mod = modules[i], index = this.modules.indexOf(mod)
|
|
105
|
+
if (index < j && index > -1) { // Ordering conflict
|
|
106
|
+
this.modules.splice(index, 1)
|
|
107
|
+
j--
|
|
108
|
+
index = -1
|
|
109
|
+
}
|
|
110
|
+
if (index == -1) {
|
|
111
|
+
this.modules.splice(j++, 0, mod)
|
|
112
|
+
if (sheet) { for (var k = 0; k < mod.rules.length; k++)
|
|
113
|
+
{ sheet.insertRule(mod.rules[k], pos++) } }
|
|
114
|
+
} else {
|
|
115
|
+
while (j < index) { pos += this.modules[j++].rules.length }
|
|
116
|
+
pos += mod.rules.length
|
|
117
|
+
j++
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (sheet) {
|
|
122
|
+
if (root.adoptedStyleSheets.indexOf(this.sheet) < 0)
|
|
123
|
+
{ root.adoptedStyleSheets = [this.sheet ].concat( root.adoptedStyleSheets) }
|
|
124
|
+
} else {
|
|
125
|
+
var text = ""
|
|
126
|
+
for (var i$1 = 0; i$1 < this.modules.length; i$1++)
|
|
127
|
+
{ text += this.modules[i$1].getRules() + "\n" }
|
|
128
|
+
this.styleTag.textContent = text
|
|
129
|
+
var target = root.head || root
|
|
130
|
+
if (this.styleTag.parentNode != target)
|
|
131
|
+
{ target.insertBefore(this.styleTag, target.firstChild) }
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
StyleSet.prototype.setNonce = function setNonce (nonce) {
|
|
136
|
+
if (this.styleTag && this.styleTag.getAttribute("nonce") != nonce)
|
|
137
|
+
{ this.styleTag.setAttribute("nonce", nonce) }
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
// Style::Object<union<Style,string>>
|
|
141
|
+
//
|
|
142
|
+
// A style is an object that, in the simple case, maps CSS property
|
|
143
|
+
// names to strings holding their values, as in `{color: "red",
|
|
144
|
+
// fontWeight: "bold"}`. The property names can be given in
|
|
145
|
+
// camel-case—the library will insert a dash before capital letters
|
|
146
|
+
// when converting them to CSS.
|
|
147
|
+
//
|
|
148
|
+
// If you include an underscore in a property name, it and everything
|
|
149
|
+
// after it will be removed from the output, which can be useful when
|
|
150
|
+
// providing a property multiple times, for browser compatibility
|
|
151
|
+
// reasons.
|
|
152
|
+
//
|
|
153
|
+
// A property in a style object can also be a sub-selector, which
|
|
154
|
+
// extends the current context to add a pseudo-selector or a child
|
|
155
|
+
// selector. Such a property should contain a `&` character, which
|
|
156
|
+
// will be replaced by the current selector. For example `{"&:before":
|
|
157
|
+
// {content: '"hi"'}}`. Sub-selectors and regular properties can
|
|
158
|
+
// freely be mixed in a given object. Any property containing a `&` is
|
|
159
|
+
// assumed to be a sub-selector.
|
|
160
|
+
//
|
|
161
|
+
// Finally, a property can specify an @-block to be wrapped around the
|
|
162
|
+
// styles defined inside the object that's the property's value. For
|
|
163
|
+
// example to create a media query you can do `{"@media screen and
|
|
164
|
+
// (min-width: 400px)": {...}}`.
|
|
165
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export class StyleModule {
|
|
2
|
+
constructor(spec: {[selector: string]: StyleSpec}, options?: {
|
|
3
|
+
finish?(sel: string): string
|
|
4
|
+
})
|
|
5
|
+
getRules(): string
|
|
6
|
+
static mount(
|
|
7
|
+
root: Document | ShadowRoot | DocumentOrShadowRoot,
|
|
8
|
+
module: StyleModule | ReadonlyArray<StyleModule>,
|
|
9
|
+
options?: {nonce?: string}
|
|
10
|
+
): void
|
|
11
|
+
static newName(): string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type StyleSpec = {
|
|
15
|
+
[propOrSelector: string]: string | number | StyleSpec | null
|
|
16
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "style-mod",
|
|
3
|
+
"version": "4.1.3",
|
|
4
|
+
"description": "A minimal CSS module shim",
|
|
5
|
+
"main": "dist/style-mod.cjs",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"exports": {
|
|
8
|
+
"import": "./src/style-mod.js",
|
|
9
|
+
"require": "./dist/style-mod.cjs"
|
|
10
|
+
},
|
|
11
|
+
"module": "src/style-mod.js",
|
|
12
|
+
"types": "src/style-mod.d.ts",
|
|
13
|
+
"directories": {
|
|
14
|
+
"test": "test"
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"test": "npm run build && mocha test/test-*.js",
|
|
18
|
+
"build": "mkdir -p dist; buble --no modules src/style-mod.js | sed -e 's/export var StyleModule/var StyleModule = exports.StyleModule/' > dist/style-mod.cjs; cp src/style-mod.d.ts dist/style-mod.d.cts",
|
|
19
|
+
"prepare": "npm run build && npm run build-readme",
|
|
20
|
+
"build-readme": "builddocs --name style-mod --main src/README.md --format markdown src/*.js > README.md"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"css",
|
|
24
|
+
"module",
|
|
25
|
+
"styling"
|
|
26
|
+
],
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "git+https://github.com/marijnh/style-mod.git"
|
|
30
|
+
},
|
|
31
|
+
"author": "Marijn Haverbeke <marijn@haverbeke.berlin>",
|
|
32
|
+
"license": "MIT",
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"buble": "^0.20.0",
|
|
35
|
+
"builddocs": "^0.3.2",
|
|
36
|
+
"ist": "^1.1.1",
|
|
37
|
+
"mocha": "^7.2.0"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
@StyleModule
|
|
31
|
+
|
|
32
|
+
Where the `Style` type is defined as:
|
|
33
|
+
|
|
34
|
+
@Style
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export class StyleModule {
|
|
2
|
+
constructor(spec: {[selector: string]: StyleSpec}, options?: {
|
|
3
|
+
finish?(sel: string): string
|
|
4
|
+
})
|
|
5
|
+
getRules(): string
|
|
6
|
+
static mount(
|
|
7
|
+
root: Document | ShadowRoot | DocumentOrShadowRoot,
|
|
8
|
+
module: StyleModule | ReadonlyArray<StyleModule>,
|
|
9
|
+
options?: {nonce?: string}
|
|
10
|
+
): void
|
|
11
|
+
static newName(): string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type StyleSpec = {
|
|
15
|
+
[propOrSelector: string]: string | number | StyleSpec | null
|
|
16
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
const C = "\u037c"
|
|
2
|
+
const COUNT = typeof Symbol == "undefined" ? "__" + C : Symbol.for(C)
|
|
3
|
+
const SET = typeof Symbol == "undefined" ? "__styleSet" + Math.floor(Math.random() * 1e8) : Symbol("styleSet")
|
|
4
|
+
const top = typeof globalThis != "undefined" ? globalThis : typeof window != "undefined" ? window : {}
|
|
5
|
+
|
|
6
|
+
// :: - Style modules encapsulate a set of CSS rules defined from
|
|
7
|
+
// JavaScript. Their definitions are only available in a given DOM
|
|
8
|
+
// root after it has been _mounted_ there with `StyleModule.mount`.
|
|
9
|
+
//
|
|
10
|
+
// Style modules should be created once and stored somewhere, as
|
|
11
|
+
// opposed to re-creating them every time you need them. The amount of
|
|
12
|
+
// CSS rules generated for a given DOM root is bounded by the amount
|
|
13
|
+
// of style modules that were used. So to avoid leaking rules, don't
|
|
14
|
+
// create these dynamically, but treat them as one-time allocations.
|
|
15
|
+
export class StyleModule {
|
|
16
|
+
// :: (Object<Style>, ?{finish: ?(string) → string})
|
|
17
|
+
// Create a style module from the given spec.
|
|
18
|
+
//
|
|
19
|
+
// When `finish` is given, it is called on regular (non-`@`)
|
|
20
|
+
// selectors (after `&` expansion) to compute the final selector.
|
|
21
|
+
constructor(spec, options) {
|
|
22
|
+
this.rules = []
|
|
23
|
+
let {finish} = options || {}
|
|
24
|
+
|
|
25
|
+
function splitSelector(selector) {
|
|
26
|
+
return /^@/.test(selector) ? [selector] : selector.split(/,\s*/)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function render(selectors, spec, target, isKeyframes) {
|
|
30
|
+
let local = [], isAt = /^@(\w+)\b/.exec(selectors[0]), keyframes = isAt && isAt[1] == "keyframes"
|
|
31
|
+
if (isAt && spec == null) return target.push(selectors[0] + ";")
|
|
32
|
+
for (let prop in spec) {
|
|
33
|
+
let value = spec[prop]
|
|
34
|
+
if (/&/.test(prop)) {
|
|
35
|
+
render(prop.split(/,\s*/).map(part => selectors.map(sel => part.replace(/&/, sel))).reduce((a, b) => a.concat(b)),
|
|
36
|
+
value, target)
|
|
37
|
+
} else if (value && typeof value == "object") {
|
|
38
|
+
if (!isAt) throw new RangeError("The value of a property (" + prop + ") should be a primitive value.")
|
|
39
|
+
render(splitSelector(prop), value, local, keyframes)
|
|
40
|
+
} else if (value != null) {
|
|
41
|
+
local.push(prop.replace(/_.*/, "").replace(/[A-Z]/g, l => "-" + l.toLowerCase()) + ": " + value + ";")
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (local.length || keyframes) {
|
|
45
|
+
target.push((finish && !isAt && !isKeyframes ? selectors.map(finish) : selectors).join(", ") +
|
|
46
|
+
" {" + local.join(" ") + "}")
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
for (let prop in spec) render(splitSelector(prop), spec[prop], this.rules)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// :: () → string
|
|
54
|
+
// Returns a string containing the module's CSS rules.
|
|
55
|
+
getRules() { return this.rules.join("\n") }
|
|
56
|
+
|
|
57
|
+
// :: () → string
|
|
58
|
+
// Generate a new unique CSS class name.
|
|
59
|
+
static newName() {
|
|
60
|
+
let id = top[COUNT] || 1
|
|
61
|
+
top[COUNT] = id + 1
|
|
62
|
+
return C + id.toString(36)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// :: (union<Document, ShadowRoot>, union<[StyleModule], StyleModule>, ?{nonce: ?string})
|
|
66
|
+
//
|
|
67
|
+
// Mount the given set of modules in the given DOM root, which ensures
|
|
68
|
+
// that the CSS rules defined by the module are available in that
|
|
69
|
+
// context.
|
|
70
|
+
//
|
|
71
|
+
// Rules are only added to the document once per root.
|
|
72
|
+
//
|
|
73
|
+
// Rule order will follow the order of the modules, so that rules from
|
|
74
|
+
// modules later in the array take precedence of those from earlier
|
|
75
|
+
// modules. If you call this function multiple times for the same root
|
|
76
|
+
// in a way that changes the order of already mounted modules, the old
|
|
77
|
+
// order will be changed.
|
|
78
|
+
//
|
|
79
|
+
// If a Content Security Policy nonce is provided, it is added to
|
|
80
|
+
// the `<style>` tag generated by the library.
|
|
81
|
+
static mount(root, modules, options) {
|
|
82
|
+
let set = root[SET], nonce = options && options.nonce
|
|
83
|
+
if (!set) set = new StyleSet(root, nonce)
|
|
84
|
+
else if (nonce) set.setNonce(nonce)
|
|
85
|
+
set.mount(Array.isArray(modules) ? modules : [modules], root)
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
let adoptedSet = new Map //<Document, StyleSet>
|
|
90
|
+
|
|
91
|
+
class StyleSet {
|
|
92
|
+
constructor(root, nonce) {
|
|
93
|
+
let doc = root.ownerDocument || root, win = doc.defaultView
|
|
94
|
+
if (!root.head && root.adoptedStyleSheets && win.CSSStyleSheet) {
|
|
95
|
+
let adopted = adoptedSet.get(doc)
|
|
96
|
+
if (adopted) return root[SET] = adopted
|
|
97
|
+
this.sheet = new win.CSSStyleSheet
|
|
98
|
+
adoptedSet.set(doc, this)
|
|
99
|
+
} else {
|
|
100
|
+
this.styleTag = doc.createElement("style")
|
|
101
|
+
if (nonce) this.styleTag.setAttribute("nonce", nonce)
|
|
102
|
+
}
|
|
103
|
+
this.modules = []
|
|
104
|
+
root[SET] = this
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
mount(modules, root) {
|
|
108
|
+
let sheet = this.sheet
|
|
109
|
+
let pos = 0 /* Current rule offset */, j = 0 /* Index into this.modules */
|
|
110
|
+
for (let i = 0; i < modules.length; i++) {
|
|
111
|
+
let mod = modules[i], index = this.modules.indexOf(mod)
|
|
112
|
+
if (index < j && index > -1) { // Ordering conflict
|
|
113
|
+
this.modules.splice(index, 1)
|
|
114
|
+
j--
|
|
115
|
+
index = -1
|
|
116
|
+
}
|
|
117
|
+
if (index == -1) {
|
|
118
|
+
this.modules.splice(j++, 0, mod)
|
|
119
|
+
if (sheet) for (let k = 0; k < mod.rules.length; k++)
|
|
120
|
+
sheet.insertRule(mod.rules[k], pos++)
|
|
121
|
+
} else {
|
|
122
|
+
while (j < index) pos += this.modules[j++].rules.length
|
|
123
|
+
pos += mod.rules.length
|
|
124
|
+
j++
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (sheet) {
|
|
129
|
+
if (root.adoptedStyleSheets.indexOf(this.sheet) < 0)
|
|
130
|
+
root.adoptedStyleSheets = [this.sheet, ...root.adoptedStyleSheets]
|
|
131
|
+
} else {
|
|
132
|
+
let text = ""
|
|
133
|
+
for (let i = 0; i < this.modules.length; i++)
|
|
134
|
+
text += this.modules[i].getRules() + "\n"
|
|
135
|
+
this.styleTag.textContent = text
|
|
136
|
+
let target = root.head || root
|
|
137
|
+
if (this.styleTag.parentNode != target)
|
|
138
|
+
target.insertBefore(this.styleTag, target.firstChild)
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
setNonce(nonce) {
|
|
143
|
+
if (this.styleTag && this.styleTag.getAttribute("nonce") != nonce)
|
|
144
|
+
this.styleTag.setAttribute("nonce", nonce)
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// Style::Object<union<Style,string>>
|
|
149
|
+
//
|
|
150
|
+
// A style is an object that, in the simple case, maps CSS property
|
|
151
|
+
// names to strings holding their values, as in `{color: "red",
|
|
152
|
+
// fontWeight: "bold"}`. The property names can be given in
|
|
153
|
+
// camel-case—the library will insert a dash before capital letters
|
|
154
|
+
// when converting them to CSS.
|
|
155
|
+
//
|
|
156
|
+
// If you include an underscore in a property name, it and everything
|
|
157
|
+
// after it will be removed from the output, which can be useful when
|
|
158
|
+
// providing a property multiple times, for browser compatibility
|
|
159
|
+
// reasons.
|
|
160
|
+
//
|
|
161
|
+
// A property in a style object can also be a sub-selector, which
|
|
162
|
+
// extends the current context to add a pseudo-selector or a child
|
|
163
|
+
// selector. Such a property should contain a `&` character, which
|
|
164
|
+
// will be replaced by the current selector. For example `{"&:before":
|
|
165
|
+
// {content: '"hi"'}}`. Sub-selectors and regular properties can
|
|
166
|
+
// freely be mixed in a given object. Any property containing a `&` is
|
|
167
|
+
// assumed to be a sub-selector.
|
|
168
|
+
//
|
|
169
|
+
// Finally, a property can specify an @-block to be wrapped around the
|
|
170
|
+
// styles defined inside the object that's the property's value. For
|
|
171
|
+
// example to create a media query you can do `{"@media screen and
|
|
172
|
+
// (min-width: 400px)": {...}}`.
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import {StyleModule} from "style-mod"
|
|
2
|
+
import ist from "ist"
|
|
3
|
+
|
|
4
|
+
describe("StyleModule", () => {
|
|
5
|
+
it("renders objects to CSS text", () => {
|
|
6
|
+
ist(rules(new StyleModule({main: {color: "red", border: "1px solid green"}})),
|
|
7
|
+
["main {color: red; border: 1px solid green;}"], eqRules)
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
it("handles multiple rules", () => {
|
|
11
|
+
ist(rules(new StyleModule({
|
|
12
|
+
one: {color: "green"},
|
|
13
|
+
two: {color: "blue"}
|
|
14
|
+
})), [
|
|
15
|
+
"one {color: green;}",
|
|
16
|
+
"two {color: blue;}"
|
|
17
|
+
], eqRules)
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
it("supports &-nesting", () => {
|
|
21
|
+
ist(rules(new StyleModule({
|
|
22
|
+
main: {
|
|
23
|
+
color: "yellow",
|
|
24
|
+
"&:hover": {fontWeight: "bold"}
|
|
25
|
+
}
|
|
26
|
+
})), [
|
|
27
|
+
"main:hover {font-weight: bold;}",
|
|
28
|
+
"main {color: yellow;}"
|
|
29
|
+
], eqRules)
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
it("can replace multiple & markers", () => {
|
|
33
|
+
ist(rules(new StyleModule({
|
|
34
|
+
main: {
|
|
35
|
+
"p &, div &": {color: "blue"}
|
|
36
|
+
}
|
|
37
|
+
})), [
|
|
38
|
+
"p main, div main {color: blue;}"
|
|
39
|
+
], eqRules)
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
it("supports media queries", () => {
|
|
43
|
+
ist(rules(new StyleModule({
|
|
44
|
+
"@media screen and (min-width: 400px)": {
|
|
45
|
+
main: {
|
|
46
|
+
fontFamily: '"URW Bookman"',
|
|
47
|
+
MozBoxSizing: "border-box"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
})), ["@media screen and (min-width: 400px) {main {font-family: \"URW Bookman\"; -moz-box-sizing: border-box;}}"], eqRules)
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
it("can render keyframes", () => {
|
|
54
|
+
ist(rules(new StyleModule({
|
|
55
|
+
"@keyframes foo": {
|
|
56
|
+
"0%": {color: "blue"},
|
|
57
|
+
"50%": {color: "red"}
|
|
58
|
+
}
|
|
59
|
+
})), ["@keyframes foo {0% {color: blue;} 50% {color: red;}}"], eqRules)
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
it("doesn't mangle keyframe names", () => {
|
|
63
|
+
ist(rules(new StyleModule({
|
|
64
|
+
"@keyframes foo": {
|
|
65
|
+
"0%": {color: "blue"},
|
|
66
|
+
"50%": {color: "red"}
|
|
67
|
+
}
|
|
68
|
+
}, {finish: s => ".foo " + s})), ["@keyframes foo {0% {color: blue;} 50% {color: red;}}"], eqRules)
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
it("can render multiple instances of a property", () => {
|
|
72
|
+
ist(rules(new StyleModule({
|
|
73
|
+
main: {
|
|
74
|
+
color: "rgba(100, 100, 100, .5)",
|
|
75
|
+
color_2: "grey"
|
|
76
|
+
}
|
|
77
|
+
})), ["main {color: rgba(100, 100, 100, .5); color: grey;}"], eqRules)
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
it("can expand multiple selectors at once", () => {
|
|
81
|
+
ist(rules(new StyleModule({
|
|
82
|
+
"one, two": {
|
|
83
|
+
"&.x": {
|
|
84
|
+
color: "yellow"
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
})), ["one.x, two.x {color: yellow;}"], eqRules)
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
it("allows processing of selectors", () => {
|
|
91
|
+
ist(rules(new StyleModule({
|
|
92
|
+
"abc, cba": {color: "yellow"},
|
|
93
|
+
"@media stuff": {abc: {fontWeight: "bold"}}
|
|
94
|
+
}, {
|
|
95
|
+
finish: x => x.replace(/a/g, "u")
|
|
96
|
+
})), ["ubc, cbu {color: yellow;}", "@media stuff {ubc {font-weight: bold;}}"], eqRules)
|
|
97
|
+
})
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
function rules(module) { return module.rules }
|
|
101
|
+
|
|
102
|
+
function eqRules(a, b) {
|
|
103
|
+
return JSON.stringify(a) == JSON.stringify(b)
|
|
104
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
39679
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (C) 2016 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,18 @@
|
|
|
1
|
+
# W3C keyname
|
|
2
|
+
|
|
3
|
+
Tiny library that exports a function `keyName` that takes a keyboard event and
|
|
4
|
+
returns a
|
|
5
|
+
[`KeyboardEvent.key`](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key)-style
|
|
6
|
+
string. Will use the actual `key` property of the event if available,
|
|
7
|
+
and fall back to a value synthesized from the `keyCode` otherwise.
|
|
8
|
+
|
|
9
|
+
Probably often wrong on non-US keyboards, since the correspondence
|
|
10
|
+
between a key code and the character it produces when shift is held is
|
|
11
|
+
predicted based on a hard-coded table. Meant as a fallback for
|
|
12
|
+
`KeyboardEvent.key`, not a replacement.
|
|
13
|
+
|
|
14
|
+
The lookup tables from key codes (`event.keyCode`) to names are
|
|
15
|
+
exported as `base` (when Shift isn't held) and `shift` (when Shift is
|
|
16
|
+
held).
|
|
17
|
+
|
|
18
|
+
License: MIT
|