@easy-cookie/core 0.1.0 → 0.1.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/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { E as EasyCookieApi } from './types-CvWqxzmv.cjs';
2
- export { a as CategoryDeclaration, b as ConsentEventDetail, c as ConsentLogOptions, d as ConsentMethod, e as ConsentRecordInput, f as ConsentState, C as CookieDeclaration, D as DeepPartial, g as EasyCookieConfig, h as EasyCookieEvent, G as GcmSignal, i as GoogleConsentModeOptions, L as Localized, R as ReopenButtonOptions, S as ServiceDeclaration, T as Texts, U as UiOptions, j as UiPosition } from './types-CvWqxzmv.cjs';
1
+ import { E as EasyCookieApi } from './types-B6QEQkj-.cjs';
2
+ export { a as CategoryDeclaration, b as ConsentEventDetail, c as ConsentLogOptions, d as ConsentMethod, e as ConsentRecordInput, f as ConsentState, C as CookieDeclaration, D as DeepPartial, g as EasyCookieConfig, h as EasyCookieEvent, G as GcmSignal, i as GoogleConsentModeOptions, L as Localized, R as ReopenButtonOptions, S as ServiceDeclaration, T as Texts, U as UiOptions, j as UiPosition } from './types-B6QEQkj-.cjs';
3
3
  export { ConfigIssue, DEFAULT_COOKIE_NAME, DEFAULT_EXPIRY_DAYS, DEFAULT_GCM_EVENT, DEFAULT_TEXTS, DEFAULT_WAIT_FOR_UPDATE, EXTRA_CATEGORY_COLORS, KNOWN_CATEGORIES, ParseOptions, RawConsentCookie, ResolvedCategory, ResolvedConfig, categoryDefaults, consentFromCookieHeader, decodeRawCookie, defineConfig, gcmStateFor, localize, parseConsent, readCookie, renderHeadScript, resolveConfig, resolveTexts, validateConfig } from './shared.cjs';
4
4
 
5
5
  /** Create an independent easy-cookie instance. The default export is a singleton. */
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { E as EasyCookieApi } from './types-CvWqxzmv.js';
2
- export { a as CategoryDeclaration, b as ConsentEventDetail, c as ConsentLogOptions, d as ConsentMethod, e as ConsentRecordInput, f as ConsentState, C as CookieDeclaration, D as DeepPartial, g as EasyCookieConfig, h as EasyCookieEvent, G as GcmSignal, i as GoogleConsentModeOptions, L as Localized, R as ReopenButtonOptions, S as ServiceDeclaration, T as Texts, U as UiOptions, j as UiPosition } from './types-CvWqxzmv.js';
1
+ import { E as EasyCookieApi } from './types-B6QEQkj-.js';
2
+ export { a as CategoryDeclaration, b as ConsentEventDetail, c as ConsentLogOptions, d as ConsentMethod, e as ConsentRecordInput, f as ConsentState, C as CookieDeclaration, D as DeepPartial, g as EasyCookieConfig, h as EasyCookieEvent, G as GcmSignal, i as GoogleConsentModeOptions, L as Localized, R as ReopenButtonOptions, S as ServiceDeclaration, T as Texts, U as UiOptions, j as UiPosition } from './types-B6QEQkj-.js';
3
3
  export { ConfigIssue, DEFAULT_COOKIE_NAME, DEFAULT_EXPIRY_DAYS, DEFAULT_GCM_EVENT, DEFAULT_TEXTS, DEFAULT_WAIT_FOR_UPDATE, EXTRA_CATEGORY_COLORS, KNOWN_CATEGORIES, ParseOptions, RawConsentCookie, ResolvedCategory, ResolvedConfig, categoryDefaults, consentFromCookieHeader, decodeRawCookie, defineConfig, gcmStateFor, localize, parseConsent, readCookie, renderHeadScript, resolveConfig, resolveTexts, validateConfig } from './shared.js';
4
4
 
5
5
  /** Create an independent easy-cookie instance. The default export is a singleton. */
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @easy-cookie/core 0.1.0 | MIT | includes vanilla-cookieconsent v3.3.0 (c) Orest Bida, MIT */
1
+ /*! @easy-cookie/core 0.1.1 | MIT | includes vanilla-cookieconsent v3.3.0 (c) Orest Bida, MIT */
2
2
  import {
3
3
  DEFAULT_COOKIE_NAME,
4
4
  DEFAULT_EXPIRY_DAYS,
@@ -19,7 +19,7 @@ import {
19
19
  resolveConfig,
20
20
  resolveTexts,
21
21
  validateConfig
22
- } from "./chunk-5YF2UROU.js";
22
+ } from "./chunk-LUBO6KZ2.js";
23
23
 
24
24
  // src/engine/utils/constants.js
25
25
  var COOKIE_NAME = "cc_cookie";
@@ -2572,6 +2572,8 @@ function createEasyCookie() {
2572
2572
  let texts = null;
2573
2573
  const listeners = /* @__PURE__ */ new Map();
2574
2574
  let pendingMethod = null;
2575
+ let pendingSubject = null;
2576
+ let lastSend = Promise.resolve(true);
2575
2577
  let firstFlag = false;
2576
2578
  let previous = [];
2577
2579
  let reopen = null;
@@ -2654,6 +2656,12 @@ function createEasyCookie() {
2654
2656
  afterState(state);
2655
2657
  emit(first ? "consent" : "change", { consent: state, changed, first });
2656
2658
  const sent = config.log ? sendRecord(config.log, record(state)) : Promise.resolve(true);
2659
+ lastSend = sent;
2660
+ if (pendingSubject && config.log) {
2661
+ const subject = pendingSubject;
2662
+ pendingSubject = null;
2663
+ void sent.then((ok) => ok && sendSubject(config.log, state.id, subject));
2664
+ }
2657
2665
  if ((_a = config.log) == null ? void 0 : _a.requireLog)
2658
2666
  sent.then((ok) => {
2659
2667
  if (!ok) {
@@ -2668,6 +2676,7 @@ function createEasyCookie() {
2668
2676
  }
2669
2677
  };
2670
2678
  const afterState = (state) => {
2679
+ if (w) w.__easyCookieHead = { granted: state ? state.categories : config.resolvedCategories.filter((c) => c.readOnly).map((c) => c.id), valid: !!state };
2671
2680
  renderMosaic(document.querySelector("#cc-main .cm"), config, texts, lang, state);
2672
2681
  reopen == null ? void 0 : reopen.update(state);
2673
2682
  embeds == null ? void 0 : embeds.refresh();
@@ -2856,9 +2865,14 @@ function createEasyCookie() {
2856
2865
  hide();
2857
2866
  },
2858
2867
  async identify(subjectId) {
2868
+ if (!(config == null ? void 0 : config.log)) return false;
2859
2869
  const s = get();
2860
- if (!s || !(config == null ? void 0 : config.log)) return;
2861
- await sendSubject(config.log, s.id, subjectId);
2870
+ if (!s) {
2871
+ pendingSubject = subjectId;
2872
+ return false;
2873
+ }
2874
+ await lastSend;
2875
+ return sendSubject(config.log, s.id, subjectId);
2862
2876
  },
2863
2877
  reset() {
2864
2878
  if (!config) return;