@sealpixel/react 1.0.0-rc.21 → 1.0.0-rc.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.
- package/dist/index.js +1 -25
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -18,31 +18,7 @@ const LitSealpixelEditor = createComponent({
|
|
|
18
18
|
* `<SealpixelEditor>` for React 18 and 19. Props map to the element's properties.
|
|
19
19
|
* Controlled: pass `editLog` and `onChange`; uncontrolled: `defaultEditLog`.
|
|
20
20
|
*/
|
|
21
|
-
export const SealpixelEditor =
|
|
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
|
+
export const SealpixelEditor = LitSealpixelEditor;
|
|
46
22
|
// #region headless
|
|
47
23
|
/**
|
|
48
24
|
* Headless use: one session per component instance, state via
|
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,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,
|
|
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,kBAAkB,CAAC;AAI7E,mBAAmB;AACnB;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAuB;IAIzD,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC,CAAC;IACjF,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAuB,IAAI,CAAC,CAAC;IAC1D,MAAM,aAAa,GAAG,KAAK,CAAC,MAAM,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","sourcesContent":["import { createComponent, type EventName } from '@lit/react';\nimport {\n createEditorSession,\n type EditorSession,\n type ExportResult,\n type SealpixelError,\n type SessionOptions,\n type SessionState,\n type SourceDescriptor,\n} from '@sealpixel/core';\nimport { SealpixelEditor as SealpixelEditorElement } from '@sealpixel/element';\nimport * as React from 'react';\n\nexport type { EditorSession, SessionOptions, SessionState } from '@sealpixel/core';\n\nconst LitSealpixelEditor = createComponent({\n react: React,\n tagName: 'sealpixel-editor',\n elementClass: SealpixelEditorElement,\n events: {\n onChange: 'sealpixel:change' as EventName<CustomEvent<{ log: unknown; index: number }>>,\n onProcess: 'sealpixel:process' as EventName<CustomEvent<ExportResult>>,\n onError: 'sealpixel:error' as EventName<CustomEvent<SealpixelError>>,\n onReady: 'sealpixel:ready' as EventName<CustomEvent<void>>,\n onLoad: 'sealpixel:load' as EventName<CustomEvent<SourceDescriptor>>,\n },\n});\n\n/**\n * `<SealpixelEditor>` for React 18 and 19. Props map to the element's properties.\n * Controlled: pass `editLog` and `onChange`; uncontrolled: `defaultEditLog`.\n */\nexport const SealpixelEditor: typeof LitSealpixelEditor = LitSealpixelEditor;\n\nexport type SealpixelEditorProps = React.ComponentProps<typeof SealpixelEditor>;\n\n// #region headless\n/**\n * Headless use: one session per component instance, state via\n * `useSyncExternalStore`. Dispose happens on unmount.\n */\nexport function useSealpixelSession(options: SessionOptions): {\n session: EditorSession;\n state: SessionState;\n} {\n const [session, setSession] = React.useState(() => createEditorSession(options));\n const disposed = React.useRef<EditorSession | null>(null);\n const latestOptions = React.useRef(options);\n latestOptions.current = options;\n React.useEffect(() => {\n // StrictMode, and a component that React hides and shows again, run the\n // cleanup and then this effect again. The disposed session cannot be used\n // again, so replace it.\n if (disposed.current === session) {\n setSession(createEditorSession(latestOptions.current));\n return;\n }\n return () => {\n disposed.current = session;\n session.dispose();\n };\n }, [session]);\n const state = React.useSyncExternalStore(\n (listener) => session.subscribe(() => listener()),\n () => session.getState(),\n () => session.getState(),\n );\n return { session, state };\n}\n// #endregion headless\n"]}
|
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.22",
|
|
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.22",
|
|
29
|
+
"@sealpixel/element": "1.0.0-rc.22",
|
|
30
|
+
"@sealpixel/ui": "1.0.0-rc.22"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"react": "^18.0.0 || ^19.0.0"
|