@atlaskit/townsquare-emoji-provider 1.0.1
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/CHANGELOG.md +1 -0
- package/LICENSE.md +11 -0
- package/README.md +10 -0
- package/dist/cjs/provider.js +40 -0
- package/dist/cjs/withSelectedToneEmitter.js +68 -0
- package/dist/es2019/provider.js +32 -0
- package/dist/es2019/withSelectedToneEmitter.js +39 -0
- package/dist/esm/provider.js +33 -0
- package/dist/esm/withSelectedToneEmitter.js +61 -0
- package/dist/types/provider.d.ts +4 -0
- package/dist/types/withSelectedToneEmitter.d.ts +2 -0
- package/dist/types-ts4.5/provider.d.ts +4 -0
- package/dist/types-ts4.5/withSelectedToneEmitter.d.ts +2 -0
- package/package.json +67 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# @atlaskit/townsquare-emoji-provider
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Copyright 2023 Atlassian Pty Ltd
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
|
|
4
|
+
compliance with the License. You may obtain a copy of the License at
|
|
5
|
+
|
|
6
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
|
|
8
|
+
Unless required by applicable law or agreed to in writing, software distributed under the License is
|
|
9
|
+
distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
10
|
+
implied. See the License for the specific language governing permissions and limitations under the
|
|
11
|
+
License.
|
package/README.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# TownsquareEmojiProvider
|
|
2
|
+
|
|
3
|
+
Townsquare emoji provider
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
`import { getEmojiProviderForCloudId } from '@atlaskit/townsquare-emoji-provider';`
|
|
8
|
+
|
|
9
|
+
Detailed docs and example usage can be found
|
|
10
|
+
[here](https://atlaskit.atlassian.com/packages/townsquare/townsquare-emoji-provider).
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.getEmojiProviderForCloudId = exports.emojiResource = exports.emojiProvider = void 0;
|
|
8
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
+
var _resource = require("@atlaskit/emoji/resource");
|
|
10
|
+
var _withSelectedToneEmitter = require("./withSelectedToneEmitter");
|
|
11
|
+
var EMOJI_URL = '/gateway/api/emoji';
|
|
12
|
+
var DEFAULT_EMOJI_CONFIG = {
|
|
13
|
+
providers: [{
|
|
14
|
+
url: "".concat(EMOJI_URL, "/standard")
|
|
15
|
+
}]
|
|
16
|
+
};
|
|
17
|
+
var emojiResource = exports.emojiResource = new _resource.EmojiResource(DEFAULT_EMOJI_CONFIG);
|
|
18
|
+
var emojiProvider = exports.emojiProvider = (0, _withSelectedToneEmitter.withSelectedToneEmitter)(emojiResource.getEmojiProvider());
|
|
19
|
+
var resources = new Map();
|
|
20
|
+
var getEmojiProviderForCloudId = exports.getEmojiProviderForCloudId = function getEmojiProviderForCloudId(cloudId, userId, disableUpload) {
|
|
21
|
+
var resourceKey = "".concat(cloudId, "::").concat(userId, "::").concat(disableUpload ? 'no-upload' : 'with-upload');
|
|
22
|
+
var resource = resources.get(resourceKey);
|
|
23
|
+
if (resource) {
|
|
24
|
+
return (0, _withSelectedToneEmitter.withSelectedToneEmitter)(resource.getEmojiProvider());
|
|
25
|
+
}
|
|
26
|
+
var emojiConfig = {
|
|
27
|
+
providers: [].concat((0, _toConsumableArray2.default)(DEFAULT_EMOJI_CONFIG.providers), [{
|
|
28
|
+
url: "".concat(EMOJI_URL, "/atlassian")
|
|
29
|
+
}, {
|
|
30
|
+
url: "".concat(EMOJI_URL, "/").concat(cloudId, "/site")
|
|
31
|
+
}]),
|
|
32
|
+
allowUpload: disableUpload ? false : true,
|
|
33
|
+
currentUser: {
|
|
34
|
+
id: userId
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
resource = new _resource.EmojiResource(emojiConfig);
|
|
38
|
+
resources.set(resourceKey, resource);
|
|
39
|
+
return (0, _withSelectedToneEmitter.withSelectedToneEmitter)(resource.getEmojiProvider());
|
|
40
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.withSelectedToneEmitter = void 0;
|
|
8
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
|
+
var DEFAULT_TONE = 0;
|
|
11
|
+
var SELECTED_TONE_CHANGED_EVENT = 'SELECTED_TONE_CHANGED_EVENT';
|
|
12
|
+
function proxySetSelectedTone(emojiProvider) {
|
|
13
|
+
return new Proxy(emojiProvider, {
|
|
14
|
+
get: function get(target, key, receiver) {
|
|
15
|
+
// Look for setSelectedTone property access
|
|
16
|
+
if (key === 'setSelectedTone' && typeof target.setSelectedTone === 'function') {
|
|
17
|
+
// Then apply proxy for the function call
|
|
18
|
+
return new Proxy(target.setSelectedTone, {
|
|
19
|
+
apply: function apply(applyTarget, thisArgs, args) {
|
|
20
|
+
// Execute the tone selection update
|
|
21
|
+
Reflect.apply(applyTarget, thisArgs, args);
|
|
22
|
+
// Emit deferred event
|
|
23
|
+
var tone = args.length > 0 ? args[0] : DEFAULT_TONE;
|
|
24
|
+
setTimeout(function () {
|
|
25
|
+
try {
|
|
26
|
+
window.dispatchEvent(new CustomEvent(SELECTED_TONE_CHANGED_EVENT, {
|
|
27
|
+
detail: {
|
|
28
|
+
tone: tone
|
|
29
|
+
}
|
|
30
|
+
}));
|
|
31
|
+
// eslint-disable-next-line no-unused-vars
|
|
32
|
+
} catch (_error) {
|
|
33
|
+
// TODO(TC-13359): Log warning to Sentry when monitoring is set up
|
|
34
|
+
// logMessage(`[proxySetSelectedTone] Error setting selected tone`, 'warning', {
|
|
35
|
+
// error: _error,
|
|
36
|
+
// selectedTone: tone,
|
|
37
|
+
// });
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
// Everything else, fallback to target directly
|
|
44
|
+
return Reflect.get(target, key, receiver);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
var withSelectedToneEmitter = exports.withSelectedToneEmitter = /*#__PURE__*/function () {
|
|
49
|
+
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(promise) {
|
|
50
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
51
|
+
while (1) switch (_context.prev = _context.next) {
|
|
52
|
+
case 0:
|
|
53
|
+
_context.t0 = proxySetSelectedTone;
|
|
54
|
+
_context.next = 3;
|
|
55
|
+
return promise;
|
|
56
|
+
case 3:
|
|
57
|
+
_context.t1 = _context.sent;
|
|
58
|
+
return _context.abrupt("return", (0, _context.t0)(_context.t1));
|
|
59
|
+
case 5:
|
|
60
|
+
case "end":
|
|
61
|
+
return _context.stop();
|
|
62
|
+
}
|
|
63
|
+
}, _callee);
|
|
64
|
+
}));
|
|
65
|
+
return function withSelectedToneEmitter(_x) {
|
|
66
|
+
return _ref.apply(this, arguments);
|
|
67
|
+
};
|
|
68
|
+
}();
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { EmojiResource } from '@atlaskit/emoji/resource';
|
|
2
|
+
import { withSelectedToneEmitter } from './withSelectedToneEmitter';
|
|
3
|
+
const EMOJI_URL = '/gateway/api/emoji';
|
|
4
|
+
const DEFAULT_EMOJI_CONFIG = {
|
|
5
|
+
providers: [{
|
|
6
|
+
url: `${EMOJI_URL}/standard`
|
|
7
|
+
}]
|
|
8
|
+
};
|
|
9
|
+
export const emojiResource = new EmojiResource(DEFAULT_EMOJI_CONFIG);
|
|
10
|
+
export const emojiProvider = withSelectedToneEmitter(emojiResource.getEmojiProvider());
|
|
11
|
+
const resources = new Map();
|
|
12
|
+
export const getEmojiProviderForCloudId = (cloudId, userId, disableUpload) => {
|
|
13
|
+
const resourceKey = `${cloudId}::${userId}::${disableUpload ? 'no-upload' : 'with-upload'}`;
|
|
14
|
+
let resource = resources.get(resourceKey);
|
|
15
|
+
if (resource) {
|
|
16
|
+
return withSelectedToneEmitter(resource.getEmojiProvider());
|
|
17
|
+
}
|
|
18
|
+
const emojiConfig = {
|
|
19
|
+
providers: [...DEFAULT_EMOJI_CONFIG.providers, {
|
|
20
|
+
url: `${EMOJI_URL}/atlassian`
|
|
21
|
+
}, {
|
|
22
|
+
url: `${EMOJI_URL}/${cloudId}/site`
|
|
23
|
+
}],
|
|
24
|
+
allowUpload: disableUpload ? false : true,
|
|
25
|
+
currentUser: {
|
|
26
|
+
id: userId
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
resource = new EmojiResource(emojiConfig);
|
|
30
|
+
resources.set(resourceKey, resource);
|
|
31
|
+
return withSelectedToneEmitter(resource.getEmojiProvider());
|
|
32
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const DEFAULT_TONE = 0;
|
|
2
|
+
const SELECTED_TONE_CHANGED_EVENT = 'SELECTED_TONE_CHANGED_EVENT';
|
|
3
|
+
function proxySetSelectedTone(emojiProvider) {
|
|
4
|
+
return new Proxy(emojiProvider, {
|
|
5
|
+
get(target, key, receiver) {
|
|
6
|
+
// Look for setSelectedTone property access
|
|
7
|
+
if (key === 'setSelectedTone' && typeof target.setSelectedTone === 'function') {
|
|
8
|
+
// Then apply proxy for the function call
|
|
9
|
+
return new Proxy(target.setSelectedTone, {
|
|
10
|
+
apply(applyTarget, thisArgs, args) {
|
|
11
|
+
// Execute the tone selection update
|
|
12
|
+
Reflect.apply(applyTarget, thisArgs, args);
|
|
13
|
+
// Emit deferred event
|
|
14
|
+
const tone = args.length > 0 ? args[0] : DEFAULT_TONE;
|
|
15
|
+
setTimeout(() => {
|
|
16
|
+
try {
|
|
17
|
+
window.dispatchEvent(new CustomEvent(SELECTED_TONE_CHANGED_EVENT, {
|
|
18
|
+
detail: {
|
|
19
|
+
tone
|
|
20
|
+
}
|
|
21
|
+
}));
|
|
22
|
+
// eslint-disable-next-line no-unused-vars
|
|
23
|
+
} catch (_error) {
|
|
24
|
+
// TODO(TC-13359): Log warning to Sentry when monitoring is set up
|
|
25
|
+
// logMessage(`[proxySetSelectedTone] Error setting selected tone`, 'warning', {
|
|
26
|
+
// error: _error,
|
|
27
|
+
// selectedTone: tone,
|
|
28
|
+
// });
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
// Everything else, fallback to target directly
|
|
35
|
+
return Reflect.get(target, key, receiver);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
export const withSelectedToneEmitter = async promise => proxySetSelectedTone(await promise);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import { EmojiResource } from '@atlaskit/emoji/resource';
|
|
3
|
+
import { withSelectedToneEmitter } from './withSelectedToneEmitter';
|
|
4
|
+
var EMOJI_URL = '/gateway/api/emoji';
|
|
5
|
+
var DEFAULT_EMOJI_CONFIG = {
|
|
6
|
+
providers: [{
|
|
7
|
+
url: "".concat(EMOJI_URL, "/standard")
|
|
8
|
+
}]
|
|
9
|
+
};
|
|
10
|
+
export var emojiResource = new EmojiResource(DEFAULT_EMOJI_CONFIG);
|
|
11
|
+
export var emojiProvider = withSelectedToneEmitter(emojiResource.getEmojiProvider());
|
|
12
|
+
var resources = new Map();
|
|
13
|
+
export var getEmojiProviderForCloudId = function getEmojiProviderForCloudId(cloudId, userId, disableUpload) {
|
|
14
|
+
var resourceKey = "".concat(cloudId, "::").concat(userId, "::").concat(disableUpload ? 'no-upload' : 'with-upload');
|
|
15
|
+
var resource = resources.get(resourceKey);
|
|
16
|
+
if (resource) {
|
|
17
|
+
return withSelectedToneEmitter(resource.getEmojiProvider());
|
|
18
|
+
}
|
|
19
|
+
var emojiConfig = {
|
|
20
|
+
providers: [].concat(_toConsumableArray(DEFAULT_EMOJI_CONFIG.providers), [{
|
|
21
|
+
url: "".concat(EMOJI_URL, "/atlassian")
|
|
22
|
+
}, {
|
|
23
|
+
url: "".concat(EMOJI_URL, "/").concat(cloudId, "/site")
|
|
24
|
+
}]),
|
|
25
|
+
allowUpload: disableUpload ? false : true,
|
|
26
|
+
currentUser: {
|
|
27
|
+
id: userId
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
resource = new EmojiResource(emojiConfig);
|
|
31
|
+
resources.set(resourceKey, resource);
|
|
32
|
+
return withSelectedToneEmitter(resource.getEmojiProvider());
|
|
33
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
+
var DEFAULT_TONE = 0;
|
|
4
|
+
var SELECTED_TONE_CHANGED_EVENT = 'SELECTED_TONE_CHANGED_EVENT';
|
|
5
|
+
function proxySetSelectedTone(emojiProvider) {
|
|
6
|
+
return new Proxy(emojiProvider, {
|
|
7
|
+
get: function get(target, key, receiver) {
|
|
8
|
+
// Look for setSelectedTone property access
|
|
9
|
+
if (key === 'setSelectedTone' && typeof target.setSelectedTone === 'function') {
|
|
10
|
+
// Then apply proxy for the function call
|
|
11
|
+
return new Proxy(target.setSelectedTone, {
|
|
12
|
+
apply: function apply(applyTarget, thisArgs, args) {
|
|
13
|
+
// Execute the tone selection update
|
|
14
|
+
Reflect.apply(applyTarget, thisArgs, args);
|
|
15
|
+
// Emit deferred event
|
|
16
|
+
var tone = args.length > 0 ? args[0] : DEFAULT_TONE;
|
|
17
|
+
setTimeout(function () {
|
|
18
|
+
try {
|
|
19
|
+
window.dispatchEvent(new CustomEvent(SELECTED_TONE_CHANGED_EVENT, {
|
|
20
|
+
detail: {
|
|
21
|
+
tone: tone
|
|
22
|
+
}
|
|
23
|
+
}));
|
|
24
|
+
// eslint-disable-next-line no-unused-vars
|
|
25
|
+
} catch (_error) {
|
|
26
|
+
// TODO(TC-13359): Log warning to Sentry when monitoring is set up
|
|
27
|
+
// logMessage(`[proxySetSelectedTone] Error setting selected tone`, 'warning', {
|
|
28
|
+
// error: _error,
|
|
29
|
+
// selectedTone: tone,
|
|
30
|
+
// });
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
// Everything else, fallback to target directly
|
|
37
|
+
return Reflect.get(target, key, receiver);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
export var withSelectedToneEmitter = /*#__PURE__*/function () {
|
|
42
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(promise) {
|
|
43
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
44
|
+
while (1) switch (_context.prev = _context.next) {
|
|
45
|
+
case 0:
|
|
46
|
+
_context.t0 = proxySetSelectedTone;
|
|
47
|
+
_context.next = 3;
|
|
48
|
+
return promise;
|
|
49
|
+
case 3:
|
|
50
|
+
_context.t1 = _context.sent;
|
|
51
|
+
return _context.abrupt("return", (0, _context.t0)(_context.t1));
|
|
52
|
+
case 5:
|
|
53
|
+
case "end":
|
|
54
|
+
return _context.stop();
|
|
55
|
+
}
|
|
56
|
+
}, _callee);
|
|
57
|
+
}));
|
|
58
|
+
return function withSelectedToneEmitter(_x) {
|
|
59
|
+
return _ref.apply(this, arguments);
|
|
60
|
+
};
|
|
61
|
+
}();
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { EmojiResource } from '@atlaskit/emoji/resource';
|
|
2
|
+
export declare const emojiResource: EmojiResource;
|
|
3
|
+
export declare const emojiProvider: Promise<import("@atlaskit/emoji/types").EmojiProvider>;
|
|
4
|
+
export declare const getEmojiProviderForCloudId: (cloudId: string, userId: string, disableUpload?: boolean) => Promise<import("@atlaskit/emoji/types").EmojiProvider>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { EmojiResource } from '@atlaskit/emoji/resource';
|
|
2
|
+
export declare const emojiResource: EmojiResource;
|
|
3
|
+
export declare const emojiProvider: Promise<import("@atlaskit/emoji/types").EmojiProvider>;
|
|
4
|
+
export declare const getEmojiProviderForCloudId: (cloudId: string, userId: string, disableUpload?: boolean) => Promise<import("@atlaskit/emoji/types").EmojiProvider>;
|
package/package.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atlaskit/townsquare-emoji-provider",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Townsquare emoji provider",
|
|
5
|
+
"atlassian": {
|
|
6
|
+
"team": "Townsquare"
|
|
7
|
+
},
|
|
8
|
+
"repository": "https://bitbucket.org/atlassian/atlassian-frontend-monorepo",
|
|
9
|
+
"main": "dist/cjs/provider.js",
|
|
10
|
+
"module": "dist/esm/provider.js",
|
|
11
|
+
"module:es2019": "dist/es2019/provider.js",
|
|
12
|
+
"types": "dist/types/provider.d.ts",
|
|
13
|
+
"typesVersions": {
|
|
14
|
+
">=4.5 <5.9": {
|
|
15
|
+
"*": [
|
|
16
|
+
"dist/types-ts4.5/*",
|
|
17
|
+
"dist/types-ts4.5/index.d.ts"
|
|
18
|
+
]
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"sideEffects": false,
|
|
22
|
+
"atlaskit:src": "src/provider.ts",
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@atlaskit/emoji": "^69.9.0",
|
|
25
|
+
"@babel/runtime": "^7.0.0"
|
|
26
|
+
},
|
|
27
|
+
"techstack": {
|
|
28
|
+
"@atlassian/frontend": {
|
|
29
|
+
"import-structure": [
|
|
30
|
+
"atlassian-conventions"
|
|
31
|
+
],
|
|
32
|
+
"circular-dependencies": [
|
|
33
|
+
"file-and-folder-level"
|
|
34
|
+
]
|
|
35
|
+
},
|
|
36
|
+
"@repo/internal": {
|
|
37
|
+
"dom-events": "use-bind-event-listener",
|
|
38
|
+
"analytics": [
|
|
39
|
+
"analytics-next"
|
|
40
|
+
],
|
|
41
|
+
"design-tokens": [
|
|
42
|
+
"color"
|
|
43
|
+
],
|
|
44
|
+
"theming": [
|
|
45
|
+
"react-context"
|
|
46
|
+
],
|
|
47
|
+
"ui-components": [
|
|
48
|
+
"lite-mode"
|
|
49
|
+
],
|
|
50
|
+
"deprecation": [
|
|
51
|
+
"no-deprecated-imports"
|
|
52
|
+
],
|
|
53
|
+
"styling": [
|
|
54
|
+
"static",
|
|
55
|
+
"compiled"
|
|
56
|
+
],
|
|
57
|
+
"imports": [
|
|
58
|
+
"import-no-extraneous-disable-for-examples-and-docs"
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"author": "Atlassian Pty Ltd",
|
|
63
|
+
"license": "Apache-2.0",
|
|
64
|
+
"publishConfig": {
|
|
65
|
+
"registry": "https://registry.npmjs.org/"
|
|
66
|
+
}
|
|
67
|
+
}
|