@nizza/core 0.7.1-beta.1 → 0.8.0-beta.2
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/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +73 -12
- package/dist/index.mjs.map +1 -1
- package/dist/lib/nizza-store/NizzaStore.d.ts +5 -1
- package/dist/lib/nizza-store/NizzaStore.d.ts.map +1 -1
- package/dist/lib/runtime/component-manager.d.ts +41 -6
- package/dist/lib/runtime/component-manager.d.ts.map +1 -1
- package/dist/lib/types/api-graphql-types.d.ts +0 -1
- package/dist/lib/types/api-graphql-types.d.ts.map +1 -1
- package/dist/lib/types/nizza/globalStore.d.ts +3 -3
- package/dist/lib/types/nizza/globalStore.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -21358,7 +21358,7 @@ let PT = class bf {
|
|
|
21358
21358
|
}
|
|
21359
21359
|
};
|
|
21360
21360
|
function BU(t) {
|
|
21361
|
-
return Hr().
|
|
21361
|
+
return Hr().baseLogger.lazyChild(t);
|
|
21362
21362
|
}
|
|
21363
21363
|
function DT(t, e) {
|
|
21364
21364
|
return PT.create(
|
|
@@ -21512,6 +21512,14 @@ const Rn = class Rn {
|
|
|
21512
21512
|
var e;
|
|
21513
21513
|
(e = this.cfg) != null && e.account && await this.loadAccount(this.cfg.account, !!this.cfg.authToken);
|
|
21514
21514
|
}
|
|
21515
|
+
/**
|
|
21516
|
+
* Reset account state and related config fields to their initial values.
|
|
21517
|
+
*/
|
|
21518
|
+
resetAccount() {
|
|
21519
|
+
this.accountData = void 0, this.statusInternal = "idle", this.currentFetchId = null, this.pds = void 0, this.cfg && (this.cfg.account = void 0, this.cfg.authToken = void 0, this.cfg.productId = null, this.cfg.orderFormId = null), this.logger.debug(
|
|
21520
|
+
"Account state and related config fields have been reset"
|
|
21521
|
+
);
|
|
21522
|
+
}
|
|
21515
21523
|
/** @returns Current version */
|
|
21516
21524
|
get version() {
|
|
21517
21525
|
return Rn.version;
|
|
@@ -21548,7 +21556,7 @@ const Rn = class Rn {
|
|
|
21548
21556
|
return this.pds;
|
|
21549
21557
|
}
|
|
21550
21558
|
};
|
|
21551
|
-
Pe(Rn, "version", "
|
|
21559
|
+
Pe(Rn, "version", "11"), Pe(Rn, "instanceRef");
|
|
21552
21560
|
let _f = Rn;
|
|
21553
21561
|
const Hr = (t) => {
|
|
21554
21562
|
const e = _f.instance();
|
|
@@ -31917,27 +31925,80 @@ Pe(dU, "baseStyles", RF`
|
|
|
31917
31925
|
}
|
|
31918
31926
|
`);
|
|
31919
31927
|
class fU {
|
|
31928
|
+
/**
|
|
31929
|
+
* @param containerId ID of DOM element to render into
|
|
31930
|
+
* @param renderHandler async function that mounts and returns control methods
|
|
31931
|
+
* @param logger logging utility for debug tracing
|
|
31932
|
+
*/
|
|
31920
31933
|
constructor(e, n, r) {
|
|
31921
|
-
|
|
31922
|
-
Pe(this, "
|
|
31923
|
-
|
|
31924
|
-
|
|
31934
|
+
// stores handlers for each lifecycle event; ensures uniqueness
|
|
31935
|
+
Pe(this, "_lifecycleHandlers", /* @__PURE__ */ new Map([
|
|
31936
|
+
["mount", /* @__PURE__ */ new Set()],
|
|
31937
|
+
["update", /* @__PURE__ */ new Set()],
|
|
31938
|
+
["unmount", /* @__PURE__ */ new Set()]
|
|
31939
|
+
]));
|
|
31940
|
+
Pe(this, "_containerId");
|
|
31941
|
+
// ID of root HTML container
|
|
31942
|
+
Pe(this, "_renderHandler");
|
|
31943
|
+
// strategy to mount component
|
|
31944
|
+
Pe(this, "_logger");
|
|
31945
|
+
// logger for debug output
|
|
31946
|
+
/** currently mounted element, null if none */
|
|
31925
31947
|
Pe(this, "element", null);
|
|
31926
|
-
|
|
31948
|
+
/** update component props or throw if not mounted */
|
|
31927
31949
|
Pe(this, "updateProps");
|
|
31928
|
-
|
|
31950
|
+
/** unmount component or throw if not mounted */
|
|
31951
|
+
Pe(this, "unmount");
|
|
31952
|
+
this._containerId = e, this._renderHandler = n, this._logger = r;
|
|
31929
31953
|
}
|
|
31954
|
+
/**
|
|
31955
|
+
* Mounts or updates the component with given props.
|
|
31956
|
+
* Calls appropriate lifecycle hooks and logs each phase.
|
|
31957
|
+
* @param props data passed to component on render/update
|
|
31958
|
+
*/
|
|
31930
31959
|
async render(e = {}) {
|
|
31931
31960
|
var n;
|
|
31932
31961
|
if (this.element)
|
|
31933
31962
|
this.updateProps(e);
|
|
31934
31963
|
else {
|
|
31935
|
-
|
|
31936
|
-
|
|
31937
|
-
|
|
31938
|
-
|
|
31964
|
+
this._logger.debug("mounting component", e);
|
|
31965
|
+
const r = await this._renderHandler(this._containerId, e);
|
|
31966
|
+
this.element = (n = r == null ? void 0 : r.element) != null ? n : null, this.updateProps = (i) => {
|
|
31967
|
+
r == null || r.updateProps(i), this._logger.debug("updating props", i), this._trigger("update", i);
|
|
31968
|
+
}, this.unmount = () => {
|
|
31969
|
+
this._logger.debug("unmounting component"), r == null || r.unmount(), this._trigger("unmount"), this.element = null;
|
|
31970
|
+
}, this._trigger("mount");
|
|
31939
31971
|
}
|
|
31940
31972
|
}
|
|
31973
|
+
/**
|
|
31974
|
+
* Registers a callback to run after mounting.
|
|
31975
|
+
* @param callback no-args handler
|
|
31976
|
+
*/
|
|
31977
|
+
onMount(e) {
|
|
31978
|
+
return this._lifecycleHandlers.get("mount").add(e), this;
|
|
31979
|
+
}
|
|
31980
|
+
/**
|
|
31981
|
+
* Registers a callback to run after props update.
|
|
31982
|
+
* @param callback receives new props
|
|
31983
|
+
*/
|
|
31984
|
+
onUpdate(e) {
|
|
31985
|
+
return this._lifecycleHandlers.get("update").add(e), this;
|
|
31986
|
+
}
|
|
31987
|
+
/**
|
|
31988
|
+
* Registers a callback to run when unmounting.
|
|
31989
|
+
* @param callback no-args handler
|
|
31990
|
+
*/
|
|
31991
|
+
onUnmount(e) {
|
|
31992
|
+
return this._lifecycleHandlers.get("unmount").add(e), this;
|
|
31993
|
+
}
|
|
31994
|
+
/**
|
|
31995
|
+
* Internal: triggers all handlers for an event.
|
|
31996
|
+
* @param event lifecycle phase to trigger
|
|
31997
|
+
* @param props optional props for update handlers
|
|
31998
|
+
*/
|
|
31999
|
+
_trigger(e, n) {
|
|
32000
|
+
this._lifecycleHandlers.get(e).forEach((i) => i(n));
|
|
32001
|
+
}
|
|
31941
32002
|
}
|
|
31942
32003
|
class Ah {
|
|
31943
32004
|
constructor(e) {
|