@symbiote-native/clipboard 0.1.0 → 0.2.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/build/core/clipboard.js +6 -1
- package/build/svelte/index.d.ts +2 -0
- package/build/svelte/index.js +7 -0
- package/build/svelte/runes/use-clipboard.svelte.d.ts +4 -0
- package/build/svelte/runes/use-clipboard.svelte.js +30 -0
- package/build-ngc/angular/services/clipboard.service/index.js +3 -3
- package/build-ngc/core/clipboard.js +6 -1
- package/build-ngc/core/clipboard.js.map +1 -1
- package/package.json +26 -12
- package/src/core/clipboard.ts +6 -1
- package/src/svelte/index.ts +8 -0
- package/src/svelte/runes/use-clipboard.svelte.ts +33 -0
- package/src/svelte/svelte-ambient.d.ts +6 -0
package/build/core/clipboard.js
CHANGED
|
@@ -36,7 +36,12 @@ export async function setStringAsync(text, options = {}) {
|
|
|
36
36
|
* Returns whether the clipboard has text content. Returns `true` for both plain text and rich
|
|
37
37
|
* text (e.g. HTML).
|
|
38
38
|
*/
|
|
39
|
-
|
|
39
|
+
// DELIBERATE DIVERGENCE from expo: Clipboard.ts:57 declares this one plain `function`, not
|
|
40
|
+
// `async` like its 8 siblings, so on a build without the native method the UnavailabilityError
|
|
41
|
+
// escapes synchronously at the call site and `hasStringAsync().catch(handler)` never catches it.
|
|
42
|
+
// Parity would hand callers a guard that fires differently from every other method in this API,
|
|
43
|
+
// so we add `async` here instead of tagging it. Everything else stays a verbatim port.
|
|
44
|
+
export async function hasStringAsync() {
|
|
40
45
|
if (!expoClipboard.hasStringAsync) {
|
|
41
46
|
throw new UnavailabilityError(NATIVE_MODULE_NAME, 'hasStringAsync');
|
|
42
47
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// @symbiote-native/clipboard/svelte: the Svelte entry over the framework-agnostic core. Unlike
|
|
2
|
+
// @symbiote-native/local-auth (all stateless functions, plain re-export), clipboard has one
|
|
3
|
+
// listener-based piece — useClipboard wires addClipboardListener's lifecycle onto a Svelte
|
|
4
|
+
// `$effect` (runes/use-clipboard.svelte.ts), mirroring the lifecycle-bucket naming convention of
|
|
5
|
+
// adapters/svelte/src/runes (never `hooks/`/`composables/`, those are React's and Vue's terms).
|
|
6
|
+
export { useClipboard } from './runes/use-clipboard.svelte';
|
|
7
|
+
export * from '../core/index.js';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Svelte lifecycle wiring over the framework-agnostic addClipboardListener subscription (core/) —
|
|
2
|
+
// the Svelte twin of vue/composables/use-clipboard and react/hooks/use-clipboard, adjusted for
|
|
3
|
+
// clipboard's single always-on subscription (no per-call config to resubscribe on).
|
|
4
|
+
//
|
|
5
|
+
// `.svelte.ts` (not `.ts`): runes ($state/$effect) are only usable in a file with this extension
|
|
6
|
+
// outside an actual `.svelte` component. `runes/` is Svelte's own term for the bucket React calls
|
|
7
|
+
// `hooks/` and Vue calls `composables/` — see adapters/svelte/src/runes.
|
|
8
|
+
//
|
|
9
|
+
// Vue's onMounted/onUnmounted pair collapses into ONE `$effect` whose returned function is the
|
|
10
|
+
// teardown. The effect only WRITES `event`, never reads it, so its dependency set stays empty: it
|
|
11
|
+
// subscribes exactly once on mount and removes the subscription exactly once on unmount.
|
|
12
|
+
//
|
|
13
|
+
// Returns a boxed getter object, NOT a bare `$state`: Svelte 5 reactivity is lexically scoped to
|
|
14
|
+
// the declaring module, so a raw `let x = $state(...)` handed out of a plain function arrives
|
|
15
|
+
// dead at the caller. `.current` is the Svelte equivalent of unwrapping Vue's `Ref` via `.value`.
|
|
16
|
+
import { addClipboardListener } from '../../core/index.js';
|
|
17
|
+
export function useClipboard() {
|
|
18
|
+
let event = $state(null);
|
|
19
|
+
$effect(() => {
|
|
20
|
+
const subscription = addClipboardListener(next => {
|
|
21
|
+
event = next;
|
|
22
|
+
});
|
|
23
|
+
return () => subscription.remove();
|
|
24
|
+
});
|
|
25
|
+
return {
|
|
26
|
+
get current() {
|
|
27
|
+
return event;
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
@@ -26,10 +26,10 @@ export class ClipboardService {
|
|
|
26
26
|
}, { injector: this.injector });
|
|
27
27
|
return event.asReadonly();
|
|
28
28
|
}
|
|
29
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.
|
|
30
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.
|
|
29
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: ClipboardService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
30
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: ClipboardService, providedIn: 'root' });
|
|
31
31
|
}
|
|
32
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.
|
|
32
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: ClipboardService, decorators: [{
|
|
33
33
|
type: Injectable,
|
|
34
34
|
args: [{ providedIn: 'root' }]
|
|
35
35
|
}] });
|
|
@@ -36,7 +36,12 @@ export async function setStringAsync(text, options = {}) {
|
|
|
36
36
|
* Returns whether the clipboard has text content. Returns `true` for both plain text and rich
|
|
37
37
|
* text (e.g. HTML).
|
|
38
38
|
*/
|
|
39
|
-
|
|
39
|
+
// DELIBERATE DIVERGENCE from expo: Clipboard.ts:57 declares this one plain `function`, not
|
|
40
|
+
// `async` like its 8 siblings, so on a build without the native method the UnavailabilityError
|
|
41
|
+
// escapes synchronously at the call site and `hasStringAsync().catch(handler)` never catches it.
|
|
42
|
+
// Parity would hand callers a guard that fires differently from every other method in this API,
|
|
43
|
+
// so we add `async` here instead of tagging it. Everything else stays a verbatim port.
|
|
44
|
+
export async function hasStringAsync() {
|
|
40
45
|
if (!expoClipboard.hasStringAsync) {
|
|
41
46
|
throw new UnavailabilityError(NATIVE_MODULE_NAME, 'hasStringAsync');
|
|
42
47
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clipboard.js","sourceRoot":"","sources":["../../src/core/clipboard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAGxD,OAAO,EAAE,4BAA4B,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAS9E,2FAA2F;AAC3F,MAAM,kBAAkB,GAAG,WAAW,CAAC;AAEvC;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,UAA6B,EAAE;IAClE,IAAI,CAAC,aAAa,CAAC,cAAc,EAAE,CAAC;QAClC,MAAM,IAAI,mBAAmB,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAC;IACtE,CAAC;IACD,OAAO,aAAa,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;AAC/C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,IAAY,EACZ,UAA6B,EAAE;IAE/B,IAAI,CAAC,aAAa,CAAC,cAAc,EAAE,CAAC;QAClC,MAAM,IAAI,mBAAmB,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAC;IACtE,CAAC;IACD,OAAO,aAAa,CAAC,cAAc,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACrD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc;
|
|
1
|
+
{"version":3,"file":"clipboard.js","sourceRoot":"","sources":["../../src/core/clipboard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAGxD,OAAO,EAAE,4BAA4B,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAS9E,2FAA2F;AAC3F,MAAM,kBAAkB,GAAG,WAAW,CAAC;AAEvC;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC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CAAC,MAAM,EAAE,CAAC;AACxB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbiote-native/clipboard",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "expo-clipboard wrapped for SymbioteNative — one framework-agnostic core, built once and reachable from the React, Vue, and Angular adapters. Reads and writes clipboard text, URLs, and images, plus a clipboard-change listener.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -30,6 +30,10 @@
|
|
|
30
30
|
"types": "./build/react/index.d.ts",
|
|
31
31
|
"default": "./build/react/index.js"
|
|
32
32
|
},
|
|
33
|
+
"./svelte": {
|
|
34
|
+
"types": "./build/svelte/index.d.ts",
|
|
35
|
+
"default": "./build/svelte/index.js"
|
|
36
|
+
},
|
|
33
37
|
"./angular": {
|
|
34
38
|
"types": "./build-ngc/angular/index.d.ts",
|
|
35
39
|
"react-native": "./build-ngc/angular/index.js",
|
|
@@ -53,15 +57,17 @@
|
|
|
53
57
|
"expo-modules-core": "57.0.5"
|
|
54
58
|
},
|
|
55
59
|
"peerDependencies": {
|
|
60
|
+
"@symbiote-native/angular": ">=0.6.2",
|
|
56
61
|
"@symbiote-native/engine": ">=0.1.7",
|
|
62
|
+
"@symbiote-native/react": ">=0.2.8",
|
|
63
|
+
"@symbiote-native/svelte": ">=0.1.0",
|
|
64
|
+
"@symbiote-native/vue": ">=0.3.8",
|
|
57
65
|
"@angular/core": ">=20",
|
|
58
66
|
"@vue/runtime-core": "^3.5.13",
|
|
59
67
|
"react": ">=19.0.0",
|
|
60
68
|
"react-native": ">=0.86",
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"@symbiote-native/react": "0.2.8",
|
|
64
|
-
"@symbiote-native/vue": "0.3.8"
|
|
69
|
+
"svelte": ">=5.56.0",
|
|
70
|
+
"vue": ">=3.5.0"
|
|
65
71
|
},
|
|
66
72
|
"peerDependenciesMeta": {
|
|
67
73
|
"@symbiote-native/angular": {
|
|
@@ -70,6 +76,9 @@
|
|
|
70
76
|
"@symbiote-native/react": {
|
|
71
77
|
"optional": true
|
|
72
78
|
},
|
|
79
|
+
"@symbiote-native/svelte": {
|
|
80
|
+
"optional": true
|
|
81
|
+
},
|
|
73
82
|
"@symbiote-native/vue": {
|
|
74
83
|
"optional": true
|
|
75
84
|
},
|
|
@@ -82,24 +91,29 @@
|
|
|
82
91
|
"react": {
|
|
83
92
|
"optional": true
|
|
84
93
|
},
|
|
94
|
+
"svelte": {
|
|
95
|
+
"optional": true
|
|
96
|
+
},
|
|
85
97
|
"vue": {
|
|
86
98
|
"optional": true
|
|
87
99
|
}
|
|
88
100
|
},
|
|
89
101
|
"devDependencies": {
|
|
90
|
-
"@angular/compiler": "
|
|
91
|
-
"@angular/compiler-cli": "
|
|
92
|
-
"@angular/core": "
|
|
102
|
+
"@angular/compiler": "~22.0.8",
|
|
103
|
+
"@angular/compiler-cli": "~22.0.8",
|
|
104
|
+
"@angular/core": "~22.0.8",
|
|
93
105
|
"@types/node": "^26.0.0",
|
|
94
106
|
"@types/react": "^19.2.0",
|
|
95
107
|
"@vue/runtime-core": "^3.5.13",
|
|
96
108
|
"react": "19.2.3",
|
|
109
|
+
"svelte": "^5.56.0",
|
|
97
110
|
"typescript": "~6.0.0",
|
|
98
|
-
"@symbiote-native/angular": "0.
|
|
99
|
-
"@symbiote-native/engine": "0.
|
|
100
|
-
"@symbiote-native/react": "0.
|
|
111
|
+
"@symbiote-native/angular": "0.7.0",
|
|
112
|
+
"@symbiote-native/engine": "0.2.0",
|
|
113
|
+
"@symbiote-native/react": "0.3.0",
|
|
114
|
+
"@symbiote-native/svelte": "0.2.0",
|
|
101
115
|
"@symbiote-native/test-utils": "0.1.6",
|
|
102
|
-
"@symbiote-native/vue": "0.
|
|
116
|
+
"@symbiote-native/vue": "0.4.0"
|
|
103
117
|
},
|
|
104
118
|
"scripts": {
|
|
105
119
|
"typecheck": "tsc --build",
|
package/src/core/clipboard.ts
CHANGED
|
@@ -52,7 +52,12 @@ export async function setStringAsync(
|
|
|
52
52
|
* Returns whether the clipboard has text content. Returns `true` for both plain text and rich
|
|
53
53
|
* text (e.g. HTML).
|
|
54
54
|
*/
|
|
55
|
-
|
|
55
|
+
// DELIBERATE DIVERGENCE from expo: Clipboard.ts:57 declares this one plain `function`, not
|
|
56
|
+
// `async` like its 8 siblings, so on a build without the native method the UnavailabilityError
|
|
57
|
+
// escapes synchronously at the call site and `hasStringAsync().catch(handler)` never catches it.
|
|
58
|
+
// Parity would hand callers a guard that fires differently from every other method in this API,
|
|
59
|
+
// so we add `async` here instead of tagging it. Everything else stays a verbatim port.
|
|
60
|
+
export async function hasStringAsync(): Promise<boolean> {
|
|
56
61
|
if (!expoClipboard.hasStringAsync) {
|
|
57
62
|
throw new UnavailabilityError(NATIVE_MODULE_NAME, 'hasStringAsync');
|
|
58
63
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// @symbiote-native/clipboard/svelte: the Svelte entry over the framework-agnostic core. Unlike
|
|
2
|
+
// @symbiote-native/local-auth (all stateless functions, plain re-export), clipboard has one
|
|
3
|
+
// listener-based piece — useClipboard wires addClipboardListener's lifecycle onto a Svelte
|
|
4
|
+
// `$effect` (runes/use-clipboard.svelte.ts), mirroring the lifecycle-bucket naming convention of
|
|
5
|
+
// adapters/svelte/src/runes (never `hooks/`/`composables/`, those are React's and Vue's terms).
|
|
6
|
+
|
|
7
|
+
export { useClipboard } from './runes/use-clipboard.svelte';
|
|
8
|
+
export * from '../core';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Svelte lifecycle wiring over the framework-agnostic addClipboardListener subscription (core/) —
|
|
2
|
+
// the Svelte twin of vue/composables/use-clipboard and react/hooks/use-clipboard, adjusted for
|
|
3
|
+
// clipboard's single always-on subscription (no per-call config to resubscribe on).
|
|
4
|
+
//
|
|
5
|
+
// `.svelte.ts` (not `.ts`): runes ($state/$effect) are only usable in a file with this extension
|
|
6
|
+
// outside an actual `.svelte` component. `runes/` is Svelte's own term for the bucket React calls
|
|
7
|
+
// `hooks/` and Vue calls `composables/` — see adapters/svelte/src/runes.
|
|
8
|
+
//
|
|
9
|
+
// Vue's onMounted/onUnmounted pair collapses into ONE `$effect` whose returned function is the
|
|
10
|
+
// teardown. The effect only WRITES `event`, never reads it, so its dependency set stays empty: it
|
|
11
|
+
// subscribes exactly once on mount and removes the subscription exactly once on unmount.
|
|
12
|
+
//
|
|
13
|
+
// Returns a boxed getter object, NOT a bare `$state`: Svelte 5 reactivity is lexically scoped to
|
|
14
|
+
// the declaring module, so a raw `let x = $state(...)` handed out of a plain function arrives
|
|
15
|
+
// dead at the caller. `.current` is the Svelte equivalent of unwrapping Vue's `Ref` via `.value`.
|
|
16
|
+
import { addClipboardListener, type EventSubscription, type IClipboardEvent } from '../../core';
|
|
17
|
+
|
|
18
|
+
export function useClipboard(): { readonly current: IClipboardEvent | null } {
|
|
19
|
+
let event = $state<IClipboardEvent | null>(null);
|
|
20
|
+
|
|
21
|
+
$effect(() => {
|
|
22
|
+
const subscription: EventSubscription = addClipboardListener(next => {
|
|
23
|
+
event = next;
|
|
24
|
+
});
|
|
25
|
+
return () => subscription.remove();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
get current(): IClipboardEvent | null {
|
|
30
|
+
return event;
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Pulls in svelte's ambient global declarations ($state/$effect/...) for this package's tsc
|
|
2
|
+
// program. adapters/svelte gets these for free because render.ts does a real value import from
|
|
3
|
+
// 'svelte' (any file in a program importing a module loads its ambient globals for the whole
|
|
4
|
+
// program); this package has no such import, so a triple-slash reference does the same job
|
|
5
|
+
// explicitly rather than relying on an incidental side-effect.
|
|
6
|
+
/// <reference types="svelte" />
|