Skip to content

Commit 5c11574

Browse files
committed
feat(get): local get function w/o lodash dependency
1 parent 86547f9 commit 5c11574

File tree

4 files changed

+86
-69
lines changed

4 files changed

+86
-69
lines changed

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@
5454
"dependencies": {
5555
"@nuxt/kit": "^3.0.0-rc.6",
5656
"browser-style-dictionary": "^3.1.1-browser.1",
57-
"@types/lodash.get": "^4.4.7",
5857
"chroma-js": "^2.4.2",
59-
"lodash.get": "^4.4.2",
6058
"untyped": "^0.4.4"
6159
},
6260
"devDependencies": {

playground/theme/tokens.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { defineTokens, palette } from '../../src'
22

3-
const primary = palette('gray')
3+
const primary = palette('blue')
44

55
export default defineTokens({
66
colors: {

src/formats.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ const DesignTokensType =
2323
[key: string]: DesignTokens | DesignToken;
2424
}`
2525

26+
const getFunction =
27+
`const get = (obj, path, def) => (() => typeof path === 'string' ? path.replace(/\\[(\\d+)]/g,'.$1') : path.join('.'))()
28+
.split('.')
29+
.filter(Boolean)
30+
.every(step => ((obj = obj[step]) !== undefined)) ? obj : def`
31+
2632
export const treeWalker = (obj, typing: boolean = true) => {
2733
let type = Object.create(null)
2834

@@ -104,12 +110,12 @@ export const tsTypesDeclaration = ({ tokens }) => {
104110
}
105111

106112
export const tsFull = ({ tokens }) => {
107-
let result = 'import get from \'lodash.get\'\n\n'
108-
109-
result = result + 'import type { NuxtDesignTokens, DesignTokensPaths, DesignToken } from \'./types.d\'\n\n'
113+
let result = 'import type { NuxtDesignTokens, DesignTokensPaths, DesignToken } from \'./types.d\'\n\n'
110114

111115
result = result + 'export * from \'./types.d\'\n\n'
112116

117+
result = result + `${getFunction}\n\n`
118+
113119
result = result + `export const designTokens: NuxtDesignTokens = ${JSON.stringify(treeWalker(tokens, false), null, 2)}\n`
114120

115121
result = result + `\n
@@ -149,7 +155,7 @@ export const $tokens = (path: DesignTokensPaths, key: keyof DesignToken = 'varia
149155
}
150156

151157
export const jsFull = ({ tokens }) => {
152-
let result = 'import get from \'lodash.get\'\n\n'
158+
let result = `${getFunction}\n\n`
153159

154160
result = result + `export const designTokens = ${JSON.stringify(treeWalker(tokens, false), null, 2)}\n`
155161

yarn.lock

Lines changed: 75 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -432,26 +432,27 @@
432432
fastq "^1.6.0"
433433

434434
"@nuxt-themes/config@npm:@nuxt-themes/config-edge@latest":
435-
version "0.0.1-27630309.7d5539b"
436-
resolved "https://registry.yarnpkg.com/@nuxt-themes/config-edge/-/config-edge-0.0.1-27630309.7d5539b.tgz#4d266123de4737d3b124074e609e949ed916f83b"
437-
integrity sha512-RL55SS8n0iMaYIFkHxpzK4Z0GM5ml58qOPFepspxXkoGe8Bx7R5o6XY48JfUAG5KnGlOnWFwl6zy/0LRdQGCjA==
435+
version "0.0.1-27636489.e304dd2"
436+
resolved "https://registry.yarnpkg.com/@nuxt-themes/config-edge/-/config-edge-0.0.1-27636489.e304dd2.tgz#fa45a267b071d6a591774e331d691a51ec1b9fd1"
437+
integrity sha512-jKPPmsLG9+nciLHRhJMvac0x0MItyGydI80w2txnD4kGo3sq7fi6l0Iv4rT2siFXGquypxynkamyUWsKc0R5Gg==
438438
dependencies:
439-
"@nuxt/kit" "^3.0.0-rc.5"
439+
"@nuxt/kit" "^3.0.0-rc.6"
440440
"@types/lodash.get" "^4.4.7"
441441
lodash.get "^4.4.2"
442442
untyped "^0.4.4"
443443

444444
"@nuxt-themes/docus@npm:@nuxt-themes/docus-edge@latest":
445-
version "3.0.0-8057363"
446-
resolved "https://registry.yarnpkg.com/@nuxt-themes/docus-edge/-/docus-edge-3.0.0-8057363.tgz#971bc96904491e49f17578e69d5169bfc39f5d69"
447-
integrity sha512-MJfDszy31C/i9TbpVlp90an3sfmeQGhBtc8q6Uc/N/XsexURYcialP+D4Tk0GaWbw5fJNmNVIoTGiSA2o0zoBw==
445+
version "3.0.0-79d58da"
446+
resolved "https://registry.yarnpkg.com/@nuxt-themes/docus-edge/-/docus-edge-3.0.0-79d58da.tgz#2523ddce63ca1641449503f20d01329b564d9fee"
447+
integrity sha512-750liRrFclXSE8rSLtmKTq5aOJ+taOQPTrepSxyjdXNCH6Yx2Joy5/vcMHrFHXdWbRC+lPxoW1neo04MJ6hUbQ==
448448
dependencies:
449449
"@iconify/vue" "^3.2.1"
450450
"@nuxt-themes/config" "npm:@nuxt-themes/config-edge@latest"
451451
"@nuxt/content" "npm:@nuxt/content-edge@latest"
452452
"@nuxt/kit" "^3.0.0-rc.5"
453453
"@nuxthq/studio" "npm:@nuxthq/studio-edge@latest"
454454
"@nuxtjs/color-mode" "^3.1.4"
455+
"@nuxtjs/design-tokens" "npm:@nuxtjs/design-tokens-edge@latest"
455456
"@nuxtjs/tailwindcss" "npm:@nuxtjs/tailwindcss-edge@latest"
456457
"@tailwindcss/aspect-ratio" "^0.4.0"
457458
"@tailwindcss/forms" "^0.5.2"
@@ -724,11 +725,11 @@
724725
vite-plugin-checker "^0.4.9"
725726

726727
"@nuxthq/studio@npm:@nuxthq/studio-edge@latest":
727-
version "0.0.1-27629141.aeb359e"
728-
resolved "https://registry.yarnpkg.com/@nuxthq/studio-edge/-/studio-edge-0.0.1-27629141.aeb359e.tgz#6b3bb6595f7a5f1c8186ac2dcd233f5fbe17034a"
729-
integrity sha512-M+bLlm0ntQ7ptIOQIF5KIodG7gXDNvbGBEusNyCytglF1GuQH/GRXl/xwbkEJdxz/OVL3wGm2C743kmJweVszw==
728+
version "0.0.1-27636100.3aa3771"
729+
resolved "https://registry.yarnpkg.com/@nuxthq/studio-edge/-/studio-edge-0.0.1-27636100.3aa3771.tgz#6eeec5ec615857b8d7385cbd2ddf325a5e8c6c7b"
730+
integrity sha512-ByHJbSnBRrCoikak2Y6FVkVqzBU4kfftTHhoCI4fLcR5Pn2gdwqaUOkugr/0hVLgnvgZKbKPuvrEz+VG42ZOsA==
730731
dependencies:
731-
"@nuxt/kit" "^3.0.0-rc.5"
732+
"@nuxt/kit" "^3.0.0-rc.6"
732733
nuxt-component-meta "^0.1.5"
733734
socket.io-client "^4.5.1"
734735
unstorage "^0.4.1"
@@ -742,6 +743,18 @@
742743
lodash.template "^4.5.0"
743744
pathe "^0.3.0"
744745

746+
"@nuxtjs/design-tokens@npm:@nuxtjs/design-tokens-edge@latest":
747+
version "0.0.1-27636462.86547f9"
748+
resolved "https://registry.yarnpkg.com/@nuxtjs/design-tokens-edge/-/design-tokens-edge-0.0.1-27636462.86547f9.tgz#2250946f6834bcb33f1702b5de3583918d0c17aa"
749+
integrity sha512-XLvj6H7+mwPj842+c8pfvanABVqdtNUguTyCjRpwpeeddvZFSOeTh/aW7uMsnjHNQQ8p8jFhkknrH/mNnVNlJQ==
750+
dependencies:
751+
"@nuxt/kit" "^3.0.0-rc.6"
752+
"@types/lodash.get" "^4.4.7"
753+
browser-style-dictionary "^3.1.1-browser.1"
754+
chroma-js "^2.4.2"
755+
lodash.get "^4.4.2"
756+
untyped "^0.4.4"
757+
745758
"@nuxtjs/eslint-config-typescript@latest":
746759
version "10.0.0"
747760
resolved "https://registry.yarnpkg.com/@nuxtjs/eslint-config-typescript/-/eslint-config-typescript-10.0.0.tgz#08eab1c450b34d4da88b81ede81b549318e4b2d6"
@@ -1060,13 +1073,13 @@
10601073
integrity sha512-5d2RhCard1nQUC3aHcq/gHzWYO6K0WJmAbjO7mQJgCQKtZpgXxv1rOM6O/dBDhDYYVutk1sciOgNSe+5YyfM8A==
10611074

10621075
"@typescript-eslint/eslint-plugin@^5.21.0":
1063-
version "5.30.6"
1064-
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.30.6.tgz#9c6017b6c1d04894141b4a87816388967f64c359"
1065-
integrity sha512-J4zYMIhgrx4MgnZrSDD7sEnQp7FmhKNOaqaOpaoQ/SfdMfRB/0yvK74hTnvH+VQxndZynqs5/Hn4t+2/j9bADg==
1076+
version "5.30.7"
1077+
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.30.7.tgz#1621dabc1ae4084310e19e9efc80dfdbb97e7493"
1078+
integrity sha512-l4L6Do+tfeM2OK0GJsU7TUcM/1oN/N25xHm3Jb4z3OiDU4Lj8dIuxX9LpVMS9riSXQs42D1ieX7b85/r16H9Fw==
10661079
dependencies:
1067-
"@typescript-eslint/scope-manager" "5.30.6"
1068-
"@typescript-eslint/type-utils" "5.30.6"
1069-
"@typescript-eslint/utils" "5.30.6"
1080+
"@typescript-eslint/scope-manager" "5.30.7"
1081+
"@typescript-eslint/type-utils" "5.30.7"
1082+
"@typescript-eslint/utils" "5.30.7"
10701083
debug "^4.3.4"
10711084
functional-red-black-tree "^1.0.1"
10721085
ignore "^5.2.0"
@@ -1075,68 +1088,68 @@
10751088
tsutils "^3.21.0"
10761089

10771090
"@typescript-eslint/parser@^5.21.0":
1078-
version "5.30.6"
1079-
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.30.6.tgz#add440db038fa9d777e4ebdaf66da9e7fb7abe92"
1080-
integrity sha512-gfF9lZjT0p2ZSdxO70Xbw8w9sPPJGfAdjK7WikEjB3fcUI/yr9maUVEdqigBjKincUYNKOmf7QBMiTf719kbrA==
1091+
version "5.30.7"
1092+
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.30.7.tgz#99d09729392aec9e64b1de45cd63cb81a4ddd980"
1093+
integrity sha512-Rg5xwznHWWSy7v2o0cdho6n+xLhK2gntImp0rJroVVFkcYFYQ8C8UJTSuTw/3CnExBmPjycjmUJkxVmjXsld6A==
10811094
dependencies:
1082-
"@typescript-eslint/scope-manager" "5.30.6"
1083-
"@typescript-eslint/types" "5.30.6"
1084-
"@typescript-eslint/typescript-estree" "5.30.6"
1095+
"@typescript-eslint/scope-manager" "5.30.7"
1096+
"@typescript-eslint/types" "5.30.7"
1097+
"@typescript-eslint/typescript-estree" "5.30.7"
10851098
debug "^4.3.4"
10861099

1087-
"@typescript-eslint/[email protected].6":
1088-
version "5.30.6"
1089-
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.30.6.tgz#ce1b49ff5ce47f55518d63dbe8fc9181ddbd1a33"
1090-
integrity sha512-Hkq5PhLgtVoW1obkqYH0i4iELctEKixkhWLPTYs55doGUKCASvkjOXOd/pisVeLdO24ZX9D6yymJ/twqpJiG3g==
1100+
"@typescript-eslint/[email protected].7":
1101+
version "5.30.7"
1102+
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.30.7.tgz#8269a931ef1e5ae68b5eb80743cc515c4ffe3dd7"
1103+
integrity sha512-7BM1bwvdF1UUvt+b9smhqdc/eniOnCKxQT/kj3oXtj3LqnTWCAM0qHRHfyzCzhEfWX0zrW7KqXXeE4DlchZBKw==
10911104
dependencies:
1092-
"@typescript-eslint/types" "5.30.6"
1093-
"@typescript-eslint/visitor-keys" "5.30.6"
1105+
"@typescript-eslint/types" "5.30.7"
1106+
"@typescript-eslint/visitor-keys" "5.30.7"
10941107

1095-
"@typescript-eslint/[email protected].6":
1096-
version "5.30.6"
1097-
resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.30.6.tgz#a64aa9acbe609ab77f09f53434a6af2b9685f3af"
1098-
integrity sha512-GFVVzs2j0QPpM+NTDMXtNmJKlF842lkZKDSanIxf+ArJsGeZUIaeT4jGg+gAgHt7AcQSFwW7htzF/rbAh2jaVA==
1108+
"@typescript-eslint/[email protected].7":
1109+
version "5.30.7"
1110+
resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.30.7.tgz#5693dc3db6f313f302764282d614cfdbc8a9fcfd"
1111+
integrity sha512-nD5qAE2aJX/YLyKMvOU5jvJyku4QN5XBVsoTynFrjQZaDgDV6i7QHFiYCx10wvn7hFvfuqIRNBtsgaLe0DbWhw==
10991112
dependencies:
1100-
"@typescript-eslint/utils" "5.30.6"
1113+
"@typescript-eslint/utils" "5.30.7"
11011114
debug "^4.3.4"
11021115
tsutils "^3.21.0"
11031116

1104-
"@typescript-eslint/[email protected].6":
1105-
version "5.30.6"
1106-
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.30.6.tgz#86369d0a7af8c67024115ac1da3e8fb2d38907e1"
1107-
integrity sha512-HdnP8HioL1F7CwVmT4RaaMX57RrfqsOMclZc08wGMiDYJBsLGBM7JwXM4cZJmbWLzIR/pXg1kkrBBVpxTOwfUg==
1117+
"@typescript-eslint/[email protected].7":
1118+
version "5.30.7"
1119+
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.30.7.tgz#18331487cc92d0f1fb1a6f580c8ec832528079d0"
1120+
integrity sha512-ocVkETUs82+U+HowkovV6uxf1AnVRKCmDRNUBUUo46/5SQv1owC/EBFkiu4MOHeZqhKz2ktZ3kvJJ1uFqQ8QPg==
11081121

1109-
"@typescript-eslint/[email protected].6":
1110-
version "5.30.6"
1111-
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.30.6.tgz#a84a0d6a486f9b54042da1de3d671a2c9f14484e"
1112-
integrity sha512-Z7TgPoeYUm06smfEfYF0RBkpF8csMyVnqQbLYiGgmUSTaSXTP57bt8f0UFXstbGxKIreTwQCujtaH0LY9w9B+A==
1122+
"@typescript-eslint/[email protected].7":
1123+
version "5.30.7"
1124+
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.30.7.tgz#05da9f1b281985bfedcf62349847f8d168eecc07"
1125+
integrity sha512-tNslqXI1ZdmXXrHER83TJ8OTYl4epUzJC0aj2i4DMDT4iU+UqLT3EJeGQvJ17BMbm31x5scSwo3hPM0nqQ1AEA==
11131126
dependencies:
1114-
"@typescript-eslint/types" "5.30.6"
1115-
"@typescript-eslint/visitor-keys" "5.30.6"
1127+
"@typescript-eslint/types" "5.30.7"
1128+
"@typescript-eslint/visitor-keys" "5.30.7"
11161129
debug "^4.3.4"
11171130
globby "^11.1.0"
11181131
is-glob "^4.0.3"
11191132
semver "^7.3.7"
11201133
tsutils "^3.21.0"
11211134

1122-
"@typescript-eslint/[email protected].6":
1123-
version "5.30.6"
1124-
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.30.6.tgz#1de2da14f678e7d187daa6f2e4cdb558ed0609dc"
1125-
integrity sha512-xFBLc/esUbLOJLk9jKv0E9gD/OH966M40aY9jJ8GiqpSkP2xOV908cokJqqhVd85WoIvHVHYXxSFE4cCSDzVvA==
1135+
"@typescript-eslint/[email protected].7":
1136+
version "5.30.7"
1137+
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.30.7.tgz#7135be070349e9f7caa262b0ca59dc96123351bb"
1138+
integrity sha512-Z3pHdbFw+ftZiGUnm1GZhkJgVqsDL5CYW2yj+TB2mfXDFOMqtbzQi2dNJIyPqPbx9mv2kUxS1gU+r2gKlKi1rQ==
11261139
dependencies:
11271140
"@types/json-schema" "^7.0.9"
1128-
"@typescript-eslint/scope-manager" "5.30.6"
1129-
"@typescript-eslint/types" "5.30.6"
1130-
"@typescript-eslint/typescript-estree" "5.30.6"
1141+
"@typescript-eslint/scope-manager" "5.30.7"
1142+
"@typescript-eslint/types" "5.30.7"
1143+
"@typescript-eslint/typescript-estree" "5.30.7"
11311144
eslint-scope "^5.1.1"
11321145
eslint-utils "^3.0.0"
11331146

1134-
"@typescript-eslint/[email protected].6":
1135-
version "5.30.6"
1136-
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.30.6.tgz#94dd10bb481c8083378d24de1742a14b38a2678c"
1137-
integrity sha512-41OiCjdL2mCaSDi2SvYbzFLlqqlm5v1ZW9Ym55wXKL/Rx6OOB1IbuFGo71Fj6Xy90gJDFTlgOS+vbmtGHPTQQA==
1147+
"@typescript-eslint/[email protected].7":
1148+
version "5.30.7"
1149+
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.30.7.tgz#c093abae75b4fd822bfbad9fc337f38a7a14909a"
1150+
integrity sha512-KrRXf8nnjvcpxDFOKej4xkD7657+PClJs5cJVSG7NNoCNnjEdc46juNAQt7AyuWctuCgs6mVRc1xGctEqrjxWw==
11381151
dependencies:
1139-
"@typescript-eslint/types" "5.30.6"
1152+
"@typescript-eslint/types" "5.30.7"
11401153
eslint-visitor-keys "^3.3.0"
11411154

11421155
"@vercel/nft@^0.20.1":
@@ -2587,9 +2600,9 @@ [email protected]:
25872600
integrity sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==
25882601

25892602
electron-to-chromium@^1.4.188:
2590-
version "1.4.192"
2591-
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.192.tgz#fac050058b3e0713b401a1088cc579e14c2ab165"
2592-
integrity sha512-8nCXyIQY9An88NXAp+PuPy5h3/w5ZY7Iu2lag65Q0XREprcat5F8gKhoHsBUnQcFuCRnmevpR8yEBYRU3d2HDw==
2603+
version "1.4.194"
2604+
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.194.tgz#2f83fcec5067907044a3d502ac7c3efb1fe6430b"
2605+
integrity sha512-ola5UH0xAP1oYY0FFUsPvwtucEzCQHucXnT7PQ1zjHJMccZhCDktEugI++JUR3YuIs7Ff7afz+OVEhVAIMhLAQ==
25932606

25942607
emoji-regex@^8.0.0:
25952608
version "8.0.0"
@@ -7843,9 +7856,9 @@ untyped@^0.4.4:
78437856
scule "^0.2.1"
78447857

78457858
update-browserslist-db@^1.0.4:
7846-
version "1.0.4"
7847-
resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.0.4.tgz#dbfc5a789caa26b1db8990796c2c8ebbce304824"
7848-
integrity sha512-jnmO2BEGUjsMOe/Fg9u0oczOe/ppIDZPebzccl1yDWGLFP16Pa1/RM5wEoKYPG2zstNcDuAStejyxsOuKINdGA==
7859+
version "1.0.5"
7860+
resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.0.5.tgz#be06a5eedd62f107b7c19eb5bcefb194411abf38"
7861+
integrity sha512-dteFFpCyvuDdr9S/ff1ISkKt/9YZxKjI9WlRR99c180GaztJtRa/fn18FdxGVKVsnPY7/a/FDN68mcvUmP4U7Q==
78497862
dependencies:
78507863
escalade "^3.1.1"
78517864
picocolors "^1.0.0"

0 commit comments

Comments
 (0)