@forge/react
11.8.3-next.0-experimental-0c74a4b11.9.0-next.1
+
Added (9 files)
~
Modified (8 files)
Index: package/out/index.js
===================================================================
--- package/out/index.js
+++ package/out/index.js
@@ -1,14 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
-exports.useObjectStore = exports.useForm = exports.replaceUnsupportedDocumentNodes = exports.I18nProvider = exports.useTranslation = exports.useIssueProperty = exports.useSpaceProperty = exports.useContentProperty = exports.default = exports.usePermissions = exports.useConfig = exports.useProductContext = exports.xcss = void 0;
+exports.useObjectStore = exports.useForm = exports.replaceUnsupportedDocumentNodes = exports.I18nProvider = exports.useTranslation = exports.useIssueProperty = exports.useSpaceProperty = exports.useContentProperty = exports.default = exports.usePermissions = exports.useTheme = exports.useConfig = exports.useProductContext = exports.xcss = void 0;
const tslib_1 = require("tslib");
const xcss = (style) => style;
exports.xcss = xcss;
var useProductContext_1 = require("./hooks/useProductContext");
Object.defineProperty(exports, "useProductContext", { enumerable: true, get: function () { return useProductContext_1.useProductContext; } });
var useConfig_1 = require("./hooks/useConfig");
Object.defineProperty(exports, "useConfig", { enumerable: true, get: function () { return useConfig_1.useConfig; } });
+var useTheme_1 = require("./hooks/useTheme");
+Object.defineProperty(exports, "useTheme", { enumerable: true, get: function () { return useTheme_1.useTheme; } });
var usePermissions_1 = require("./hooks/usePermissions");
Object.defineProperty(exports, "usePermissions", { enumerable: true, get: function () { return usePermissions_1.usePermissions; } });
var reconciler_1 = require("./reconciler");
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return reconciler_1.ForgeReconciler; } }); Index: package/out/hooks/__test__/useConfig.test.js
===================================================================
--- package/out/hooks/__test__/useConfig.test.js
+++ package/out/hooks/__test__/useConfig.test.js
@@ -1,25 +1,9 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
-const listeners = new Map();
-const simpleBridgeEvents = {
- on: (event, callback) => {
- if (!listeners.has(event)) {
- listeners.set(event, []);
- }
- listeners.get(event)?.push(callback);
- },
- emit: (event, data) => {
- if (listeners.has(event)) {
- listeners.get(event)?.forEach((callback) => callback(data));
- }
- },
- clearListeners: (event) => {
- listeners.delete(event);
- }
-};
+const utils_1 = require("./utils");
// defining mock function above import so it is initialised before jest.mock runs
const mockGetContext = jest.fn(async () => null);
const react_1 = tslib_1.__importStar(require("react"));
const reconcilerTestRenderer_1 = tslib_1.__importDefault(require("../../__test__/reconcilerTestRenderer"));
@@ -28,9 +12,9 @@
jest.mock('@forge/bridge', () => ({
view: {
getContext: mockGetContext
},
- events: simpleBridgeEvents
+ events: utils_1.simpleBridgeEvents
}));
const MOCK_CONFIG = {
value: 1
};
@@ -58,9 +42,9 @@
};
};
describe('useConfig', () => {
beforeAll(() => (0, testUtils_1.setupBridge)());
- beforeEach(() => simpleBridgeEvents.clearListeners('FORGE_CORE_MACRO_CONFIG_CHANGED'));
+ beforeEach(() => utils_1.simpleBridgeEvents.clearListeners('FORGE_CORE_MACRO_CONFIG_CHANGED'));
afterEach(() => jest.clearAllMocks());
it('correctly outputs a given config', async () => {
mockGetContext.mockResolvedValue(MOCK_CONTEXT_WITH_CONFIG);
await renderTest();
@@ -77,8 +61,8 @@
mockGetContext.mockResolvedValue(MOCK_CONTEXT_WITH_CONFIG);
await renderTest();
expect(mockGetContext).toHaveBeenCalledTimes(1);
const newConfig = { value: 2 };
- simpleBridgeEvents.emit('FORGE_CORE_MACRO_CONFIG_CHANGED', newConfig);
+ utils_1.simpleBridgeEvents.emit('FORGE_CORE_MACRO_CONFIG_CHANGED', newConfig);
expect(mockGetContext).toHaveBeenCalledTimes(2);
});
}); Index: package/out/hooks/__test__/useObjectStore.test.js
===================================================================
--- package/out/hooks/__test__/useObjectStore.test.js
+++ package/out/hooks/__test__/useObjectStore.test.js
@@ -16,8 +16,9 @@
const mockGetMetadata = jest.fn();
const reconcilerTestRenderer_1 = tslib_1.__importDefault(require("../../__test__/reconcilerTestRenderer"));
const testUtils_1 = require("../../__test__/testUtils");
const useObjectStore_1 = require("../useObjectStore");
+const utils_1 = require("./utils");
// Mock @forge/bridge
jest.mock('@forge/bridge', () => ({
objectStore: {
upload: mockUpload,
@@ -169,9 +170,9 @@
functionKey: MOCK_FUNCTION_KEY,
objects: [MOCK_BLOB]
});
// Give a tick for state to update
- await new Promise((resolve) => setTimeout(resolve, 0));
+ await (0, utils_1.sleep)();
// Should have temp object with isUploading: true
expect(hookResult.objectStates).toHaveLength(1);
expect(hookResult.objectStates[0].isUploading).toBe(true);
expect(hookResult.objectStates[0].key).toMatch(/^temp-upload-/);
@@ -277,9 +278,9 @@
functionKey: MOCK_FUNCTION_KEY,
keys: [MOCK_OBJECT_KEY_1]
});
// Give a tick for state to update
- await new Promise((resolve) => setTimeout(resolve, 0));
+ await (0, utils_1.sleep)();
// Should have isDeleting: true
expect(hookResult.objectStates[0].isDeleting).toBe(true);
// Resolve delete
resolveDelete(undefined);
@@ -360,9 +361,9 @@
functionKey: MOCK_FUNCTION_KEY,
keys: [MOCK_OBJECT_KEY_1, MOCK_OBJECT_KEY_2]
});
// Give a tick for state to update
- await new Promise((resolve) => setTimeout(resolve, 0));
+ await (0, utils_1.sleep)();
// Both should have isDeleting: true
expect(hookResult.objectStates[0].isDeleting).toBe(true);
expect(hookResult.objectStates[1].isDeleting).toBe(true);
// Resolve delete
@@ -417,9 +418,9 @@
functionKey: MOCK_FUNCTION_KEY,
keys: [MOCK_OBJECT_KEY_1]
});
// Give a tick for state to update
- await new Promise((resolve) => setTimeout(resolve, 0));
+ await (0, utils_1.sleep)();
// Should have isDownloading: true
expect(hookResult.objectStates[0].isDownloading).toBe(true);
// Resolve download
const mockBlob = new Blob(['content']); Index: package/package.json
===================================================================
--- package/package.json
+++ package/package.json
@@ -1,7 +1,7 @@
{
"name": "@forge/react",
- "version": "11.8.3-next.0-experimental-0c74a4b",
+ "version": "11.9.0-next.1",
"description": "Forge React reconciler",
"author": "Atlassian",
"license": "SEE LICENSE IN LICENSE.txt",
"main": "out/index.js",
@@ -27,9 +27,9 @@
"dependencies": {
"@atlaskit/adf-schema": "^48.0.0",
"@atlaskit/adf-utils": "^19.19.0",
"@atlaskit/forge-react-types": "^0.48.0",
- "@forge/bridge": "^5.10.1-next.1-experimental-0c74a4b",
+ "@forge/bridge": "^5.10.1-next.0",
"@forge/i18n": "0.0.7",
"@types/react": "^18.2.64",
"@types/react-reconciler": "^0.28.8",
"lodash": "^4.17.21", Index: package/out/index.d.ts.map
===================================================================
--- package/out/index.d.ts.map
+++ package/out/index.d.ts.map
@@ -1,1 +1,1 @@
-{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,eAAO,MAAM,IAAI,UAAW,UAAU,KAAG,UAAmB,CAAC;AAE7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EACL,cAAc,EACd,KAAK,WAAW,EAChB,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAC3B,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,eAAe,IAAI,OAAO,EAAE,MAAM,cAAc,CAAC;AAE1D,cAAc,cAAc,CAAC;AAE7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EAAE,+BAA+B,EAAE,MAAM,oDAAoD,CAAC;AACrG,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,YAAY,EAAE,UAAU,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAClE,YAAY,EACV,gBAAgB,EAChB,UAAU,EACV,QAAQ,EACR,gBAAgB,EAChB,WAAW,EACX,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,cAAc,EACd,SAAS,EACT,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,SAAS,EACT,eAAe,EACf,eAAe,EACf,SAAS,EACT,gBAAgB,EAChB,SAAS,EACT,YAAY,EACZ,kBAAkB,EAClB,SAAS,EACT,WAAW,EACX,UAAU,EACV,eAAe,EACf,SAAS,EACT,aAAa,EACb,kBAAkB,EAClB,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,EACV,eAAe,EACf,oBAAoB,EACpB,gBAAgB,EAChB,oBAAoB,EACpB,eAAe,EACf,UAAU,EACV,UAAU,EACV,yBAAyB,EACzB,mBAAmB,EACnB,WAAW,EACX,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,SAAS,EACT,aAAa,EACb,QAAQ,EACR,SAAS,EACT,aAAa,EACb,cAAc,EACd,WAAW,EACX,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,UAAU,EACV,eAAe,EACf,qBAAqB,EACrB,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,4BAA4B,EAC5B,uBAAuB,EACvB,cAAc,EACd,eAAe,EACf,aAAa,EACb,gBAAgB,EACjB,MAAM,6BAA6B,CAAC"}
\ No newline at end of file
+{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,eAAO,MAAM,IAAI,UAAW,UAAU,KAAG,UAAmB,CAAC;AAE7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA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f,oBAAoB,EACpB,gBAAgB,EAChB,oBAAoB,EACpB,eAAe,EACf,UAAU,EACV,UAAU,EACV,yBAAyB,EACzB,mBAAmB,EACnB,WAAW,EACX,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,SAAS,EACT,aAAa,EACb,QAAQ,EACR,SAAS,EACT,aAAa,EACb,cAAc,EACd,WAAW,EACX,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,UAAU,EACV,eAAe,EACf,qBAAqB,EACrB,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,4BAA4B,EAC5B,uBAAuB,EACvB,cAAc,EACd,eAAe,EACf,aAAa,EACb,gBAAgB,EACjB,MAAM,6BAA6B,CAAC"}
\ No newline at end of file Index: package/CHANGELOG.md
===================================================================
--- package/CHANGELOG.md
+++ package/CHANGELOG.md
@@ -1,11 +1,11 @@
# @forge/react
-## 11.8.3-next.0-experimental-0c74a4b
+## 11.9.0-next.1
-### Patch Changes
+### Minor Changes
-- @forge/[email protected]
+- 92c8fe8: Added useTheme hook to access the current theme and subscribe to theme updates
## 11.8.3-next.0
### Patch Changes Index: package/out/index.d.ts
===================================================================
--- package/out/index.d.ts
+++ package/out/index.d.ts
@@ -1,8 +1,9 @@
import type { XCSSObject } from './package-types';
export declare const xcss: (style: XCSSObject) => XCSSObject;
export { useProductContext } from './hooks/useProductContext';
export { useConfig } from './hooks/useConfig';
+export { useTheme } from './hooks/useTheme';
export { usePermissions, type Permissions, type PermissionRequirements, type MissingPermissions, type PermissionCheckResult } from './hooks/usePermissions';
export { ForgeReconciler as default } from './reconciler';
export * from './components';
export { useContentProperty } from './hooks/useContentProperty'; File too large for inline diff