@iota-uz/sdk 0.4.20 → 0.4.22

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.
Files changed (40) hide show
  1. package/README.md +20 -0
  2. package/dist/applet/core.cjs +8 -4
  3. package/dist/applet/core.cjs.map +1 -1
  4. package/dist/applet/core.mjs +8 -4
  5. package/dist/applet/core.mjs.map +1 -1
  6. package/dist/applet/devtools.cjs +24 -8
  7. package/dist/applet/devtools.cjs.map +1 -1
  8. package/dist/applet/devtools.mjs +24 -8
  9. package/dist/applet/devtools.mjs.map +1 -1
  10. package/dist/applet/host.cjs +47 -16
  11. package/dist/applet/host.cjs.map +1 -1
  12. package/dist/applet/host.mjs +47 -16
  13. package/dist/applet/host.mjs.map +1 -1
  14. package/dist/applet/vite.cjs +12 -4
  15. package/dist/applet/vite.cjs.map +1 -1
  16. package/dist/applet/vite.mjs +12 -4
  17. package/dist/applet/vite.mjs.map +1 -1
  18. package/dist/applet-runtime/index.cjs.map +1 -1
  19. package/dist/applet-runtime/index.mjs.map +1 -1
  20. package/dist/bichat/index.cjs +6971 -2646
  21. package/dist/bichat/index.cjs.map +1 -1
  22. package/dist/bichat/index.css +11 -1
  23. package/dist/bichat/index.css.map +1 -1
  24. package/dist/bichat/index.d.cts +453 -157
  25. package/dist/bichat/index.d.ts +453 -157
  26. package/dist/bichat/index.mjs +6969 -2652
  27. package/dist/bichat/index.mjs.map +1 -1
  28. package/dist/bichat/styles.css +17 -4
  29. package/dist/bichat/tailwind.cjs.map +1 -1
  30. package/dist/bichat/tailwind.mjs.map +1 -1
  31. package/dist/index.cjs +73 -26
  32. package/dist/index.cjs.map +1 -1
  33. package/dist/index.mjs +73 -26
  34. package/dist/index.mjs.map +1 -1
  35. package/package.json +10 -3
  36. package/tailwind/compiled.css +1 -1
  37. package/tailwind/create-config.cjs +50 -2
  38. package/tailwind/iota.css +6 -6
  39. package/tailwind/sdk-content.cjs +177 -0
  40. package/tailwind/sdk-theme.cjs +12 -0
@@ -1,4 +1,8 @@
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+
1
4
  const sdkTheme = require("./sdk-theme.cjs");
5
+ const { resolveIotaSdkTailwindContent } = require("./sdk-content.cjs");
2
6
 
3
7
  function isPlainObject(value) {
4
8
  return (
@@ -21,17 +25,61 @@ function mergeDeep(base, extra) {
21
25
  return out;
22
26
  }
23
27
 
28
+ function uniqueStrings(values) {
29
+ return Array.from(new Set(values.filter(Boolean)));
30
+ }
31
+
32
+ function normalizeStringArray(value) {
33
+ if (Array.isArray(value)) {
34
+ return value.filter((item) => typeof item === "string" && item.trim() !== "");
35
+ }
36
+ if (typeof value === "string" && value.trim() !== "") {
37
+ return [value];
38
+ }
39
+ return [];
40
+ }
41
+
42
+ function shouldIncludeSdkTemplates(includeSdkTemplates, rootDir) {
43
+ if (typeof includeSdkTemplates === "boolean") {
44
+ return includeSdkTemplates;
45
+ }
46
+ return fs.existsSync(path.join(rootDir, "go.mod"));
47
+ }
48
+
24
49
  /**
25
50
  * Creates a Tailwind config that extends the SDK theme (design tokens from iota.css).
26
- * @param { { content?: string[], extend?: Record<string, unknown>, plugins?: unknown[] } } options
51
+ * @param { {
52
+ * content?: string[],
53
+ * extend?: Record<string, unknown>,
54
+ * plugins?: unknown[],
55
+ * includeSdkTemplates?: boolean,
56
+ * rootDir?: string,
57
+ * sdkContentOptions?: Record<string, unknown>
58
+ * } } options
27
59
  * @returns { import('tailwindcss').Config }
28
60
  */
29
61
  function createIotaTailwindConfig(options = {}) {
30
62
  const { content = [], extend = {}, plugins = [] } = options;
63
+ const rootDir = path.resolve(options.rootDir ?? process.cwd());
64
+ const includeSdkTemplates = shouldIncludeSdkTemplates(
65
+ options.includeSdkTemplates,
66
+ rootDir
67
+ );
68
+ const sdkTemplateContent = includeSdkTemplates
69
+ ? resolveIotaSdkTailwindContent({
70
+ rootDir,
71
+ ...(options.sdkContentOptions ?? {}),
72
+ })
73
+ : [];
31
74
  const mergedExtend = mergeDeep(sdkTheme, extend);
75
+ const mergedContent = uniqueStrings([
76
+ ...normalizeStringArray(content),
77
+ ...normalizeStringArray(sdkTemplateContent),
78
+ ]);
79
+
32
80
  return {
33
81
  darkMode: "class",
34
- content,
82
+ content: mergedContent,
35
83
  theme: {
36
84
  extend: mergedExtend,
37
85
  },
package/tailwind/iota.css CHANGED
@@ -115,9 +115,9 @@
115
115
  --clr-btn-bg-active: var(--gray-200);
116
116
  --clr-btn-bg-hover: var(--gray-100);
117
117
  --clr-btn-text: var(--black);
118
- --crl-btn-text-hover: var(--black);
119
- --clr-btn-border: var(--transaprent);
120
- --clr-btn-border-hover: var(--transaprent);
118
+ --clr-btn-text-hover: var(--black);
119
+ --clr-btn-border: var(--transparent);
120
+ --clr-btn-border-hover: var(--transparent);
121
121
 
122
122
  /* Primary btn */
123
123
  --clr-primary-btn-bg: var(--primary-500);
@@ -428,12 +428,12 @@
428
428
  .btn {
429
429
  --text-color: var(--clr-btn-text);
430
430
  --loading-indicator-color: var(--clr-btn-text);
431
- --text-hover: var(--crl-btn-text-hover);
432
- --bg-color: var(--crl-btn-bg);
431
+ --text-hover: var(--clr-btn-text-hover);
432
+ --bg-color: var(--clr-btn-bg);
433
433
  --bg-active: var(--clr-btn-bg-active);
434
434
  --bg-hover: var(--clr-btn-bg-hover);
435
435
  --border-color: var(--clr-btn-border);
436
- --border-hover: var(--crl-btn-border-hover);
436
+ --border-hover: var(--clr-btn-border-hover);
437
437
  --border-size: 1px;
438
438
  --size-x: calc(1rem - var(--border-size) * 2);
439
439
  --size-y: calc(0.75rem - var(--border-size) * 2);
@@ -0,0 +1,177 @@
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+ const { execSync } = require("child_process");
4
+
5
+ function directoryExists(dirPath) {
6
+ try {
7
+ return Boolean(dirPath) && fs.existsSync(dirPath) && fs.statSync(dirPath).isDirectory();
8
+ } catch {
9
+ return false;
10
+ }
11
+ }
12
+
13
+ function fileExists(filePath) {
14
+ try {
15
+ return Boolean(filePath) && fs.existsSync(filePath) && fs.statSync(filePath).isFile();
16
+ } catch {
17
+ return false;
18
+ }
19
+ }
20
+
21
+ function uniqueSorted(items) {
22
+ return Array.from(new Set(items.filter(Boolean))).sort();
23
+ }
24
+
25
+ function normalizeRootDir(rootDir) {
26
+ if (!rootDir || typeof rootDir !== "string") {
27
+ return process.cwd();
28
+ }
29
+ return path.resolve(rootDir);
30
+ }
31
+
32
+ function resolveGoModCacheDir(env) {
33
+ if (env.GOMODCACHE) {
34
+ return env.GOMODCACHE;
35
+ }
36
+ if (env.GOPATH) {
37
+ return path.join(env.GOPATH, "pkg", "mod");
38
+ }
39
+ return "";
40
+ }
41
+
42
+ function resolveGoListModuleDir(rootDir, execSyncFn, env) {
43
+ if (!fileExists(path.join(rootDir, "go.mod"))) {
44
+ return "";
45
+ }
46
+ try {
47
+ return execSyncFn("go list -m -f '{{.Dir}}' github.com/iota-uz/iota-sdk", {
48
+ cwd: rootDir,
49
+ stdio: ["ignore", "pipe", "ignore"],
50
+ env: { ...env, GOWORK: "off" },
51
+ })
52
+ .toString()
53
+ .trim();
54
+ } catch {
55
+ return "";
56
+ }
57
+ }
58
+
59
+ function defaultMonorepoCandidates(rootDir) {
60
+ return [
61
+ path.resolve(rootDir, "..", "iota-sdk"),
62
+ path.resolve(rootDir, "..", "..", "iota-sdk"),
63
+ path.resolve(rootDir, "..", "..", "..", "iota-sdk"),
64
+ ];
65
+ }
66
+
67
+ function sdkTemplateGlobsFromDir(sdkDir) {
68
+ return [
69
+ path.join(sdkDir, "modules", "**", "templates", "**", "*.{html,js,templ}"),
70
+ path.join(sdkDir, "components", "**", "*.{html,js,templ,go}"),
71
+ ];
72
+ }
73
+
74
+ function sdkTemplateGlobsFromGoModCache(goModCacheDir) {
75
+ return [
76
+ path.join(
77
+ goModCacheDir,
78
+ "github.com",
79
+ "iota-uz",
80
+ "iota-sdk@*",
81
+ "modules",
82
+ "**",
83
+ "templates",
84
+ "**",
85
+ "*.{html,js,templ}"
86
+ ),
87
+ path.join(
88
+ goModCacheDir,
89
+ "github.com",
90
+ "iota-uz",
91
+ "iota-sdk@*",
92
+ "components",
93
+ "**",
94
+ "*.{html,js,templ,go}"
95
+ ),
96
+ ];
97
+ }
98
+
99
+ function resolveIotaSdkTailwindContentWithDebug(options = {}) {
100
+ const rootDir = normalizeRootDir(options.rootDir);
101
+ const env = { ...process.env, ...(options.env ?? {}) };
102
+ const execSyncFn = options.execSyncFn ?? execSync;
103
+ const includeGoList = options.includeGoList !== false;
104
+ const includeMonorepoFallback = options.includeMonorepoFallback !== false;
105
+ const includeGoModCache = options.includeGoModCache !== false;
106
+
107
+ const sources = {
108
+ rootDir,
109
+ goListModuleDir: "",
110
+ monorepoCandidateDirs: [],
111
+ goModCacheDir: "",
112
+ };
113
+
114
+ const sdkDirs = [];
115
+
116
+ if (typeof options.goListModuleDir === "string" && options.goListModuleDir.trim() !== "") {
117
+ sources.goListModuleDir = path.resolve(options.goListModuleDir);
118
+ } else if (includeGoList) {
119
+ sources.goListModuleDir = resolveGoListModuleDir(rootDir, execSyncFn, env);
120
+ }
121
+ if (directoryExists(sources.goListModuleDir)) {
122
+ sdkDirs.push(path.resolve(sources.goListModuleDir));
123
+ }
124
+
125
+ if (includeMonorepoFallback) {
126
+ const rawMonorepoCandidates = Array.isArray(options.monorepoCandidates) && options.monorepoCandidates.length > 0
127
+ ? options.monorepoCandidates
128
+ : defaultMonorepoCandidates(rootDir);
129
+ for (const candidate of rawMonorepoCandidates) {
130
+ if (!candidate || typeof candidate !== "string") {
131
+ continue;
132
+ }
133
+ const absCandidate = path.resolve(candidate);
134
+ if (directoryExists(absCandidate)) {
135
+ sources.monorepoCandidateDirs.push(absCandidate);
136
+ sdkDirs.push(absCandidate);
137
+ }
138
+ }
139
+ }
140
+
141
+ if (includeGoModCache) {
142
+ const rawGoModCacheDir = typeof options.goModCacheDir === "string" && options.goModCacheDir.trim() !== ""
143
+ ? options.goModCacheDir
144
+ : resolveGoModCacheDir(env);
145
+ if (directoryExists(rawGoModCacheDir)) {
146
+ sources.goModCacheDir = path.resolve(rawGoModCacheDir);
147
+ }
148
+ }
149
+
150
+ const content = [];
151
+ for (const sdkDir of uniqueSorted(sdkDirs)) {
152
+ content.push(...sdkTemplateGlobsFromDir(sdkDir));
153
+ }
154
+ if (
155
+ sources.goModCacheDir &&
156
+ directoryExists(path.join(sources.goModCacheDir, "github.com", "iota-uz"))
157
+ ) {
158
+ content.push(...sdkTemplateGlobsFromGoModCache(sources.goModCacheDir));
159
+ }
160
+
161
+ return {
162
+ content: uniqueSorted(content),
163
+ sources: {
164
+ ...sources,
165
+ monorepoCandidateDirs: uniqueSorted(sources.monorepoCandidateDirs),
166
+ },
167
+ };
168
+ }
169
+
170
+ function resolveIotaSdkTailwindContent(options = {}) {
171
+ return resolveIotaSdkTailwindContentWithDebug(options).content;
172
+ }
173
+
174
+ module.exports = {
175
+ resolveIotaSdkTailwindContent,
176
+ resolveIotaSdkTailwindContentWithDebug,
177
+ };
@@ -48,6 +48,18 @@ module.exports = {
48
48
  DEFAULT: "oklch(var(--black) / <alpha-value>)",
49
49
  950: "oklch(var(--black-950) / <alpha-value>)",
50
50
  },
51
+ primary: {
52
+ 50: "oklch(var(--primary-50) / <alpha-value>)",
53
+ 100: "oklch(var(--primary-100) / <alpha-value>)",
54
+ 200: "oklch(var(--primary-200) / <alpha-value>)",
55
+ 300: "oklch(var(--primary-300) / <alpha-value>)",
56
+ 400: "oklch(var(--primary-400) / <alpha-value>)",
57
+ 500: "oklch(var(--primary-500) / <alpha-value>)",
58
+ 600: "oklch(var(--primary-600) / <alpha-value>)",
59
+ 700: "oklch(var(--primary-700) / <alpha-value>)",
60
+ 800: "oklch(var(--primary-800) / <alpha-value>)",
61
+ 900: "oklch(var(--primary-900) / <alpha-value>)",
62
+ },
51
63
  brand: {
52
64
  500: "oklch(var(--primary-500) / <alpha-value>)",
53
65
  600: "oklch(var(--primary-600) / <alpha-value>)",