@sealpixel/react 1.0.0-rc.11 → 1.0.0-rc.13
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/dist/index.d.ts +6 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +47 -10
- package/dist/index.js.map +1 -1
- package/package.json +11 -6
package/dist/index.d.ts
CHANGED
|
@@ -3,11 +3,7 @@ import { type EditorSession, type ExportResult, type SealpixelError, type Sessio
|
|
|
3
3
|
import { SealpixelEditor as SealpixelEditorElement } from '@sealpixel/element';
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
export type { EditorSession, SessionOptions, SessionState } from '@sealpixel/core';
|
|
6
|
-
|
|
7
|
-
* `<SealpixelEditor>` for React 18 and 19. Props map to the element's properties.
|
|
8
|
-
* Controlled: pass `editLog` and `onChange`; uncontrolled: `defaultEditLog`.
|
|
9
|
-
*/
|
|
10
|
-
export declare const SealpixelEditor: import("@lit/react").ReactWebComponent<SealpixelEditorElement, {
|
|
6
|
+
declare const LitSealpixelEditor: import("@lit/react").ReactWebComponent<SealpixelEditorElement, {
|
|
11
7
|
onChange: EventName<CustomEvent<{
|
|
12
8
|
log: unknown;
|
|
13
9
|
index: number;
|
|
@@ -17,6 +13,11 @@ export declare const SealpixelEditor: import("@lit/react").ReactWebComponent<Sea
|
|
|
17
13
|
onReady: EventName<CustomEvent<void>>;
|
|
18
14
|
onLoad: EventName<CustomEvent<SourceDescriptor>>;
|
|
19
15
|
}>;
|
|
16
|
+
/**
|
|
17
|
+
* `<SealpixelEditor>` for React 18 and 19. Props map to the element's properties.
|
|
18
|
+
* Controlled: pass `editLog` and `onChange`; uncontrolled: `defaultEditLog`.
|
|
19
|
+
*/
|
|
20
|
+
export declare const SealpixelEditor: typeof LitSealpixelEditor;
|
|
20
21
|
export type SealpixelEditorProps = React.ComponentProps<typeof SealpixelEditor>;
|
|
21
22
|
/**
|
|
22
23
|
* Headless use: one session per component instance, state via
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACtB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,eAAe,IAAI,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC/E,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEnF
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACtB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,eAAe,IAAI,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC/E,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEnF,QAAA,MAAM,kBAAkB;cAKY,SAAS,CAAC,WAAW,CAAC;QAAE,GAAG,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;eACrD,SAAS,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;aACxC,SAAS,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;aACtC,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;YAC9B,SAAS,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC;EAEtE,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,OAAO,kBA0BnC,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,CAAC;AAGhF;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,cAAc,GAAG;IAC5D,OAAO,EAAE,aAAa,CAAC;IACvB,KAAK,EAAE,YAAY,CAAC;CACrB,CAwBA"}
|
package/dist/index.js
CHANGED
|
@@ -2,11 +2,7 @@ import { createComponent } from '@lit/react';
|
|
|
2
2
|
import { createEditorSession, } from '@sealpixel/core';
|
|
3
3
|
import { SealpixelEditor as SealpixelEditorElement } from '@sealpixel/element';
|
|
4
4
|
import * as React from 'react';
|
|
5
|
-
|
|
6
|
-
* `<SealpixelEditor>` for React 18 and 19. Props map to the element's properties.
|
|
7
|
-
* Controlled: pass `editLog` and `onChange`; uncontrolled: `defaultEditLog`.
|
|
8
|
-
*/
|
|
9
|
-
export const SealpixelEditor = createComponent({
|
|
5
|
+
const LitSealpixelEditor = createComponent({
|
|
10
6
|
react: React,
|
|
11
7
|
tagName: 'sealpixel-editor',
|
|
12
8
|
elementClass: SealpixelEditorElement,
|
|
@@ -18,17 +14,58 @@ export const SealpixelEditor = createComponent({
|
|
|
18
14
|
onLoad: 'sealpixel:load',
|
|
19
15
|
},
|
|
20
16
|
});
|
|
17
|
+
/**
|
|
18
|
+
* `<SealpixelEditor>` for React 18 and 19. Props map to the element's properties.
|
|
19
|
+
* Controlled: pass `editLog` and `onChange`; uncontrolled: `defaultEditLog`.
|
|
20
|
+
*/
|
|
21
|
+
export const SealpixelEditor = React.forwardRef(function SealpixelEditor(props, ref) {
|
|
22
|
+
const { onReady } = props;
|
|
23
|
+
const element = React.useRef(null);
|
|
24
|
+
const announced = React.useRef(null);
|
|
25
|
+
const setRef = React.useCallback((node) => {
|
|
26
|
+
element.current = node;
|
|
27
|
+
if (typeof ref === 'function')
|
|
28
|
+
ref(node);
|
|
29
|
+
else if (ref)
|
|
30
|
+
ref.current = node;
|
|
31
|
+
}, [ref]);
|
|
32
|
+
// The element creates its session and fires `sealpixel:ready` when React
|
|
33
|
+
// inserts it. @lit/react attaches listeners later, in a layout effect, so
|
|
34
|
+
// that first event reaches nobody. This layout effect runs after the child's
|
|
35
|
+
// and delivers it once per element.
|
|
36
|
+
React.useLayoutEffect(() => {
|
|
37
|
+
const node = element.current;
|
|
38
|
+
if (!node || announced.current === node)
|
|
39
|
+
return;
|
|
40
|
+
announced.current = node;
|
|
41
|
+
if (node.isConnected)
|
|
42
|
+
onReady?.(new CustomEvent('sealpixel:ready'));
|
|
43
|
+
}, [onReady]);
|
|
44
|
+
return React.createElement(LitSealpixelEditor, { ...props, ref: setRef });
|
|
45
|
+
});
|
|
21
46
|
// #region headless
|
|
22
47
|
/**
|
|
23
48
|
* Headless use: one session per component instance, state via
|
|
24
49
|
* `useSyncExternalStore`. Dispose happens on unmount.
|
|
25
50
|
*/
|
|
26
51
|
export function useSealpixelSession(options) {
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
React.useEffect(() =>
|
|
52
|
+
const [session, setSession] = React.useState(() => createEditorSession(options));
|
|
53
|
+
const disposed = React.useRef(null);
|
|
54
|
+
const latestOptions = React.useRef(options);
|
|
55
|
+
latestOptions.current = options;
|
|
56
|
+
React.useEffect(() => {
|
|
57
|
+
// StrictMode, and a component that React hides and shows again, run the
|
|
58
|
+
// cleanup and then this effect again. The disposed session cannot be used
|
|
59
|
+
// again, so replace it.
|
|
60
|
+
if (disposed.current === session) {
|
|
61
|
+
setSession(createEditorSession(latestOptions.current));
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
return () => {
|
|
65
|
+
disposed.current = session;
|
|
66
|
+
session.dispose();
|
|
67
|
+
};
|
|
68
|
+
}, [session]);
|
|
32
69
|
const state = React.useSyncExternalStore((listener) => session.subscribe(() => listener()), () => session.getState(), () => session.getState());
|
|
33
70
|
return { session, state };
|
|
34
71
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAkB,MAAM,YAAY,CAAC;AAC7D,OAAO,EACL,mBAAmB,GAOpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,eAAe,IAAI,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC/E,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAkB,MAAM,YAAY,CAAC;AAC7D,OAAO,EACL,mBAAmB,GAOpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,eAAe,IAAI,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC/E,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,MAAM,kBAAkB,GAAG,eAAe,CAAC;IACzC,KAAK,EAAE,KAAK;IACZ,OAAO,EAAE,kBAAkB;IAC3B,YAAY,EAAE,sBAAsB;IACpC,MAAM,EAAE;QACN,QAAQ,EAAE,kBAA6E;QACvF,SAAS,EAAE,mBAA2D;QACtE,OAAO,EAAE,iBAA2D;QACpE,OAAO,EAAE,iBAAiD;QAC1D,MAAM,EAAE,gBAA4D;KACrE;CACF,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAA8B,KAAK,CAAC,UAAU,CAGxE,SAAS,eAAe,CAAC,KAAK,EAAE,GAAG;IACnC,MAAM,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;IAC1B,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAgC,IAA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,CAAC,OAAO,CAAC,CAAC;IAC5C,aAAa,CAAC,OAAO,GAAG,OAAO,CAAC;IAChC,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,wEAAwE;QACxE,0EAA0E;QAC1E,wBAAwB;QACxB,IAAI,QAAQ,CAAC,OAAO,KAAK,OAAO,EAAE,CAAC;YACjC,UAAU,CAAC,mBAAmB,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;YACvD,OAAO;QACT,CAAC;QACD,OAAO,GAAG,EAAE;YACV,QAAQ,CAAC,OAAO,GAAG,OAAO,CAAC;YAC3B,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IACd,MAAM,KAAK,GAAG,KAAK,CAAC,oBAAoB,CACtC,CAAC,QAAQ,EAAE,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,EACjD,GAAG,EAAE,CAAC,OAAO,CAAC,QAAQ,EAAE,EACxB,GAAG,EAAE,CAAC,OAAO,CAAC,QAAQ,EAAE,CACzB,CAAC;IACF,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AAC5B,CAAC;AACD,sBAAsB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sealpixel/react",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.13",
|
|
4
4
|
"description": "React bindings for the Sealpixel image editor: <SealpixelEditor> with controlled and uncontrolled edit logs, and useSealpixelSession for headless use.",
|
|
5
5
|
"license": "BUSL-1.1",
|
|
6
6
|
"repository": {
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@lit/react": "^1.0.8",
|
|
28
|
-
"@sealpixel/core": "1.0.0-rc.
|
|
29
|
-
"@sealpixel/element": "1.0.0-rc.
|
|
30
|
-
"@sealpixel/ui": "1.0.0-rc.
|
|
28
|
+
"@sealpixel/core": "1.0.0-rc.13",
|
|
29
|
+
"@sealpixel/element": "1.0.0-rc.13",
|
|
30
|
+
"@sealpixel/ui": "1.0.0-rc.13"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"react": "^18.0.0 || ^19.0.0"
|
|
@@ -36,11 +36,16 @@
|
|
|
36
36
|
"@sealpixel/config": "0.0.0",
|
|
37
37
|
"@types/node": "^24.0.0",
|
|
38
38
|
"@types/react": "^19.0.0",
|
|
39
|
+
"@types/react-dom": "^19.0.0",
|
|
40
|
+
"happy-dom": "^20.0.0",
|
|
39
41
|
"react": "^19.0.0",
|
|
40
|
-
"
|
|
42
|
+
"react-dom": "^19.0.0",
|
|
43
|
+
"typescript": "^6.0.0",
|
|
44
|
+
"vitest": "^5.0.0"
|
|
41
45
|
},
|
|
42
46
|
"scripts": {
|
|
43
47
|
"build": "tsc -p tsconfig.build.json",
|
|
44
|
-
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
48
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
49
|
+
"test": "vitest run"
|
|
45
50
|
}
|
|
46
51
|
}
|