@v1nt1248/3nclient-lib 0.0.16 → 0.0.19

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 (39) hide show
  1. package/README.md +44 -4
  2. package/dist/components/ui3n-emoji.vue.d.ts +8 -1
  3. package/dist/components/ui3n-list.vue.d.ts +1 -1
  4. package/dist/components/ui3n-virtual-scroll.vue.d.ts +1 -1
  5. package/dist/constants/emoticons.d.ts +4 -649
  6. package/dist/libs/index.d.ts +2 -1
  7. package/dist/libs/serialization-for-ipc/protobuf-type.d.ts +1 -1
  8. package/dist/libs/serialization-for-ipc/types.d.ts +3 -0
  9. package/dist/libs/sqlite-on-3nstorage/types.d.ts +0 -1
  10. package/dist/stories/Ui3nButton.stories.d.ts +203 -0
  11. package/dist/stories/Ui3nDialog.stories.d.ts +41 -0
  12. package/dist/stories/Ui3nDropFiles.stories.d.ts +140 -0
  13. package/dist/stories/Ui3nEmoji.stories.d.ts +39 -0
  14. package/dist/stories/Ui3nIcon.stories.d.ts +80 -0
  15. package/dist/stories/Ui3nInput.stories.d.ts +456 -0
  16. package/dist/stories/Ui3nList.stories.d.ts +29 -0
  17. package/dist/stories/data/data-to-list.d.ts +8 -0
  18. package/dist/stories/data/icons.d.ts +1 -0
  19. package/dist/style.css +1 -1
  20. package/dist/ui-3n-lib.js +9487 -10373
  21. package/package.json +24 -7
  22. package/src/components/ui3n-button.vue +20 -4
  23. package/src/components/ui3n-drop-files.vue +34 -11
  24. package/src/components/ui3n-emoji.vue +34 -14
  25. package/src/components/ui3n-input.vue +3 -2
  26. package/src/components/ui3n-list.vue +1 -1
  27. package/src/libs/index.ts +0 -11
  28. package/src/libs/ipc-service-caller.ts +0 -121
  29. package/src/libs/ipc-service.ts +0 -422
  30. package/src/libs/serialization-for-ipc/copy-json.ts +0 -55
  31. package/src/libs/serialization-for-ipc/json-ipc.proto.d.ts +0 -432
  32. package/src/libs/serialization-for-ipc/json-ipc.proto.js +0 -1093
  33. package/src/libs/serialization-for-ipc/json-n-binary.ts +0 -275
  34. package/src/libs/serialization-for-ipc/protobuf-type.ts +0 -61
  35. package/src/libs/sqlite-on-3nstorage/deferred.ts +0 -32
  36. package/src/libs/sqlite-on-3nstorage/index.ts +0 -292
  37. package/src/libs/sqlite-on-3nstorage/sqljs.js +0 -225
  38. package/src/libs/sqlite-on-3nstorage/synced.ts +0 -194
  39. package/src/libs/sqlite-on-3nstorage/types.ts +0 -279
package/package.json CHANGED
@@ -1,15 +1,14 @@
1
1
  {
2
2
  "name": "@v1nt1248/3nclient-lib",
3
- "private": false,
4
3
  "license": "AGPL-3.0-or-later",
5
4
  "author": "v1nt1248",
6
- "version": "0.0.16",
5
+ "version": "0.0.19",
7
6
  "description": "Library for 3NWeb clients",
7
+ "private": false,
8
8
  "type": "module",
9
9
  "files": [
10
10
  "dist",
11
- "src/components/",
12
- "src/libs"
11
+ "src/components/"
13
12
  ],
14
13
  "module": "./dist/ui-3n-lib.js",
15
14
  "types": "./dist/index.d.ts",
@@ -30,7 +29,9 @@
30
29
  "linter": "eslint -c .eslintrc.cjs --ext .js,.vue,.ts, src",
31
30
  "linter:fix": "eslint -c .eslintrc.cjs --fix --ext .js,.vue,.ts, src",
32
31
  "lint": "yarn linter && yarn stylelint",
33
- "lint:fix": "yarn linter:fix && yarn stylelint:fix"
32
+ "lint:fix": "yarn linter:fix && yarn stylelint:fix",
33
+ "storybook": "storybook dev -p 6006",
34
+ "build-storybook": "storybook build"
34
35
  },
35
36
  "dependencies": {
36
37
  "@iconify-icons/ic": "^1.2.13",
@@ -47,22 +48,38 @@
47
48
  "vue": "^3.3.4"
48
49
  },
49
50
  "devDependencies": {
51
+ "@storybook/addon-actions": "^7.4.4",
52
+ "@storybook/addon-docs": "^7.4.4",
53
+ "@storybook/addon-essentials": "^7.4.4",
54
+ "@storybook/addon-interactions": "^7.4.4",
55
+ "@storybook/addon-links": "^7.4.4",
56
+ "@storybook/blocks": "^7.4.4",
57
+ "@storybook/builder-vite": "^7.4.4",
58
+ "@storybook/testing-library": "^0.2.1",
59
+ "@storybook/vue3": "^7.4.4",
60
+ "@storybook/vue3-vite": "^7.4.4",
50
61
  "@types/lodash": "^4.14.197",
51
62
  "@types/node": "^20.5.6",
52
63
  "@types/sanitize-html": "^2.9.0",
53
64
  "@typescript-eslint/eslint-plugin": "^6.4.1",
54
65
  "@typescript-eslint/parser": "^6.4.1",
55
66
  "@vitejs/plugin-vue": "^4.2.3",
67
+ "@vue/compiler-core": "^3.3.4",
56
68
  "@vue/eslint-config-typescript": "^11.0.3",
57
69
  "@vuedx/typescript-plugin-vue": "^0.7.6",
58
70
  "eslint": "^8.48.0",
59
71
  "eslint-plugin-import": "^2.28.1",
60
72
  "eslint-plugin-node": "^11.1.0",
61
73
  "eslint-plugin-promise": "^6.1.1",
74
+ "eslint-plugin-storybook": "^0.6.14",
62
75
  "eslint-plugin-vue": "^9.17.0",
76
+ "jackspeak": "^2.3.3",
63
77
  "pinia": "^2.1.6",
64
78
  "postcss-html": "^1.5.0",
79
+ "react": "^18.2.0",
80
+ "react-dom": "^18.2.0",
65
81
  "sass": "^1.66.1",
82
+ "storybook": "^7.4.4",
66
83
  "stylelint": "^15.10.3",
67
84
  "stylelint-config-recommended-scss": "^12.0.0",
68
85
  "stylelint-config-recommended-vue": "^1.5.0",
@@ -71,10 +88,10 @@
71
88
  "stylelint-scss": "^5.1.0",
72
89
  "typescript": "^5.2.2",
73
90
  "vite": "^4.4.5",
74
- "vite-plugin-commonjs": "^0.9.0",
75
91
  "vite-plugin-css-injected-by-js": "^3.3.0",
76
92
  "vite-plugin-dts": "^3.5.3",
77
93
  "vue": "^3.3.4",
78
94
  "vue-tsc": "^1.8.5"
79
- }
95
+ },
96
+ "packageManager": "yarn@3.6.3"
80
97
  }
@@ -1,5 +1,5 @@
1
1
  <script lang="ts" setup>
2
- import { computed, onMounted, ref, useSlots } from 'vue'
2
+ import { computed, onMounted, ref, useSlots, watch } from 'vue'
3
3
  import { hasSlotContent } from '../tools/ui.helpers'
4
4
  import Ui3nIcon from './ui3n-icon.vue'
5
5
 
@@ -27,6 +27,22 @@
27
27
  const buttonEl = ref<HTMLButtonElement | null>(null)
28
28
  const isSlotEmpty = computed(() => !hasSlotContent(slots['default']))
29
29
 
30
+ watch(
31
+ [() => props.color, () => props.textColor],
32
+ (newValue: [string|undefined, string|undefined], prevValue: [string|undefined, string|undefined]) => {
33
+ const [ prevColor, prevTextColor ] = prevValue
34
+ const [ color, textColor ] = newValue
35
+ if (buttonEl.value) {
36
+ if (color !== prevColor) {
37
+ buttonEl.value.style.setProperty('--ui3n-button-background', color ?? 'var(--blue-main, #0090ec)')
38
+ }
39
+ if (textColor !== prevTextColor) {
40
+ buttonEl.value.style.setProperty('--ui3n-button-text-color', textColor ?? 'var(--system-white, #fff)')
41
+ }
42
+ }
43
+ },
44
+ )
45
+
30
46
  onMounted(() => {
31
47
  if (buttonEl.value) {
32
48
  if (props.color) {
@@ -97,8 +113,8 @@
97
113
  transition: background 0.5s ease-in-out;
98
114
 
99
115
  &--round {
100
- --ui3n-button-padding-vert: 4px;
101
- --ui3n-button-padding-horiz: 4px;
116
+ --ui3n-button-padding-vert: 6px;
117
+ --ui3n-button-padding-horiz: 6px;
102
118
 
103
119
  border-radius: 50%;
104
120
  }
@@ -115,6 +131,7 @@
115
131
  var(--ui3n-button-background)
116
132
  radial-gradient(circle, transparent 1%, var(--ui3n-button-background) 1%)
117
133
  center/15000%;
134
+ box-shadow: 0 0 4px var(--shadow-key-ambient-opacity, rgba(0, 0, 0, 0.12));
118
135
 
119
136
  .ui3n-button {
120
137
  &__icon,
@@ -152,4 +169,3 @@
152
169
  }
153
170
  }
154
171
  </style>
155
- ../tools/ui.helpers
@@ -1,5 +1,5 @@
1
1
  <script lang="ts" setup>
2
- import { computed, ref } from 'vue'
2
+ import { computed, onMounted, ref } from 'vue'
3
3
 
4
4
  export interface Ui3nDropFilesProps {
5
5
  title?: string;
@@ -14,6 +14,8 @@
14
14
  const props = defineProps<Ui3nDropFilesProps>()
15
15
  const emit = defineEmits<Ui3nDropFilesEmits>()
16
16
 
17
+ const wrapperElement = ref<HTMLDivElement | null>(null)
18
+ const wrapperElementHeight = ref(0)
17
19
  const isOverDropPlace = ref(false)
18
20
  const isOverDropZone = ref(false)
19
21
  const params = computed(() => {
@@ -26,6 +28,20 @@
26
28
  }
27
29
  })
28
30
 
31
+ onMounted(() => {
32
+ if (wrapperElement.value) {
33
+ wrapperElementHeight.value = wrapperElement.value.clientHeight
34
+ wrapperElement.value.style.setProperty('--dropzone-height', `${wrapperElementHeight.value}px`)
35
+ let titleFontSize = 12
36
+ if (wrapperElementHeight.value > 100 && wrapperElementHeight.value <= 240) {
37
+ titleFontSize = 16
38
+ } else if (wrapperElementHeight.value > 240) {
39
+ titleFontSize = 20
40
+ }
41
+ wrapperElement.value.style.setProperty('--dropzone-title-font', `${titleFontSize}px`)
42
+ }
43
+ })
44
+
29
45
  const onDragenter = (ev: MouseEvent) => {
30
46
  ev.preventDefault()
31
47
  isOverDropPlace.value = true
@@ -60,6 +76,7 @@
60
76
  <template>
61
77
  <!-- eslint-disable max-len -->
62
78
  <div
79
+ ref="wrapperElement"
63
80
  class="ui3n-drop-files"
64
81
  @dragenter="onDragenter"
65
82
  @dragleave="onDragleave"
@@ -80,8 +97,8 @@
80
97
  </h3>
81
98
  <div class="ui3n-drop-files__dropzone-icon">
82
99
  <svg
83
- width="192"
84
- height="192"
100
+ :width="wrapperElementHeight / 2"
101
+ :height="wrapperElementHeight / 2"
85
102
  viewBox="0 0 192 192"
86
103
  fill="none"
87
104
  xmlns="http://www.w3.org/2000/svg"
@@ -110,11 +127,16 @@
110
127
 
111
128
  <style lang="scss" scoped>
112
129
  .ui3n-drop-files {
130
+ --dropzone-height: 0;
131
+ --dropzone-title-font: 0;
132
+
113
133
  position: relative;
134
+ box-sizing: border-box;
114
135
  width: 100%;
115
136
  height: 100%;
116
137
 
117
138
  &__dropzone {
139
+ box-sizing: border-box;
118
140
  position: absolute;
119
141
  background-color: var(--system-white, #fff);
120
142
  display: flex;
@@ -126,19 +148,20 @@
126
148
  z-index: 5;
127
149
 
128
150
  &-border {
151
+ box-sizing: border-box;
129
152
  position: absolute;
130
- width: calc(100% - calc(var(--base-size, 8px) * 2));
131
- height: calc(100% - calc(var(--base-size, 8px) * 2));
132
- top: var(--base-size, 8px);
133
- left: var(--base-size, 8px);
153
+ top: calc(var(--base-size, 8px) + 1px);
154
+ bottom: calc(var(--base-size, 8px) + 1px);
155
+ left: calc(var(--base-size, 8px) + 1px);
156
+ right: calc(var(--base-size, 8px) + 1px);
134
157
  border-radius: var(--base-size, 8px);
135
158
  border: 2px dashed var(--gray-50, #f2f2f2);
136
159
  pointer-events: none;
137
160
  }
138
161
 
139
162
  &-title {
140
- margin: 0 0 24px;
141
- font-size: var(--font-24, 24px);
163
+ margin: 0 0 var(--dropzone-title-font);
164
+ font-size: var(--dropzone-title-font);
142
165
  font-weight: 600;
143
166
  color: var(--black-30, #b3b3b3);
144
167
  pointer-events: none;
@@ -146,8 +169,8 @@
146
169
 
147
170
  &-icon {
148
171
  position: relative;
149
- width: 160px;
150
- height: 160px;
172
+ width: calc(var(--dropzone-height) * 0.4);
173
+ height: calc(var(--dropzone-height) * 0.4);
151
174
  border-radius: 50%;
152
175
  background-color: var(--gray-50, #f2f2f2);
153
176
  display: flex;
@@ -1,5 +1,7 @@
1
1
  <script lang="ts" setup>
2
- import { computed, onMounted, ref } from 'vue'
2
+ import { computed, onMounted, ref, watch } from 'vue'
3
+ import { emoticons } from '../constants/emoticons'
4
+
3
5
 
4
6
  export interface Ui3nEmojiProps {
5
7
  emoji: string;
@@ -11,26 +13,43 @@
11
13
  (ev: 'click', value: Event): void;
12
14
  }
13
15
 
14
- const props = defineProps<Ui3nEmojiProps>()
16
+ const props = withDefaults(
17
+ defineProps<Ui3nEmojiProps>(),
18
+ {
19
+ size: 16,
20
+ readonly: false,
21
+ },
22
+ )
15
23
  const emit = defineEmits<Ui3nEmojiEmits>()
16
24
 
17
25
  const emojiElement = ref<HTMLDivElement | null>(null)
18
- const params = computed(() => {
19
- const {
20
- emoji,
21
- size = 16,
22
- readonly = false,
23
- } = props
24
-
25
- return { emoji, size, readonly }
26
- })
26
+ const emojiData = computed(() => emoticons[props.emoji])
27
27
 
28
28
  onMounted(() => {
29
29
  if (emojiElement.value) {
30
- emojiElement.value.style.setProperty('--emoji-size', `${params.value.size}px`)
30
+ emojiElement.value.style.setProperty('--emoji-size', `${props.size}px`)
31
31
  }
32
32
  })
33
33
 
34
+ watch(
35
+ () => props.emoji,
36
+ newValue => {
37
+ if (!Object.keys(emoticons).includes(newValue)) {
38
+ console.error(`[Ui3nEmoji] Invalid emoticon: ${newValue}`)
39
+ }
40
+ },
41
+ { immediate: true },
42
+ )
43
+
44
+ watch(
45
+ () => props.size,
46
+ (newValue, prevValue) => {
47
+ if (emojiElement.value && newValue && newValue !== prevValue) {
48
+ emojiElement.value.style.setProperty('--emoji-size', `${newValue}px`)
49
+ }
50
+ },
51
+ )
52
+
34
53
  const onClick = (ev: Event) => {
35
54
  ev.stopImmediatePropagation()
36
55
  emit('click', ev)
@@ -42,11 +61,11 @@
42
61
  ref="emojiElement"
43
62
  :class="[
44
63
  'ui3n-emoji',
45
- { 'ui3n-emoji--readonly': params.readonly },
64
+ { 'ui3n-emoji--readonly': props.readonly },
46
65
  ]"
47
66
  v-on="readonly ? {} : { 'click': onClick }"
48
67
  >
49
- {{ emoji }}
68
+ {{ emojiData && emojiData.value }}
50
69
  </div>
51
70
  </template>
52
71
 
@@ -57,6 +76,7 @@
57
76
  display: flex;
58
77
  width: var(--emoji-size);
59
78
  height: var(--emoji-size);
79
+ font-size: var(--emoji-size);
60
80
  justify-content: center;
61
81
  align-items: center;
62
82
  cursor: pointer;
@@ -185,6 +185,7 @@
185
185
  display: block;
186
186
  width: 100%;
187
187
  font-size: var(--font-12, 12px);
188
+ line-height: var(--font-16, 16px);
188
189
  font-weight: 600;
189
190
  color: var(--black-90, #212121);
190
191
  margin-bottom: calc(var(--base-size, 8px) / 2);
@@ -271,11 +272,11 @@
271
272
 
272
273
  &--with-label {
273
274
  .ui3n-input__icon {
274
- top: calc(var(--base-size) * 3.5 + 1px);
275
+ top: calc(var(--base-size, 8px) * 3.5 + 1px);
275
276
  }
276
277
 
277
278
  .ui3n-input__clear-btn {
278
- top: calc(var(--base-size) * 3 + 1px);
279
+ top: calc(var(--base-size, 8px) * 3 + 1px);
279
280
  }
280
281
  }
281
282
  }
@@ -62,7 +62,7 @@
62
62
  <div
63
63
  :class="[
64
64
  'ui3n-list__item-content',
65
- { 'ui3n-list__item-content--disables': props.disabled },
65
+ { 'ui3n-list__item-content--disabled': props.disabled },
66
66
  ]"
67
67
  @click.stop="emits('select', { value: item, index })"
68
68
  >
package/src/libs/index.ts DELETED
@@ -1,11 +0,0 @@
1
- export * from './sqlite-on-3nstorage'
2
- export {
3
- makeObservableMethodCaller,
4
- makeReqRepMethodCaller,
5
- makeServiceCaller,
6
- } from './ipc-service-caller'
7
- export {
8
- SingleConnectionIPCWrap,
9
- MultiConnectionIPCWrap,
10
- IPCWrap,
11
- } from './ipc-service'
@@ -1,121 +0,0 @@
1
- /*
2
- Copyright (C) 2022 - 2023 3NSoft Inc.
3
-
4
- This program is free software: you can redistribute it and/or modify it under
5
- the terms of the GNU General Public License as published by the Free Software
6
- Foundation, either version 3 of the License, or (at your option) any later
7
- version.
8
-
9
- This program is distributed in the hope that it will be useful, but
10
- WITHOUT ANY WARRANTY; without even the implied warranty of
11
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
- See the GNU General Public License for more details.
13
-
14
- You should have received a copy of the GNU General Public License along with
15
- this program. If not, see <http://www.gnu.org/licenses/>.
16
- */
17
-
18
- /// <reference path="../@types/platform-defs/w3n.d.ts" />
19
-
20
- import { deserializeArgs, serializeArgs } from "./serialization-for-ipc/json-n-binary";
21
-
22
- type RPCConnection = web3n.rpc.client.RPCConnection;
23
- type PassedDatum = web3n.rpc.PassedDatum;
24
- type Observer<T> = web3n.Observer<T>;
25
-
26
-
27
- export interface TransformOpts {
28
- unpackReply?: ((reply: PassedDatum | undefined) => any) | 'noop';
29
- packRequest?: ((args: any[]) => PassedDatum | undefined) | 'noop';
30
- }
31
-
32
- function replyFromPassedDatum(
33
- data: PassedDatum|undefined, unpack: TransformOpts['unpackReply']
34
- ): any {
35
- if (!data) { return; }
36
- if (unpack) {
37
- if (unpack === 'noop') {
38
- return [data.bytes];
39
- }
40
- else {
41
- return unpack(data);
42
- }
43
- }
44
- else {
45
- const { bytes, passedByReference } = data;
46
- return (bytes ? deserializeArgs(bytes, passedByReference)[0] : undefined);
47
- }
48
- }
49
-
50
- function argsToPassedDatum(
51
- args: any[], pack: TransformOpts['packRequest']
52
- ): PassedDatum|undefined {
53
- if (args === undefined) { return; }
54
- if (pack) {
55
- if (pack === 'noop') {
56
- if (!ArrayBuffer.isView(args[0])) {
57
- throw new Error(`Method returned non-binary, while no serialization is set`);
58
- }
59
- return { bytes: args[0] as Uint8Array };
60
- }
61
- return pack(args);
62
- }
63
- else {
64
- return serializeArgs(args);
65
- }
66
- }
67
-
68
- export function makeReqRepMethodCaller<F extends Function>(
69
- connection: RPCConnection, method: string, transforms?: TransformOpts
70
- ): F {
71
- return (async (...args: any[]) => {
72
- const req = argsToPassedDatum(args, transforms?.packRequest);
73
- const reply = await connection.makeRequestReplyCall(method, req);
74
- return replyFromPassedDatum(reply, transforms?.unpackReply);
75
- }) as any as F;
76
- }
77
-
78
- export function makeObservableMethodCaller<F extends Function>(
79
- connection: RPCConnection, method: string, transforms?: TransformOpts
80
- ): F {
81
- return ((obs: Observer<any>, ...args: any[]) => {
82
- const req = argsToPassedDatum(args, transforms?.packRequest);
83
- const obsWrap: Observer<any> = {
84
- next: data => {
85
- if (!obs.next) {
86
- return;
87
- }
88
- const ev = replyFromPassedDatum(data, transforms?.unpackReply);
89
- obs.next(ev);
90
- },
91
- complete: obs.complete,
92
- error: obs.error
93
- };
94
- return connection.startObservableCall(method, req, obsWrap);
95
- }) as any as F;
96
- }
97
-
98
- export function makeServiceCaller<T>(
99
- connection: RPCConnection,
100
- reqRepMethods?: (keyof T)[], obsMethods?: (keyof T)[],
101
- transforms?: { [method in keyof T]: TransformOpts; }
102
- ): Partial<T> {
103
- const caller = {} as T;
104
- if (reqRepMethods) {
105
- for (const method of reqRepMethods) {
106
- caller[method] = makeReqRepMethodCaller(
107
- connection, method as string,
108
- (transforms ? transforms[method] : undefined)
109
- ) as any;
110
- }
111
- }
112
- if (obsMethods) {
113
- for (const method of obsMethods) {
114
- caller[method] = makeObservableMethodCaller(
115
- connection, method as string,
116
- (transforms ? transforms[method] : undefined)
117
- ) as any;
118
- }
119
- }
120
- return caller;
121
- }