@effect/platform-browser 0.49.6 → 0.50.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/dist/cjs/Clipboard.js +62 -6
- package/dist/cjs/Clipboard.js.map +1 -1
- package/dist/dts/Clipboard.d.ts +43 -13
- package/dist/dts/Clipboard.d.ts.map +1 -1
- package/dist/dts/Geolocation.d.ts +1 -1
- package/dist/esm/Clipboard.js +59 -5
- package/dist/esm/Clipboard.js.map +1 -1
- package/package.json +3 -3
- package/src/Clipboard.ts +96 -17
- package/dist/cjs/internal/clipboard.js +0 -65
- package/dist/cjs/internal/clipboard.js.map +0 -1
- package/dist/dts/internal/clipboard.d.ts +0 -2
- package/dist/dts/internal/clipboard.d.ts.map +0 -1
- package/dist/esm/internal/clipboard.js +0 -56
- package/dist/esm/internal/clipboard.js.map +0 -1
- package/src/internal/clipboard.ts +0 -71
package/dist/cjs/Clipboard.js
CHANGED
|
@@ -3,8 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.make = exports.layer = exports.Clipboard = void 0;
|
|
7
|
-
var
|
|
6
|
+
exports.make = exports.layer = exports.TypeId = exports.ErrorTypeId = exports.ClipboardError = exports.Clipboard = void 0;
|
|
7
|
+
var _Error = require("@effect/platform/Error");
|
|
8
|
+
var Context = _interopRequireWildcard(require("effect/Context"));
|
|
9
|
+
var Effect = _interopRequireWildcard(require("effect/Effect"));
|
|
10
|
+
var Layer = _interopRequireWildcard(require("effect/Layer"));
|
|
8
11
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
9
12
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
10
13
|
/**
|
|
@@ -13,19 +16,72 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
13
16
|
|
|
14
17
|
/**
|
|
15
18
|
* @since 1.0.0
|
|
16
|
-
* @category
|
|
19
|
+
* @category type ids
|
|
20
|
+
*/
|
|
21
|
+
const TypeId = exports.TypeId = /*#__PURE__*/Symbol.for("@effect/platform-browser/Clipboard");
|
|
22
|
+
/**
|
|
23
|
+
* @since 1.0.0
|
|
24
|
+
* @category type ids
|
|
25
|
+
*/
|
|
26
|
+
const ErrorTypeId = exports.ErrorTypeId = /*#__PURE__*/Symbol.for("@effect/platform-browser/Clipboard/ClipboardError");
|
|
27
|
+
/**
|
|
28
|
+
* @since 1.0.0
|
|
29
|
+
* @category errors
|
|
17
30
|
*/
|
|
18
|
-
|
|
31
|
+
class ClipboardError extends /*#__PURE__*/(0, _Error.TypeIdError)(ErrorTypeId, "ClipboardError") {}
|
|
19
32
|
/**
|
|
20
33
|
* @since 1.0.0
|
|
21
34
|
* @category tag
|
|
22
35
|
*/
|
|
23
|
-
|
|
36
|
+
exports.ClipboardError = ClipboardError;
|
|
37
|
+
const Clipboard = exports.Clipboard = /*#__PURE__*/Context.GenericTag("@effect/platform-browser/Clipboard");
|
|
38
|
+
/**
|
|
39
|
+
* @since 1.0.0
|
|
40
|
+
* @category constructor
|
|
41
|
+
*/
|
|
42
|
+
const make = impl => Clipboard.of({
|
|
43
|
+
...impl,
|
|
44
|
+
[TypeId]: TypeId,
|
|
45
|
+
clear: impl.writeString(""),
|
|
46
|
+
writeBlob: blob => impl.write([new ClipboardItem({
|
|
47
|
+
[blob.type]: blob
|
|
48
|
+
})])
|
|
49
|
+
});
|
|
24
50
|
/**
|
|
25
51
|
* A layer that directly interfaces with the navigator.clipboard api
|
|
26
52
|
*
|
|
27
53
|
* @since 1.0.0
|
|
28
54
|
* @category layers
|
|
29
55
|
*/
|
|
30
|
-
|
|
56
|
+
exports.make = make;
|
|
57
|
+
const layer = exports.layer = /*#__PURE__*/Layer.succeed(Clipboard, /*#__PURE__*/make({
|
|
58
|
+
read: /*#__PURE__*/Effect.tryPromise({
|
|
59
|
+
try: () => navigator.clipboard.read(),
|
|
60
|
+
catch: cause => new ClipboardError({
|
|
61
|
+
cause,
|
|
62
|
+
"message": "Unable to read from clipboard"
|
|
63
|
+
})
|
|
64
|
+
}),
|
|
65
|
+
write: s => Effect.tryPromise({
|
|
66
|
+
try: () => navigator.clipboard.write(s),
|
|
67
|
+
catch: cause => new ClipboardError({
|
|
68
|
+
cause,
|
|
69
|
+
"message": "Unable to write to clipboard"
|
|
70
|
+
})
|
|
71
|
+
}),
|
|
72
|
+
readString: /*#__PURE__*/Effect.tryPromise({
|
|
73
|
+
try: () => navigator.clipboard.readText(),
|
|
74
|
+
catch: cause => new ClipboardError({
|
|
75
|
+
cause,
|
|
76
|
+
"message": "Unable to read a string from clipboard"
|
|
77
|
+
})
|
|
78
|
+
}),
|
|
79
|
+
writeString: text => Effect.tryPromise({
|
|
80
|
+
try: () => navigator.clipboard.writeText(text),
|
|
81
|
+
catch: cause => new ClipboardError({
|
|
82
|
+
cause,
|
|
83
|
+
"message": "Unable to write a string to clipboard"
|
|
84
|
+
})
|
|
85
|
+
})
|
|
86
|
+
}));
|
|
31
87
|
//# sourceMappingURL=Clipboard.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Clipboard.js","names":["
|
|
1
|
+
{"version":3,"file":"Clipboard.js","names":["_Error","require","Context","_interopRequireWildcard","Effect","Layer","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","TypeId","exports","Symbol","for","ErrorTypeId","ClipboardError","TypeIdError","Clipboard","GenericTag","make","impl","of","clear","writeString","writeBlob","blob","write","ClipboardItem","type","layer","succeed","read","tryPromise","try","navigator","clipboard","catch","cause","s","readString","readText","text","writeText"],"sources":["../../src/Clipboard.ts"],"sourcesContent":[null],"mappings":";;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,uBAAA,CAAAF,OAAA;AACA,IAAAG,MAAA,GAAAD,uBAAA,CAAAF,OAAA;AACA,IAAAI,KAAA,GAAAF,uBAAA,CAAAF,OAAA;AAAqC,SAAAK,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAJ,wBAAAI,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,CAAA,SAAAG,CAAA,GAAAP,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAAc,CAAA,UAAAG,CAAA,KAAAA,CAAA,CAAAV,GAAA,IAAAU,CAAA,C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AC4C,UAAU,CAAC;IACtBC,GAAG,EAAEA,CAAA,KAAMC,SAAS,CAACC,SAAS,CAACJ,IAAI,EAAE;IACrCK,KAAK,EAAGC,KAAK,IACX,IAAItB,cAAc,CAAC;MACjBsB,KAAK;MACL,SAAS,EAAE;KACZ;GACJ,CAAC;EACFX,KAAK,EAAGY,CAAuB,IAC7BlD,MAAM,CAAC4C,UAAU,CAAC;IAChBC,GAAG,EAAEA,CAAA,KAAMC,SAAS,CAACC,SAAS,CAACT,KAAK,CAACY,CAAC,CAAC;IACvCF,KAAK,EAAGC,KAAK,IACX,IAAItB,cAAc,CAAC;MACjBsB,KAAK;MACL,SAAS,EAAE;KACZ;GACJ,CAAC;EACJE,UAAU,eAAEnD,MAAM,CAAC4C,UAAU,CAAC;IAC5BC,GAAG,EAAEA,CAAA,KAAMC,SAAS,CAACC,SAAS,CAACK,QAAQ,EAAE;IACzCJ,KAAK,EAAGC,KAAK,IACX,IAAItB,cAAc,CAAC;MACjBsB,KAAK;MACL,SAAS,EAAE;KACZ;GACJ,CAAC;EACFd,WAAW,EAAGkB,IAAY,IACxBrD,MAAM,CAAC4C,UAAU,CAAC;IAChBC,GAAG,EAAEA,CAAA,KAAMC,SAAS,CAACC,SAAS,CAACO,SAAS,CAACD,IAAI,CAAC;IAC9CL,KAAK,EAAGC,KAAK,IACX,IAAItB,cAAc,CAAC;MACjBsB,KAAK;MACL,SAAS,EAAE;KACZ;GACJ;CACJ,CAAC,CACH","ignoreList":[]}
|
package/dist/dts/Clipboard.d.ts
CHANGED
|
@@ -1,32 +1,61 @@
|
|
|
1
|
+
import * as Context from "effect/Context";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Layer from "effect/Layer";
|
|
1
4
|
/**
|
|
2
5
|
* @since 1.0.0
|
|
6
|
+
* @category type ids
|
|
3
7
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
export declare const TypeId: unique symbol;
|
|
9
|
+
/**
|
|
10
|
+
* @since 1.0.0
|
|
11
|
+
* @category type ids
|
|
12
|
+
*/
|
|
13
|
+
export type TypeId = typeof TypeId;
|
|
8
14
|
/**
|
|
9
15
|
* @since 1.0.0
|
|
10
16
|
* @category interface
|
|
11
17
|
*/
|
|
12
18
|
export interface Clipboard {
|
|
13
|
-
readonly
|
|
14
|
-
readonly
|
|
15
|
-
readonly
|
|
16
|
-
readonly
|
|
17
|
-
readonly
|
|
18
|
-
readonly
|
|
19
|
+
readonly [TypeId]: TypeId;
|
|
20
|
+
readonly read: Effect.Effect<ClipboardItems, ClipboardError>;
|
|
21
|
+
readonly readString: Effect.Effect<string, ClipboardError>;
|
|
22
|
+
readonly write: (items: ClipboardItems) => Effect.Effect<void, ClipboardError>;
|
|
23
|
+
readonly writeString: (text: string) => Effect.Effect<void, ClipboardError>;
|
|
24
|
+
readonly writeBlob: (blob: Blob) => Effect.Effect<void, ClipboardError>;
|
|
25
|
+
readonly clear: Effect.Effect<void, ClipboardError>;
|
|
19
26
|
}
|
|
20
27
|
/**
|
|
21
28
|
* @since 1.0.0
|
|
22
|
-
* @category
|
|
29
|
+
* @category type ids
|
|
23
30
|
*/
|
|
24
|
-
export declare const
|
|
31
|
+
export declare const ErrorTypeId: unique symbol;
|
|
32
|
+
/**
|
|
33
|
+
* @since 1.0.0
|
|
34
|
+
* @category type ids
|
|
35
|
+
*/
|
|
36
|
+
export type ErrorTypeId = typeof ErrorTypeId;
|
|
37
|
+
declare const ClipboardError_base: new <A extends Record<string, any>>(args: import("effect/Types").Simplify<A>) => import("effect/Cause").YieldableError & Record<typeof ErrorTypeId, typeof ErrorTypeId> & {
|
|
38
|
+
readonly _tag: "ClipboardError";
|
|
39
|
+
} & Readonly<A>;
|
|
40
|
+
/**
|
|
41
|
+
* @since 1.0.0
|
|
42
|
+
* @category errors
|
|
43
|
+
*/
|
|
44
|
+
export declare class ClipboardError extends ClipboardError_base<{
|
|
45
|
+
readonly message: string;
|
|
46
|
+
readonly cause: unknown;
|
|
47
|
+
}> {
|
|
48
|
+
}
|
|
25
49
|
/**
|
|
26
50
|
* @since 1.0.0
|
|
27
51
|
* @category tag
|
|
28
52
|
*/
|
|
29
|
-
export declare const Clipboard: Tag<Clipboard, Clipboard>;
|
|
53
|
+
export declare const Clipboard: Context.Tag<Clipboard, Clipboard>;
|
|
54
|
+
/**
|
|
55
|
+
* @since 1.0.0
|
|
56
|
+
* @category constructor
|
|
57
|
+
*/
|
|
58
|
+
export declare const make: (impl: Omit<Clipboard, "clear" | "writeBlob" | TypeId>) => Clipboard;
|
|
30
59
|
/**
|
|
31
60
|
* A layer that directly interfaces with the navigator.clipboard api
|
|
32
61
|
*
|
|
@@ -34,4 +63,5 @@ export declare const Clipboard: Tag<Clipboard, Clipboard>;
|
|
|
34
63
|
* @category layers
|
|
35
64
|
*/
|
|
36
65
|
export declare const layer: Layer.Layer<Clipboard>;
|
|
66
|
+
export {};
|
|
37
67
|
//# sourceMappingURL=Clipboard.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Clipboard.d.ts","sourceRoot":"","sources":["../../src/Clipboard.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Clipboard.d.ts","sourceRoot":"","sources":["../../src/Clipboard.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC;;;GAGG;AACH,eAAO,MAAM,MAAM,EAAE,OAAO,MAAyD,CAAA;AAErF;;;GAGG;AACH,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAA;AAElC;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IAEzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE,cAAc,CAAC,C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";
|
|
50
50
|
readonly cause: unknown;
|
|
51
51
|
}> {
|
|
52
|
-
get message(): "
|
|
52
|
+
get message(): "PositionUnavailable" | "PermissionDenied" | "Timeout";
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
55
55
|
* @since 1.0.0
|
package/dist/esm/Clipboard.js
CHANGED
|
@@ -1,22 +1,76 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @since 1.0.0
|
|
3
3
|
*/
|
|
4
|
-
import
|
|
4
|
+
import { TypeIdError } from "@effect/platform/Error";
|
|
5
|
+
import * as Context from "effect/Context";
|
|
6
|
+
import * as Effect from "effect/Effect";
|
|
7
|
+
import * as Layer from "effect/Layer";
|
|
5
8
|
/**
|
|
6
9
|
* @since 1.0.0
|
|
7
|
-
* @category
|
|
10
|
+
* @category type ids
|
|
11
|
+
*/
|
|
12
|
+
export const TypeId = /*#__PURE__*/Symbol.for("@effect/platform-browser/Clipboard");
|
|
13
|
+
/**
|
|
14
|
+
* @since 1.0.0
|
|
15
|
+
* @category type ids
|
|
8
16
|
*/
|
|
9
|
-
export const
|
|
17
|
+
export const ErrorTypeId = /*#__PURE__*/Symbol.for("@effect/platform-browser/Clipboard/ClipboardError");
|
|
18
|
+
/**
|
|
19
|
+
* @since 1.0.0
|
|
20
|
+
* @category errors
|
|
21
|
+
*/
|
|
22
|
+
export class ClipboardError extends /*#__PURE__*/TypeIdError(ErrorTypeId, "ClipboardError") {}
|
|
10
23
|
/**
|
|
11
24
|
* @since 1.0.0
|
|
12
25
|
* @category tag
|
|
13
26
|
*/
|
|
14
|
-
export const Clipboard =
|
|
27
|
+
export const Clipboard = /*#__PURE__*/Context.GenericTag("@effect/platform-browser/Clipboard");
|
|
28
|
+
/**
|
|
29
|
+
* @since 1.0.0
|
|
30
|
+
* @category constructor
|
|
31
|
+
*/
|
|
32
|
+
export const make = impl => Clipboard.of({
|
|
33
|
+
...impl,
|
|
34
|
+
[TypeId]: TypeId,
|
|
35
|
+
clear: impl.writeString(""),
|
|
36
|
+
writeBlob: blob => impl.write([new ClipboardItem({
|
|
37
|
+
[blob.type]: blob
|
|
38
|
+
})])
|
|
39
|
+
});
|
|
15
40
|
/**
|
|
16
41
|
* A layer that directly interfaces with the navigator.clipboard api
|
|
17
42
|
*
|
|
18
43
|
* @since 1.0.0
|
|
19
44
|
* @category layers
|
|
20
45
|
*/
|
|
21
|
-
export const layer =
|
|
46
|
+
export const layer = /*#__PURE__*/Layer.succeed(Clipboard, /*#__PURE__*/make({
|
|
47
|
+
read: /*#__PURE__*/Effect.tryPromise({
|
|
48
|
+
try: () => navigator.clipboard.read(),
|
|
49
|
+
catch: cause => new ClipboardError({
|
|
50
|
+
cause,
|
|
51
|
+
"message": "Unable to read from clipboard"
|
|
52
|
+
})
|
|
53
|
+
}),
|
|
54
|
+
write: s => Effect.tryPromise({
|
|
55
|
+
try: () => navigator.clipboard.write(s),
|
|
56
|
+
catch: cause => new ClipboardError({
|
|
57
|
+
cause,
|
|
58
|
+
"message": "Unable to write to clipboard"
|
|
59
|
+
})
|
|
60
|
+
}),
|
|
61
|
+
readString: /*#__PURE__*/Effect.tryPromise({
|
|
62
|
+
try: () => navigator.clipboard.readText(),
|
|
63
|
+
catch: cause => new ClipboardError({
|
|
64
|
+
cause,
|
|
65
|
+
"message": "Unable to read a string from clipboard"
|
|
66
|
+
})
|
|
67
|
+
}),
|
|
68
|
+
writeString: text => Effect.tryPromise({
|
|
69
|
+
try: () => navigator.clipboard.writeText(text),
|
|
70
|
+
catch: cause => new ClipboardError({
|
|
71
|
+
cause,
|
|
72
|
+
"message": "Unable to write a string to clipboard"
|
|
73
|
+
})
|
|
74
|
+
})
|
|
75
|
+
}));
|
|
22
76
|
//# sourceMappingURL=Clipboard.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Clipboard.js","names":["
|
|
1
|
+
{"version":3,"file":"Clipboard.js","names":["TypeIdError","Context","Effect","Layer","TypeId","Symbol","for","ErrorTypeId","ClipboardError","Clipboard","GenericTag","make","impl","of","clear","writeString","writeBlob","blob","write","ClipboardItem","type","layer","succeed","read","tryPromise","try","navigator","clipboard","catch","cause","s","readString","readText","text","writeText"],"sources":["../../src/Clipboard.ts"],"sourcesContent":[null],"mappings":"AAAA;;;AAGA,SAASA,WAAW,QAAQ,wBAAwB;AACpD,OAAO,KAAKC,OAAO,MAAM,gBAAgB;AACzC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,KAAK,MAAM,cAAc;AAErC;;;;AAIA,OAAO,MAAMC,MAAM,gBAAkBC,MAAM,CAACC,GAAG,CAAC,oCAAoC,CAAC;AAuBrF;;;;AAIA,OAAO,MAAMC,WAAW,gBAAkBF,MAAM,CAACC,GAAG,CAAC,mDAAmD,CAAC;AAQzG;;;;AAIA,OAAM,MAAOE,cAAe,sBAAQR,WAAW,CAACO,WAAW,EAAE,gBAAgB,CAG3E;AAEF;;;;AAIA,OAAO,MAAME,SAAS,gBAAsCR,OAAO,CAACS,UAAU,CAC5E,oCAAoC,CACrC;AAED;;;;AAIA,OAAO,MAAMC,IAAI,GACfC,IAAqD,IAErDH,SAAS,CAACI,EAAE,CAAC;EACX,GAAGD,IAAI;EACP,CAACR,MAAM,GAAGA,MAAM;EAChBU,KAAK,EAAEF,IAAI,CAACG,WAAW,CAAC,EAAE,CAAC;EAC3BC,SAAS,EAAGC,IAAU,IAAKL,IAAI,CAACM,KAAK,CAAC,CAAC,IAAIC,aAAa,CAAC;IAAE,CAACF,IAAI,CAACG,IAAI,GAAGH;EAAI,CAAE,CAAC,CAAC;CACjF,CAAC;AAEJ;;;;;;AAMA,OAAO,MAAMI,KAAK,gBAA2BlB,KAAK,CAACmB,OAAO,CACxDb,SAAS,eACTE,IAAI,CAAC;EACHY,IAAI,eAAErB,MAAM,CAACsB,UAAU,CAAC;IACtBC,GAAG,EAAEA,CAAA,KAAMC,SAAS,CAACC,SAAS,CAACJ,IAAI,EAAE;IACrCK,KAAK,EAAGC,KAAK,IACX,IAAIrB,cAAc,CAAC;MACjBqB,KAAK;MACL,SAAS,EAAE;KACZ;GACJ,CAAC;EACFX,KAAK,EAAGY,CAAuB,IAC7B5B,MAAM,CAACsB,UAAU,CAAC;IAChBC,GAAG,EAAEA,CAAA,KAAMC,SAAS,CAACC,SAAS,CAACT,KAAK,CAACY,CAAC,CAAC;IACvCF,KAAK,EAAGC,KAAK,IACX,IAAIrB,cAAc,CAAC;MACjBqB,KAAK;MACL,SAAS,EAAE;KACZ;GACJ,CAAC;EACJE,UAAU,eAAE7B,MAAM,CAACsB,UAAU,CAAC;IAC5BC,GAAG,EAAEA,CAAA,KAAMC,SAAS,CAACC,SAAS,CAACK,QAAQ,EAAE;IACzCJ,KAAK,EAAGC,KAAK,IACX,IAAIrB,cAAc,CAAC;MACjBqB,KAAK;MACL,SAAS,EAAE;KACZ;GACJ,CAAC;EACFd,WAAW,EAAGkB,IAAY,IACxB/B,MAAM,CAACsB,UAAU,CAAC;IAChBC,GAAG,EAAEA,CAAA,KAAMC,SAAS,CAACC,SAAS,CAACO,SAAS,CAACD,IAAI,CAAC;IAC9CL,KAAK,EAAGC,KAAK,IACX,IAAIrB,cAAc,CAAC;MACjBqB,KAAK;MACL,SAAS,EAAE;KACZ;GACJ;CACJ,CAAC,CACH","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effect/platform-browser",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.50.0",
|
|
4
4
|
"description": "Platform specific implementations for the browser",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"multipasta": "^0.2.5"
|
|
14
14
|
},
|
|
15
15
|
"peerDependencies": {
|
|
16
|
-
"@effect/platform": "^0.
|
|
17
|
-
"effect": "^3.11.
|
|
16
|
+
"@effect/platform": "^0.71.0",
|
|
17
|
+
"effect": "^3.11.6"
|
|
18
18
|
},
|
|
19
19
|
"publishConfig": {
|
|
20
20
|
"provenance": true
|
package/src/Clipboard.ts
CHANGED
|
@@ -1,39 +1,80 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @since 1.0.0
|
|
3
3
|
*/
|
|
4
|
+
import { TypeIdError } from "@effect/platform/Error"
|
|
5
|
+
import * as Context from "effect/Context"
|
|
6
|
+
import * as Effect from "effect/Effect"
|
|
7
|
+
import * as Layer from "effect/Layer"
|
|
4
8
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
/**
|
|
10
|
+
* @since 1.0.0
|
|
11
|
+
* @category type ids
|
|
12
|
+
*/
|
|
13
|
+
export const TypeId: unique symbol = Symbol.for("@effect/platform-browser/Clipboard")
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @since 1.0.0
|
|
17
|
+
* @category type ids
|
|
18
|
+
*/
|
|
19
|
+
export type TypeId = typeof TypeId
|
|
10
20
|
|
|
11
21
|
/**
|
|
12
22
|
* @since 1.0.0
|
|
13
23
|
* @category interface
|
|
14
24
|
*/
|
|
15
25
|
export interface Clipboard {
|
|
16
|
-
readonly
|
|
17
|
-
|
|
18
|
-
readonly
|
|
19
|
-
readonly
|
|
20
|
-
readonly
|
|
21
|
-
readonly
|
|
26
|
+
readonly [TypeId]: TypeId
|
|
27
|
+
|
|
28
|
+
readonly read: Effect.Effect<ClipboardItems, ClipboardError>
|
|
29
|
+
readonly readString: Effect.Effect<string, ClipboardError>
|
|
30
|
+
readonly write: (items: ClipboardItems) => Effect.Effect<void, ClipboardError>
|
|
31
|
+
readonly writeString: (text: string) => Effect.Effect<void, ClipboardError>
|
|
32
|
+
readonly writeBlob: (blob: Blob) => Effect.Effect<void, ClipboardError>
|
|
33
|
+
readonly clear: Effect.Effect<void, ClipboardError>
|
|
22
34
|
}
|
|
23
35
|
|
|
24
36
|
/**
|
|
25
37
|
* @since 1.0.0
|
|
26
|
-
* @category
|
|
38
|
+
* @category type ids
|
|
39
|
+
*/
|
|
40
|
+
export const ErrorTypeId: unique symbol = Symbol.for("@effect/platform-browser/Clipboard/ClipboardError")
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @since 1.0.0
|
|
44
|
+
* @category type ids
|
|
45
|
+
*/
|
|
46
|
+
export type ErrorTypeId = typeof ErrorTypeId
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @since 1.0.0
|
|
50
|
+
* @category errors
|
|
27
51
|
*/
|
|
28
|
-
export
|
|
29
|
-
|
|
30
|
-
|
|
52
|
+
export class ClipboardError extends TypeIdError(ErrorTypeId, "ClipboardError")<{
|
|
53
|
+
readonly message: string
|
|
54
|
+
readonly cause: unknown
|
|
55
|
+
}> {}
|
|
31
56
|
|
|
32
57
|
/**
|
|
33
58
|
* @since 1.0.0
|
|
34
59
|
* @category tag
|
|
35
60
|
*/
|
|
36
|
-
export const Clipboard: Tag<Clipboard, Clipboard> =
|
|
61
|
+
export const Clipboard: Context.Tag<Clipboard, Clipboard> = Context.GenericTag<Clipboard>(
|
|
62
|
+
"@effect/platform-browser/Clipboard"
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @since 1.0.0
|
|
67
|
+
* @category constructor
|
|
68
|
+
*/
|
|
69
|
+
export const make = (
|
|
70
|
+
impl: Omit<Clipboard, "clear" | "writeBlob" | TypeId>
|
|
71
|
+
): Clipboard =>
|
|
72
|
+
Clipboard.of({
|
|
73
|
+
...impl,
|
|
74
|
+
[TypeId]: TypeId,
|
|
75
|
+
clear: impl.writeString(""),
|
|
76
|
+
writeBlob: (blob: Blob) => impl.write([new ClipboardItem({ [blob.type]: blob })])
|
|
77
|
+
})
|
|
37
78
|
|
|
38
79
|
/**
|
|
39
80
|
* A layer that directly interfaces with the navigator.clipboard api
|
|
@@ -41,4 +82,42 @@ export const Clipboard: Tag<Clipboard, Clipboard> = internal.tag
|
|
|
41
82
|
* @since 1.0.0
|
|
42
83
|
* @category layers
|
|
43
84
|
*/
|
|
44
|
-
export const layer: Layer.Layer<Clipboard> =
|
|
85
|
+
export const layer: Layer.Layer<Clipboard> = Layer.succeed(
|
|
86
|
+
Clipboard,
|
|
87
|
+
make({
|
|
88
|
+
read: Effect.tryPromise({
|
|
89
|
+
try: () => navigator.clipboard.read(),
|
|
90
|
+
catch: (cause) =>
|
|
91
|
+
new ClipboardError({
|
|
92
|
+
cause,
|
|
93
|
+
"message": "Unable to read from clipboard"
|
|
94
|
+
})
|
|
95
|
+
}),
|
|
96
|
+
write: (s: Array<ClipboardItem>) =>
|
|
97
|
+
Effect.tryPromise({
|
|
98
|
+
try: () => navigator.clipboard.write(s),
|
|
99
|
+
catch: (cause) =>
|
|
100
|
+
new ClipboardError({
|
|
101
|
+
cause,
|
|
102
|
+
"message": "Unable to write to clipboard"
|
|
103
|
+
})
|
|
104
|
+
}),
|
|
105
|
+
readString: Effect.tryPromise({
|
|
106
|
+
try: () => navigator.clipboard.readText(),
|
|
107
|
+
catch: (cause) =>
|
|
108
|
+
new ClipboardError({
|
|
109
|
+
cause,
|
|
110
|
+
"message": "Unable to read a string from clipboard"
|
|
111
|
+
})
|
|
112
|
+
}),
|
|
113
|
+
writeString: (text: string) =>
|
|
114
|
+
Effect.tryPromise({
|
|
115
|
+
try: () => navigator.clipboard.writeText(text),
|
|
116
|
+
catch: (cause) =>
|
|
117
|
+
new ClipboardError({
|
|
118
|
+
cause,
|
|
119
|
+
"message": "Unable to write a string to clipboard"
|
|
120
|
+
})
|
|
121
|
+
})
|
|
122
|
+
})
|
|
123
|
+
)
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.tag = exports.make = exports.layer = void 0;
|
|
7
|
-
var PlatformError = _interopRequireWildcard(require("@effect/platform/Error"));
|
|
8
|
-
var _Context = require("effect/Context");
|
|
9
|
-
var Effect = _interopRequireWildcard(require("effect/Effect"));
|
|
10
|
-
var Layer = _interopRequireWildcard(require("effect/Layer"));
|
|
11
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
12
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
13
|
-
/** @internal */
|
|
14
|
-
const tag = exports.tag = /*#__PURE__*/(0, _Context.GenericTag)("@effect/platform-browser/Clipboard");
|
|
15
|
-
/** @internal */
|
|
16
|
-
const make = impl => tag.of({
|
|
17
|
-
...impl,
|
|
18
|
-
clear: impl.writeString(""),
|
|
19
|
-
writeBlob: blob => impl.write([new ClipboardItem({
|
|
20
|
-
[blob.type]: blob
|
|
21
|
-
})])
|
|
22
|
-
});
|
|
23
|
-
/** @internal */
|
|
24
|
-
exports.make = make;
|
|
25
|
-
const clipboardError = props => PlatformError.SystemError({
|
|
26
|
-
reason: "PermissionDenied",
|
|
27
|
-
module: "Clipboard",
|
|
28
|
-
...props
|
|
29
|
-
});
|
|
30
|
-
/** @internal */
|
|
31
|
-
const layer = exports.layer = /*#__PURE__*/Layer.succeed(tag, /*#__PURE__*/make({
|
|
32
|
-
read: /*#__PURE__*/Effect.tryPromise({
|
|
33
|
-
try: () => navigator.clipboard.read(),
|
|
34
|
-
catch: () => clipboardError({
|
|
35
|
-
"message": "Unable to read from clipboard",
|
|
36
|
-
"method": "read",
|
|
37
|
-
"pathOrDescriptor": "layer"
|
|
38
|
-
})
|
|
39
|
-
}),
|
|
40
|
-
write: s => Effect.tryPromise({
|
|
41
|
-
try: () => navigator.clipboard.write(s),
|
|
42
|
-
catch: () => clipboardError({
|
|
43
|
-
"message": "Unable to write to clipboard",
|
|
44
|
-
"method": "write",
|
|
45
|
-
"pathOrDescriptor": "layer"
|
|
46
|
-
})
|
|
47
|
-
}),
|
|
48
|
-
readString: /*#__PURE__*/Effect.tryPromise({
|
|
49
|
-
try: () => navigator.clipboard.readText(),
|
|
50
|
-
catch: () => clipboardError({
|
|
51
|
-
"message": "Unable to read a string from clipboard",
|
|
52
|
-
"method": "readString",
|
|
53
|
-
"pathOrDescriptor": "layer"
|
|
54
|
-
})
|
|
55
|
-
}),
|
|
56
|
-
writeString: text => Effect.tryPromise({
|
|
57
|
-
try: () => navigator.clipboard.writeText(text),
|
|
58
|
-
catch: () => clipboardError({
|
|
59
|
-
"message": "Unable to write a string to clipboard",
|
|
60
|
-
"method": "writeString",
|
|
61
|
-
"pathOrDescriptor": "layer"
|
|
62
|
-
})
|
|
63
|
-
})
|
|
64
|
-
}));
|
|
65
|
-
//# sourceMappingURL=clipboard.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"clipboard.js","names":["PlatformError","_interopRequireWildcard","require","_Context","Effect","Layer","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","tag","exports","GenericTag","make","impl","of","clear","writeString","writeBlob","blob","write","ClipboardItem","type","clipboardError","props","SystemError","reason","module","layer","succeed","read","tryPromise","try","navigator","clipboard","catch","s","readString","readText","text","writeText"],"sources":["../../../src/internal/clipboard.ts"],"sourcesContent":[null],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAH,uBAAA,CAAAC,OAAA;AACA,IAA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AQ,EAAE;IACzCH,KAAK,EAAEA,CAAA,KACLZ,cAAc,CAAC;MACb,SAAS,EAAE,wCAAwC;MACnD,QAAQ,EAAE,YAAY;MACtB,kBAAkB,EAAE;KACrB;GACJ,CAAC;EACFN,WAAW,EAAGsB,IAAY,IACxBnD,MAAM,CAAC2C,UAAU,CAAC;IAChBC,GAAG,EAAEA,CAAA,KAAMC,SAAS,CAACC,SAAS,CAACM,SAAS,CAACD,IAAI,CAAC;IAC9CJ,KAAK,EAAEA,CAAA,KACLZ,cAAc,CAAC;MACb,SAAS,EAAE,uCAAuC;MAClD,QAAQ,EAAE,aAAa;MACvB,kBAAkB,EAAE;KACrB;GACJ;CACJ,CAAC,CACH","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"clipboard.d.ts","sourceRoot":"","sources":["../../../src/internal/clipboard.ts"],"names":[],"mappings":""}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import * as PlatformError from "@effect/platform/Error";
|
|
2
|
-
import { GenericTag } from "effect/Context";
|
|
3
|
-
import * as Effect from "effect/Effect";
|
|
4
|
-
import * as Layer from "effect/Layer";
|
|
5
|
-
/** @internal */
|
|
6
|
-
export const tag = /*#__PURE__*/GenericTag("@effect/platform-browser/Clipboard");
|
|
7
|
-
/** @internal */
|
|
8
|
-
export const make = impl => tag.of({
|
|
9
|
-
...impl,
|
|
10
|
-
clear: impl.writeString(""),
|
|
11
|
-
writeBlob: blob => impl.write([new ClipboardItem({
|
|
12
|
-
[blob.type]: blob
|
|
13
|
-
})])
|
|
14
|
-
});
|
|
15
|
-
/** @internal */
|
|
16
|
-
const clipboardError = props => PlatformError.SystemError({
|
|
17
|
-
reason: "PermissionDenied",
|
|
18
|
-
module: "Clipboard",
|
|
19
|
-
...props
|
|
20
|
-
});
|
|
21
|
-
/** @internal */
|
|
22
|
-
export const layer = /*#__PURE__*/Layer.succeed(tag, /*#__PURE__*/make({
|
|
23
|
-
read: /*#__PURE__*/Effect.tryPromise({
|
|
24
|
-
try: () => navigator.clipboard.read(),
|
|
25
|
-
catch: () => clipboardError({
|
|
26
|
-
"message": "Unable to read from clipboard",
|
|
27
|
-
"method": "read",
|
|
28
|
-
"pathOrDescriptor": "layer"
|
|
29
|
-
})
|
|
30
|
-
}),
|
|
31
|
-
write: s => Effect.tryPromise({
|
|
32
|
-
try: () => navigator.clipboard.write(s),
|
|
33
|
-
catch: () => clipboardError({
|
|
34
|
-
"message": "Unable to write to clipboard",
|
|
35
|
-
"method": "write",
|
|
36
|
-
"pathOrDescriptor": "layer"
|
|
37
|
-
})
|
|
38
|
-
}),
|
|
39
|
-
readString: /*#__PURE__*/Effect.tryPromise({
|
|
40
|
-
try: () => navigator.clipboard.readText(),
|
|
41
|
-
catch: () => clipboardError({
|
|
42
|
-
"message": "Unable to read a string from clipboard",
|
|
43
|
-
"method": "readString",
|
|
44
|
-
"pathOrDescriptor": "layer"
|
|
45
|
-
})
|
|
46
|
-
}),
|
|
47
|
-
writeString: text => Effect.tryPromise({
|
|
48
|
-
try: () => navigator.clipboard.writeText(text),
|
|
49
|
-
catch: () => clipboardError({
|
|
50
|
-
"message": "Unable to write a string to clipboard",
|
|
51
|
-
"method": "writeString",
|
|
52
|
-
"pathOrDescriptor": "layer"
|
|
53
|
-
})
|
|
54
|
-
})
|
|
55
|
-
}));
|
|
56
|
-
//# sourceMappingURL=clipboard.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"clipboard.js","names":["PlatformError","GenericTag","Effect","Layer","tag","make","impl","of","clear","writeString","writeBlob","blob","write","ClipboardItem","type","clipboardError","props","SystemError","reason","module","layer","succeed","read","tryPromise","try","navigator","clipboard","catch","s","readString","readText","text","writeText"],"sources":["../../../src/internal/clipboard.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAO,KAAKA,aAAa,MAAM,wBAAwB;AACvD,SAASC,UAAU,QAAQ,gBAAgB;AAC3C,OAAO,KAAKC,MAAM,MAAM,eAAe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CAAC;IAC5BC,GAAG,EAAEA,CAAA,KAAMC,SAAS,CAACC,SAAS,CAACI,QAAQ,EAAE;IACzCH,KAAK,EAAEA,CAAA,KACLZ,cAAc,CAAC;MACb,SAAS,EAAE,wCAAwC;MACnD,QAAQ,EAAE,YAAY;MACtB,kBAAkB,EAAE;KACrB;GACJ,CAAC;EACFN,WAAW,EAAGsB,IAAY,IACxB7B,MAAM,CAACqB,UAAU,CAAC;IAChBC,GAAG,EAAEA,CAAA,KAAMC,SAAS,CAACC,SAAS,CAACM,SAAS,CAACD,IAAI,CAAC;IAC9CJ,KAAK,EAAEA,CAAA,KACLZ,cAAc,CAAC;MACb,SAAS,EAAE,uCAAuC;MAClD,QAAQ,EAAE,aAAa;MACvB,kBAAkB,EAAE;KACrB;GACJ;CACJ,CAAC,CACH","ignoreList":[]}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import * as PlatformError from "@effect/platform/Error"
|
|
2
|
-
import { GenericTag } from "effect/Context"
|
|
3
|
-
import * as Effect from "effect/Effect"
|
|
4
|
-
import * as Layer from "effect/Layer"
|
|
5
|
-
import type * as Clipboard from "../Clipboard.js"
|
|
6
|
-
|
|
7
|
-
/** @internal */
|
|
8
|
-
export const tag = GenericTag<Clipboard.Clipboard>("@effect/platform-browser/Clipboard")
|
|
9
|
-
|
|
10
|
-
/** @internal */
|
|
11
|
-
export const make = (
|
|
12
|
-
impl: Omit<Clipboard.Clipboard, "clear" | "writeBlob">
|
|
13
|
-
): Clipboard.Clipboard =>
|
|
14
|
-
tag.of({
|
|
15
|
-
...impl,
|
|
16
|
-
clear: impl.writeString(""),
|
|
17
|
-
writeBlob: (blob: Blob) => impl.write([new ClipboardItem({ [blob.type]: blob })])
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
/** @internal */
|
|
21
|
-
const clipboardError = (props: Omit<Parameters<typeof PlatformError.SystemError>[0], "reason" | "module">) =>
|
|
22
|
-
PlatformError.SystemError({
|
|
23
|
-
reason: "PermissionDenied",
|
|
24
|
-
module: "Clipboard",
|
|
25
|
-
...props
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
/** @internal */
|
|
29
|
-
export const layer = Layer.succeed(
|
|
30
|
-
tag,
|
|
31
|
-
make({
|
|
32
|
-
read: Effect.tryPromise({
|
|
33
|
-
try: () => navigator.clipboard.read(),
|
|
34
|
-
catch: () =>
|
|
35
|
-
clipboardError({
|
|
36
|
-
"message": "Unable to read from clipboard",
|
|
37
|
-
"method": "read",
|
|
38
|
-
"pathOrDescriptor": "layer"
|
|
39
|
-
})
|
|
40
|
-
}),
|
|
41
|
-
write: (s: Array<ClipboardItem>) =>
|
|
42
|
-
Effect.tryPromise({
|
|
43
|
-
try: () => navigator.clipboard.write(s),
|
|
44
|
-
catch: () =>
|
|
45
|
-
clipboardError({
|
|
46
|
-
"message": "Unable to write to clipboard",
|
|
47
|
-
"method": "write",
|
|
48
|
-
"pathOrDescriptor": "layer"
|
|
49
|
-
})
|
|
50
|
-
}),
|
|
51
|
-
readString: Effect.tryPromise({
|
|
52
|
-
try: () => navigator.clipboard.readText(),
|
|
53
|
-
catch: () =>
|
|
54
|
-
clipboardError({
|
|
55
|
-
"message": "Unable to read a string from clipboard",
|
|
56
|
-
"method": "readString",
|
|
57
|
-
"pathOrDescriptor": "layer"
|
|
58
|
-
})
|
|
59
|
-
}),
|
|
60
|
-
writeString: (text: string) =>
|
|
61
|
-
Effect.tryPromise({
|
|
62
|
-
try: () => navigator.clipboard.writeText(text),
|
|
63
|
-
catch: () =>
|
|
64
|
-
clipboardError({
|
|
65
|
-
"message": "Unable to write a string to clipboard",
|
|
66
|
-
"method": "writeString",
|
|
67
|
-
"pathOrDescriptor": "layer"
|
|
68
|
-
})
|
|
69
|
-
})
|
|
70
|
-
})
|
|
71
|
-
)
|