🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@forge/react

Package Overview
Dependencies
Maintainers
2
Versions
428
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@forge/react - npm Package Compare versions

Comparing version
8.1.2-next.1
to
8.1.2-next.2
+2
out/__test__/defaultReconciler.test.d.ts
export {};
//# sourceMappingURL=defaultReconciler.test.d.ts.map
{"version":3,"file":"defaultReconciler.test.d.ts","sourceRoot":"","sources":["../../src/__test__/defaultReconciler.test.tsx"],"names":[],"mappings":""}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
let keyCount = 0;
jest.mock('uuid', () => (Object.assign(Object.assign({}, jest.requireActual('uuid')), { v4: () => `${keyCount++}` })));
const react_1 = tslib_1.__importStar(require("react"));
const reconcilerTestRenderer_1 = tslib_1.__importDefault(require("./reconcilerTestRenderer"));
const components_1 = require("../components");
const get_1 = tslib_1.__importDefault(require("lodash/get"));
const testUtils_1 = require("./testUtils");
describe('Disabled reconcilation counting (default behaviour)', () => {
let bridgeCalls = [];
const TEXT = 0;
const BUTTON = 1;
const STATIC_TEXT = 2;
const STRING = 0;
beforeAll(async () => {
bridgeCalls = (0, testUtils_1.setupBridge)();
const Test = () => {
const [bool, setBool] = (0, react_1.useState)(false);
return ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [(0, jsx_runtime_1.jsx)(components_1.Text, { children: !bool ? 'Loading...' : 'Now loaded...' }), (0, jsx_runtime_1.jsx)(components_1.Button, Object.assign({ onClick: () => setBool(true) }, { children: "Click" })), (0, jsx_runtime_1.jsx)(components_1.StatusLozenge, Object.assign({ appearance: "inprogress" }, { children: "Test" }))] }));
};
await reconcilerTestRenderer_1.default.create((0, jsx_runtime_1.jsx)(Test, {}));
});
it('No reconciliation counts are present', () => {
const forgeDoc = (0, testUtils_1.getLastBridgeCallForgeDoc)(bridgeCalls);
expect(forgeDoc).not.toHaveProperty('reconciliationCount');
expect(forgeDoc).toHaveProperty(`children[${TEXT}].type`, 'Text');
expect(forgeDoc).not.toHaveProperty(`children[${TEXT}].reconciliationCount`);
expect(forgeDoc).toHaveProperty(`children[${BUTTON}].type`, 'Button');
expect(forgeDoc).not.toHaveProperty(`children[${BUTTON}].reconciliationCount`);
expect(forgeDoc).toHaveProperty(`children[${STATIC_TEXT}].type`, 'StatusLozenge');
expect(forgeDoc).not.toHaveProperty(`children[${STATIC_TEXT}].reconciliationCount`);
expect(forgeDoc).toMatchSnapshot();
});
it('calling the button click handler DOES NOT add reconciliation count', () => {
let forgeDoc = (0, testUtils_1.getLastBridgeCallForgeDoc)(bridgeCalls);
const onClick = (0, get_1.default)(forgeDoc, `children[${BUTTON}].props.onClick`);
expect(onClick).not.toBeUndefined();
onClick();
forgeDoc = (0, testUtils_1.getLastBridgeCallForgeDoc)(bridgeCalls);
expect(forgeDoc).not.toHaveProperty('reconciliationCount');
expect(forgeDoc).not.toHaveProperty(`children[${TEXT}].reconciliationCount`);
expect(forgeDoc).toHaveProperty(`children[${TEXT}].children[${STRING}].type`, 'String');
expect(forgeDoc).not.toHaveProperty(`children[${TEXT}].children[${STRING}].reconciliationCount`);
expect(forgeDoc).not.toHaveProperty(`children[${BUTTON}].reconciliationCount`, 2);
expect(forgeDoc).not.toHaveProperty(`children[${STATIC_TEXT}].reconciliationCount`);
expect(forgeDoc).toMatchSnapshot();
});
});
+6
-0
# @forge/react
## 8.1.2-next.2
### Patch Changes
- 10aa19d3: Reconciliation counting disabled by default in UI Kit 2
## 8.1.2-next.1

@@ -4,0 +10,0 @@

+1
-0

@@ -7,2 +7,3 @@ "use strict";

const testUtils_1 = require("./testUtils");
reconciler_1.ReconciliationCounter.getInstance(false);
const emptyForgeDoc = (0, reconciler_1.createElement)({ type: 'root', props: {} });

@@ -9,0 +10,0 @@ describe('hostConfig used functions', () => {

@@ -12,2 +12,4 @@ "use strict";

const testUtils_1 = require("./testUtils");
const reconciler_1 = require("../reconciler");
reconciler_1.ReconciliationCounter.getInstance(false);
describe('Reconciliation counting', () => {

@@ -14,0 +16,0 @@ let bridgeCalls = [];

@@ -11,3 +11,3 @@ /// <reference types="node" />

key: string;
reconciliationCount: number;
reconciliationCount?: number;
}

@@ -22,2 +22,12 @@ export type CallBridge = (cmd: string, data: {

}) => ForgeDoc;
export declare class ReconciliationCounter {
private count;
private disabled;
private static instance;
private constructor();
static getInstance(disable?: boolean): ReconciliationCounter;
increment(): void;
getCount(): number | undefined;
getNextCount(): number | undefined;
}
export declare const createElement: CreateElement;

@@ -24,0 +34,0 @@ export declare const appendChild: (parent: ForgeDoc, child: ForgeDoc) => void;

+1
-1

@@ -1,1 +0,1 @@

{"version":3,"file":"reconciler.d.ts","sourceRoot":"","sources":["../src/reconciler.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAmB,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAI1D,KAAK,WAAW,GAAG,MAAM,CAAC;AAC1B,KAAK,YAAY,GAAG,aAAa,CAAC;AAElC,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,WAAW,CAAC;IAClB,KAAK,EAAE,YAAY,CAAC;IACpB,QAAQ,EAAE,QAAQ,EAAE,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,mBAAmB,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,MAAM,UAAU,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE;IAAE,QAAQ,EAAE,QAAQ,CAAA;CAAE,KAAK,IAAI,CAAC;AAC7E,eAAO,MAAM,UAAU,EAAE,UAGxB,CAAC;AAEF,KAAK,aAAa,GAAG,CAAC,IAAI,EAAE;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,KAAK,EAAE,aAAa,CAAA;CAAE,KAAK,QAAQ,CAAC;AAmCrF,eAAO,MAAM,aAAa,EAA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S,GAAG,QAAQ,CAAC;AAC1B,KAAK,QAAQ,GAAG,QAAQ,CAAC;AACzB,KAAK,YAAY,GAAG,QAAQ,CAAC;AAC7B,KAAK,gBAAgB,GAAG,QAAQ,CAAC;AACjC,KAAK,kBAAkB,GAAG,QAAQ,CAAC;AACnC,KAAK,cAAc,GAAG,QAAQ,CAAC;AAE/B,KAAK,WAAW,GAAG,GAAG,CAAC;AAEvB,KAAK,aAAa,GAAG,GAAG,CAAC;AAEzB,KAAK,QAAQ,GAAG,GAAG,CAAC;AACpB,KAAK,aAAa,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;AACnD,KAAK,SAAS,GAAG,CAAC,CAAC,CAAC;AAEpB,eAAO,MAAM,UAAU,EAAE,UAAU,CACjC,cAAc,EACd,aAAa,EACb,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACd,WAAW,EACX,aAAa,EACb,QAAQ,EACR,aAAa,EACb,SAAS,CA6KV,CAAC;AAIF,eAAO,MAAM,eAAe;sBACR,SAAS;CAqB5B,CAAC;AAEF,eAAe,eAAe,CAAC"}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ForgeReconciler = exports.hostConfig = exports.nonChildPropsAreEqual = exports.insertBefore = exports.appendChild = exports.createElement = exports.callBridge = void 0;
exports.ForgeReconciler = exports.hostConfig = exports.nonChildPropsAreEqual = exports.insertBefore = exports.appendChild = exports.createElement = exports.ReconciliationCounter = exports.callBridge = void 0;
const tslib_1 = require("tslib");

@@ -14,9 +14,11 @@ const react_reconciler_1 = tslib_1.__importDefault(require("react-reconciler"));

class ReconciliationCounter {
constructor() {
constructor(disable = true) {
this.count = 0;
this.disabled = true;
this.count = 0;
this.disabled = disable;
}
static getInstance() {
static getInstance(disable) {
if (!ReconciliationCounter.instance) {
ReconciliationCounter.instance = new ReconciliationCounter();
ReconciliationCounter.instance = new ReconciliationCounter(disable);
}

@@ -29,10 +31,26 @@ return ReconciliationCounter.instance;

getCount() {
if (this.disabled === true)
return undefined;
return this.count;
}
getNextCount() {
if (this.disabled === true)
return undefined;
return this.count + 1;
}
}
exports.ReconciliationCounter = ReconciliationCounter;
const createElement = ({ type, props = {} }) => {
const { children } = props, restProps = tslib_1.__rest(props, ["children"]);
const reconciliationCount = ReconciliationCounter.getInstance().getNextCount();
if (reconciliationCount !== undefined) {
const element = {
type,
children: [],
props: restProps,
key: (0, uuid_1.v4)(),
reconciliationCount
};
return element;
}
const element = {

@@ -42,4 +60,3 @@ type,

props: restProps,
key: (0, uuid_1.v4)(),
reconciliationCount: ReconciliationCounter.getInstance().getNextCount()
key: (0, uuid_1.v4)()
};

@@ -89,3 +106,6 @@ return element;

counter.increment();
containerInfo.reconciliationCount = counter.getCount();
const reconciliationCount = counter.getCount();
if (reconciliationCount !== undefined) {
containerInfo.reconciliationCount = reconciliationCount;
}
(0, exports.callBridge)('reconcile', { forgeDoc: containerInfo });

@@ -117,3 +137,6 @@ },

}
instance.reconciliationCount = ReconciliationCounter.getInstance().getNextCount();
const reconciliationCount = ReconciliationCounter.getInstance().getNextCount();
if (reconciliationCount !== undefined) {
instance.reconciliationCount = reconciliationCount;
}
instance.props = newProps;

@@ -160,3 +183,6 @@ return newProps;

commitTextUpdate(textInstance, oldText, newText) {
textInstance.reconciliationCount = ReconciliationCounter.getInstance().getNextCount();
const reconciliationCount = ReconciliationCounter.getInstance().getNextCount();
if (reconciliationCount !== undefined) {
textInstance.reconciliationCount = reconciliationCount;
}
textInstance.props.text = newText;

@@ -188,2 +214,3 @@ },

render: (element) => {
ReconciliationCounter.getInstance(true);
const rootElement = (0, exports.createElement)({ type: 'Root', props: {} });

@@ -190,0 +217,0 @@ const container = reconciler.createContainer(rootElement, 0, null, false, null, 'root', (err) => {

{
"name": "@forge/react",
"version": "8.1.2-next.1",
"version": "8.1.2-next.2",
"description": "Forge React reconciler",

@@ -5,0 +5,0 @@ "author": "Atlassian",

Sorry, the diff of this file is not supported yet