@inditextech/weave-types 0.1.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/README.md ADDED
@@ -0,0 +1,282 @@
1
+ <!--
2
+ SPDX-FileCopyrightText: 2025 2025 INDUSTRIA DE DISEÑO TEXTIL S.A. (INDITEX S.A.)
3
+
4
+ SPDX-License-Identifier: Apache-2.0
5
+ -->
6
+
7
+ [![npm version](https://badge.fury.io/js/angular2-expandable-list.svg)](https://badge.fury.io/js/angular2-expandable-list)
8
+ [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
9
+
10
+ # Weave.js / SDK
11
+
12
+ > Write a project description
13
+
14
+ ## Prerequisites
15
+
16
+ This project requires NodeJS (version 8 or later) and NPM.
17
+ [Node](http://nodejs.org/) and [NPM](https://npmjs.org/) are really easy to install.
18
+ To make sure you have them available on your machine,
19
+ try running the following command.
20
+
21
+ ```sh
22
+ $ npm -v && node -v
23
+ 6.4.1
24
+ v8.16.0
25
+ ```
26
+
27
+ ## Table of contents
28
+
29
+ - [Project Name](#project-name)
30
+ - [Prerequisites](#prerequisites)
31
+ - [Table of contents](#table-of-contents)
32
+ - [Getting Started](#getting-started)
33
+ - [Installation](#installation)
34
+ - [Usage](#usage)
35
+ - [Serving the app](#serving-the-app)
36
+ - [Running the tests](#running-the-tests)
37
+ - [Building a distribution version](#building-a-distribution-version)
38
+ - [Serving the distribution version](#serving-the-distribution-version)
39
+ - [API](#api)
40
+ - [useBasicFetch](#usebasicfetch)
41
+ - [Options](#options)
42
+ - [fetchData](#fetchdata)
43
+ - [Contributing](#contributing)
44
+ - [Credits](#credits)
45
+ - [Built With](#built-with)
46
+ - [Versioning](#versioning)
47
+ - [Authors](#authors)
48
+ - [License](#license)
49
+
50
+ ## Getting Started
51
+
52
+ These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
53
+
54
+ ## Installation
55
+
56
+ **BEFORE YOU INSTALL:** please read the [prerequisites](#prerequisites)
57
+
58
+ Start with cloning this repo on your local machine:
59
+
60
+ ```sh
61
+ $ git clone https://github.com/ORG/PROJECT.git
62
+ $ cd PROJECT
63
+ ```
64
+
65
+ To install and set up the library, run:
66
+
67
+ ```sh
68
+ $ npm install -S myLib
69
+ ```
70
+
71
+ Or if you prefer using Yarn:
72
+
73
+ ```sh
74
+ $ yarn add --dev myLib
75
+ ```
76
+
77
+ ## Usage
78
+
79
+ ### Serving the app
80
+
81
+ ```sh
82
+ $ npm start
83
+ ```
84
+
85
+ ### Running the tests
86
+
87
+ ```sh
88
+ $ npm test
89
+ ```
90
+
91
+ ### Building a distribution version
92
+
93
+ ```sh
94
+ $ npm run build
95
+ ```
96
+
97
+ This task will create a distribution version of the project
98
+ inside your local `dist/` folder
99
+
100
+ ### Serving the distribution version
101
+
102
+ ```sh
103
+ $ npm run serve:dist
104
+ ```
105
+
106
+ This will use `lite-server` for servign your already
107
+ generated distribution version of the project.
108
+
109
+ _Note_ this requires
110
+ [Building a distribution version](#building-a-distribution-version) first.
111
+
112
+ ## API
113
+
114
+ ### useBasicFetch
115
+
116
+ ```js
117
+ useBasicFetch(((url: string) = ''), ((delay: number) = 0));
118
+ ```
119
+
120
+ Supported options and result fields for the `useBasicFetch` hook are listed below.
121
+
122
+ #### Options
123
+
124
+ `url`
125
+
126
+ | Type | Default value |
127
+ | ------ | ------------- |
128
+ | string | '' |
129
+
130
+ If present, the request will be performed as soon as the component is mounted
131
+
132
+ Example:
133
+
134
+ ```tsx
135
+ const MyComponent: React.FC = () => {
136
+ const { data, error, loading } = useBasicFetch(
137
+ 'https://api.icndb.com/jokes/random'
138
+ );
139
+
140
+ if (error) {
141
+ return <p>Error</p>;
142
+ }
143
+
144
+ if (loading) {
145
+ return <p>Loading...</p>;
146
+ }
147
+
148
+ return (
149
+ <div className="App">
150
+ <h2>Chuck Norris Joke of the day</h2>
151
+ {data && data.value && <p>{data.value.joke}</p>}
152
+ </div>
153
+ );
154
+ };
155
+ ```
156
+
157
+ `delay`
158
+
159
+ | Type | Default value | Description |
160
+ | ------ | ------------- | -------------------- |
161
+ | number | 0 | Time in milliseconds |
162
+
163
+ If present, the request will be delayed by the given amount of time
164
+
165
+ Example:
166
+
167
+ ```tsx
168
+ type Joke = {
169
+ value: {
170
+ id: number;
171
+ joke: string;
172
+ };
173
+ };
174
+
175
+ const MyComponent: React.FC = () => {
176
+ const { data, error, loading } = useBasicFetch<Joke>(
177
+ 'https://api.icndb.com/jokes/random',
178
+ 2000
179
+ );
180
+
181
+ if (error) {
182
+ return <p>Error</p>;
183
+ }
184
+
185
+ if (loading) {
186
+ return <p>Loading...</p>;
187
+ }
188
+
189
+ return (
190
+ <div className="App">
191
+ <h2>Chuck Norris Joke of the day</h2>
192
+ {data && data.value && <p>{data.value.joke}</p>}
193
+ </div>
194
+ );
195
+ };
196
+ ```
197
+
198
+ ### fetchData
199
+
200
+ ```js
201
+ fetchData(url: string)
202
+ ```
203
+
204
+ Perform an asynchronous http request against a given url
205
+
206
+ ```tsx
207
+ type Joke = {
208
+ value: {
209
+ id: number;
210
+ joke: string;
211
+ };
212
+ };
213
+
214
+ const ChuckNorrisJokes: React.FC = () => {
215
+ const { data, fetchData, error, loading } = useBasicFetch<Joke>();
216
+ const [jokeId, setJokeId] = useState(1);
217
+
218
+ useEffect(() => {
219
+ fetchData(`https://api.icndb.com/jokes/${jokeId}`);
220
+ }, [jokeId, fetchData]);
221
+
222
+ const handleNext = () => setJokeId(jokeId + 1);
223
+
224
+ if (error) {
225
+ return <p>Error</p>;
226
+ }
227
+
228
+ const jokeData = data && data.value;
229
+
230
+ return (
231
+ <div className="Comments">
232
+ {loading && <p>Loading...</p>}
233
+ {!loading && jokeData && (
234
+ <div>
235
+ <p>Joke ID: {jokeData.id}</p>
236
+ <p>{jokeData.joke}</p>
237
+ </div>
238
+ )}
239
+ {!loading && jokeData && !jokeData.joke && <p>{jokeData}</p>}
240
+ <button disabled={loading} onClick={handleNext}>
241
+ Next Joke
242
+ </button>
243
+ </div>
244
+ );
245
+ };
246
+ ```
247
+
248
+ ## Contributing
249
+
250
+ Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.
251
+
252
+ 1. Fork it!
253
+ 2. Create your feature branch: `git checkout -b my-new-feature`
254
+ 3. Add your changes: `git add .`
255
+ 4. Commit your changes: `git commit -am 'Add some feature'`
256
+ 5. Push to the branch: `git push origin my-new-feature`
257
+ 6. Submit a pull request :sunglasses:
258
+
259
+ ## Credits
260
+
261
+ TODO: Write credits
262
+
263
+ ## Built With
264
+
265
+ - Dropwizard - Bla bla bla
266
+ - Maven - Maybe
267
+ - Atom - ergaerga
268
+ - Love
269
+
270
+ ## Versioning
271
+
272
+ We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/your/project/tags).
273
+
274
+ ## Authors
275
+
276
+ - **John Doe** - _Initial work_ - [JohnDoe](https://github.com/JohnDoe)
277
+
278
+ See also the list of [contributors](https://github.com/your/project/contributors) who participated in this project.
279
+
280
+ ## License
281
+
282
+ [MIT License](https://andreasonny.mit-license.org/2019) © Andrea SonnY
package/dist/types.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E="mainLayer",A={IDLE:"idle",STARTING:"starting",LOADING_FONTS:"loadingFonts",RUNNING:"running"},_={UP:"up",DOWN:"down",FRONT:"front",BACK:"back"},T="white",O={PNG:"image/png",JPEG:"image/jpeg"},N={"image/png":".png","image/jpeg":".jpg"},e={CREATE:"create",UPDATE:"update",DELETE:"delete"};exports.STATE_ACTIONS=e;exports.WEAVE_EXPORT_BACKGROUND_COLOR=T;exports.WEAVE_EXPORT_FILE_FORMAT=N;exports.WEAVE_EXPORT_FORMATS=O;exports.WEAVE_INSTANCE_STATUS=A;exports.WEAVE_NODE_LAYER_ID=E;exports.WEAVE_NODE_POSITION=_;
Binary file
@@ -0,0 +1,203 @@
1
+ import { default as default_2 } from 'konva';
2
+
3
+ export declare type GroupSerializable = default_2.NodeConfig & {
4
+ id: string;
5
+ type: 'group';
6
+ nodes: string[];
7
+ };
8
+
9
+ export declare type GroupsStateChange = {
10
+ action: StateAction;
11
+ value: GroupSerializable;
12
+ };
13
+
14
+ export declare type NodeSerializable = default_2.NodeConfig & {
15
+ id: string;
16
+ type: string;
17
+ };
18
+
19
+ export declare type NodesStateChange = {
20
+ action: StateAction;
21
+ value: NodeSerializable;
22
+ };
23
+
24
+ export declare const STATE_ACTIONS: {
25
+ readonly CREATE: "create";
26
+ readonly UPDATE: "update";
27
+ readonly DELETE: "delete";
28
+ };
29
+
30
+ export declare type StateAction = (typeof STATE_ACTIONS)[StateActionKeys];
31
+
32
+ export declare type StateActionKeys = keyof typeof STATE_ACTIONS;
33
+
34
+ export declare const WEAVE_EXPORT_BACKGROUND_COLOR = "white";
35
+
36
+ export declare const WEAVE_EXPORT_FILE_FORMAT: {
37
+ readonly "image/png": ".png";
38
+ readonly "image/jpeg": ".jpg";
39
+ };
40
+
41
+ export declare const WEAVE_EXPORT_FORMATS: {
42
+ readonly PNG: "image/png";
43
+ readonly JPEG: "image/jpeg";
44
+ };
45
+
46
+ export declare const WEAVE_INSTANCE_STATUS: {
47
+ readonly IDLE: "idle";
48
+ readonly STARTING: "starting";
49
+ readonly LOADING_FONTS: "loadingFonts";
50
+ readonly RUNNING: "running";
51
+ };
52
+
53
+ export declare const WEAVE_NODE_LAYER_ID = "mainLayer";
54
+
55
+ export declare const WEAVE_NODE_POSITION: {
56
+ readonly UP: "up";
57
+ readonly DOWN: "down";
58
+ readonly FRONT: "front";
59
+ readonly BACK: "back";
60
+ };
61
+
62
+ export declare interface WeaveActionBase {
63
+ init?(): void;
64
+ trigger(cancelAction: () => void, params?: unknown): unknown;
65
+ internalUpdate?(): void;
66
+ cleanup?(): void;
67
+ }
68
+
69
+ export declare type WeaveAwarenessChange<K extends string, T> = {
70
+ [key in K]: T;
71
+ };
72
+
73
+ export declare type WeaveCallbacks = {
74
+ onRender?: () => void;
75
+ onRoomLoaded?: (loaded: boolean) => void;
76
+ onInstanceStatus?: (status: WeaveStatus) => void;
77
+ onActiveActionChange?: (actionName: string | undefined) => void;
78
+ onStateChange?: (state: WeaveState) => void;
79
+ onUndoManagerStatusChange?: (undoManagerStatus: WeaveUndoRedoChange) => void;
80
+ };
81
+
82
+ export declare type WeaveConfig = {
83
+ store: WeaveStoreBase;
84
+ nodes?: WeaveNodeBase[];
85
+ actions?: WeaveActionBase[];
86
+ plugins?: WeavePluginBase[];
87
+ fonts?: WeaveFont[];
88
+ callbacks?: WeaveCallbacks;
89
+ logger?: WeaveLoggerConfig;
90
+ };
91
+
92
+ export declare type WeaveElementAttributes = {
93
+ [key: string]: any;
94
+ id?: string;
95
+ nodeType?: string;
96
+ children?: WeaveStateElement[];
97
+ };
98
+
99
+ export declare type WeaveElementInstance = default_2.Layer | default_2.Group | default_2.Shape;
100
+
101
+ export declare type WeaveExportFileFormat = (typeof WEAVE_EXPORT_FILE_FORMAT)[WeaveExportFileFormatKeys];
102
+
103
+ export declare type WeaveExportFileFormatKeys = keyof typeof WEAVE_EXPORT_FILE_FORMAT;
104
+
105
+ export declare type WeaveExportFormat = (typeof WEAVE_EXPORT_FORMATS)[WeaveExportFormatKeys];
106
+
107
+ export declare type WeaveExportFormatKeys = keyof typeof WEAVE_EXPORT_FORMATS;
108
+
109
+ export declare type WeaveExportNodeOptions = {
110
+ format?: typeof WEAVE_EXPORT_FORMATS.PNG;
111
+ padding?: number;
112
+ pixelRatio?: number;
113
+ backgroundColor?: string;
114
+ quality?: number;
115
+ };
116
+
117
+ export declare type WeaveFont = {
118
+ id: string;
119
+ name: string;
120
+ };
121
+
122
+ export declare type WeaveLoggerConfig = {
123
+ disabled?: boolean;
124
+ level?: 'debug' | 'info' | 'warn' | 'error';
125
+ };
126
+
127
+ export declare interface WeaveNodeBase {
128
+ createNode(id: string, props: WeaveElementAttributes): WeaveStateElement;
129
+ createInstance(props: WeaveElementAttributes): WeaveElementInstance;
130
+ updateInstance(instance: WeaveElementInstance, nextProps: WeaveElementAttributes): void;
131
+ removeInstance(instance: WeaveElementInstance): void;
132
+ toNode(instance: WeaveElementInstance): WeaveStateElement;
133
+ }
134
+
135
+ export declare interface WeavePluginBase {
136
+ init?(): void;
137
+ render?(): void;
138
+ enable(): void;
139
+ disable(): void;
140
+ isEnabled(): boolean;
141
+ }
142
+
143
+ export declare type WeavePosition = (typeof WEAVE_NODE_POSITION)[WeavePositionKeys];
144
+
145
+ export declare type WeavePositionKeys = keyof typeof WEAVE_NODE_POSITION;
146
+
147
+ export declare type WeaveSelection = {
148
+ instance: default_2.Shape | default_2.Group;
149
+ node: WeaveStateElement;
150
+ };
151
+
152
+ export declare type WeaveState = {
153
+ weave: {
154
+ key: 'stage';
155
+ type: 'stage';
156
+ props: {
157
+ [key: string]: unknown;
158
+ id: 'stage';
159
+ children: WeaveStateElement[];
160
+ };
161
+ } | Record<string, WeaveStateElement>;
162
+ };
163
+
164
+ export declare type WeaveStateElement = {
165
+ key: string;
166
+ type: string;
167
+ props: WeaveElementAttributes;
168
+ };
169
+
170
+ export declare type WeaveStatus = (typeof WEAVE_INSTANCE_STATUS)[WeaveStatusKeys];
171
+
172
+ export declare type WeaveStatusKeys = keyof typeof WEAVE_INSTANCE_STATUS;
173
+
174
+ export declare interface WeaveStoreBase {
175
+ connect(): void;
176
+ disconnect(): void;
177
+ onAwarenessChange<K extends string, T>(callback: (changes: WeaveAwarenessChange<K, T>[]) => void): void;
178
+ setAwarenessInfo(field: string, value: unknown): void;
179
+ }
180
+
181
+ export declare type WeaveStoreOptions = {
182
+ getUser: () => WeaveUser;
183
+ undoManagerOptions?: WeaveUndoManagerOptions;
184
+ };
185
+
186
+ export declare type WeaveUndoManagerOptions = {
187
+ captureTimeout?: number;
188
+ trackedOrigins?: Set<any>;
189
+ };
190
+
191
+ export declare type WeaveUndoRedoChange = {
192
+ canRedo: boolean;
193
+ canUndo: boolean;
194
+ redoStackLength: number;
195
+ undoStackLength: number;
196
+ };
197
+
198
+ export declare type WeaveUser = {
199
+ name: string;
200
+ email: string;
201
+ };
202
+
203
+ export { }
package/dist/types.js ADDED
@@ -0,0 +1,30 @@
1
+ const E = "mainLayer", n = {
2
+ IDLE: "idle",
3
+ STARTING: "starting",
4
+ LOADING_FONTS: "loadingFonts",
5
+ RUNNING: "running"
6
+ }, A = {
7
+ UP: "up",
8
+ DOWN: "down",
9
+ FRONT: "front",
10
+ BACK: "back"
11
+ }, T = "white", O = {
12
+ PNG: "image/png",
13
+ JPEG: "image/jpeg"
14
+ }, _ = {
15
+ "image/png": ".png",
16
+ "image/jpeg": ".jpg"
17
+ }, e = {
18
+ CREATE: "create",
19
+ UPDATE: "update",
20
+ DELETE: "delete"
21
+ };
22
+ export {
23
+ e as STATE_ACTIONS,
24
+ T as WEAVE_EXPORT_BACKGROUND_COLOR,
25
+ _ as WEAVE_EXPORT_FILE_FORMAT,
26
+ O as WEAVE_EXPORT_FORMATS,
27
+ n as WEAVE_INSTANCE_STATUS,
28
+ E as WEAVE_NODE_LAYER_ID,
29
+ A as WEAVE_NODE_POSITION
30
+ };
Binary file
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "@inditextech/weave-types",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "license": "Apache-2.0",
6
+ "author": "Jesus Manuel Piñeiro Cid <jesusmpc@inditex.com>",
7
+ "homepage": "https://inditextech.github.io/weavejs",
8
+ "repository": "github:InditexTech/weavejs",
9
+ "maintainers": [
10
+ {
11
+ "name": "Jesus Manuel Piñeiro Cid",
12
+ "email": "jesusmpc@inditex.com"
13
+ }
14
+ ],
15
+ "exports": {
16
+ "import": "./dist/types.js",
17
+ "require": "./dist/types.cjs"
18
+ },
19
+ "types": "dist/types.d.ts",
20
+ "files": [
21
+ "dist"
22
+ ],
23
+ "scripts": {
24
+ "build:snapshot": "vite build --mode=development --sourcemap --emptyOutDir",
25
+ "build": "vite build --mode=production --minify --emptyOutDir",
26
+ "bump:snapshot": "npm version $npm_package_version.$(date \"+%s\")",
27
+ "bundle:analyze": "vite-bundle-visualizer",
28
+ "check": "echo \"Monorepo test script\" && exit 0",
29
+ "dev": "vite build --watch",
30
+ "dist:tag": "npm dist-tag add \"$(jq -r .name package.json)@$(jq -r .version package.json)\" \"$PR_TAG\" --registry=\"$NPM_PUBLISHING_REGISTRY\" --verbose",
31
+ "format": "npm run lint -- --quiet --fix --fix-type layout",
32
+ "link": "npm link",
33
+ "lint:fix": "npm run lint -- --fix",
34
+ "lint": "eslint ./src",
35
+ "publish:snapshot": "npm publish",
36
+ "release:perform": "npm publish --access public",
37
+ "release:prepare": "npm run verify",
38
+ "test": "vitest --typecheck --coverage --watch=false",
39
+ "dev:test": "vitest --typecheck",
40
+ "verify": "npm run lint && npm run test && npm run build",
41
+ "version:development": "npm version $(npm version minor)-SNAPSHOT",
42
+ "version:release": "npm version $RELEASE_VERSION -m \"[npm-scripts] prepare release $RELEASE_VERSION\" --tag-version-prefix \"\""
43
+ },
44
+ "devDependencies": {
45
+ "@typescript-eslint/eslint-plugin": "8.26.0",
46
+ "@typescript-eslint/parser": "8.26.0",
47
+ "@vitest/coverage-v8": "1.6.0",
48
+ "@vitest/ui": "1.6.0",
49
+ "eslint": "8.57.1",
50
+ "eslint-plugin-react": "7.34.1",
51
+ "eslint-plugin-react-hooks": "^4.6.2",
52
+ "typescript-eslint": "8.22.0",
53
+ "vite": "5.2.9",
54
+ "vite-bundle-visualizer": "1.1.0",
55
+ "vite-plugin-compression2": "1.0.0",
56
+ "vite-plugin-dts": "4.0.3",
57
+ "vitest": "1.6.0",
58
+ "vitest-sonar-reporter": "2.0.0"
59
+ },
60
+ "engines": {
61
+ "node": "^18.12 || ^20.11 || ^22.11",
62
+ "npm": ">= 8.19.x"
63
+ }
64
+ }