@plumeria/core 0.16.1 → 0.17.0

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.js CHANGED
@@ -14,16 +14,32 @@ function create(object) {
14
14
  const hashes = new Set();
15
15
  const sheets = new Set();
16
16
  (0, zss_engine.processAtomicProps)({ [prop]: value }, hashes, sheets);
17
- const baseSheets = [];
18
- const querySheets = [];
19
- for (const sheet$1 of sheets) if (sheet$1.includes("@media") || sheet$1.includes("@container")) querySheets.push(sheet$1);
20
- else baseSheets.push(sheet$1);
21
- const hash = [...hashes].join(" ");
22
- const sheet = [...baseSheets, ...querySheets].join("");
23
- records.push({
17
+ const hashArray = [...hashes];
18
+ const sheetArray = [...sheets];
19
+ const baseSheetParts = [];
20
+ const baseHashParts = [];
21
+ const querySheetParts = [];
22
+ const queryHashParts = [];
23
+ for (let i = 0; i < sheetArray.length; i++) {
24
+ const sheet = sheetArray[i];
25
+ const hash = hashArray[i];
26
+ if (sheet.includes("@media") || sheet.includes("@container")) {
27
+ querySheetParts.push(sheet);
28
+ queryHashParts.push(hash);
29
+ } else {
30
+ baseSheetParts.push(sheet);
31
+ baseHashParts.push(hash);
32
+ }
33
+ }
34
+ if (baseSheetParts.length > 0) records.push({
24
35
  key: prop,
25
- hash,
26
- sheet
36
+ hash: baseHashParts.join(" "),
37
+ sheet: baseSheetParts.join(" ")
38
+ });
39
+ if (querySheetParts.length > 0) records.push({
40
+ key: prop + "__queries__",
41
+ hash: queryHashParts.join(" "),
42
+ sheet: querySheetParts.join(" ")
27
43
  });
28
44
  });
29
45
  if (Object.keys(nonFlat).length > 0) {
@@ -96,6 +112,27 @@ function props(...objects) {
96
112
  uniqueStyleSheets.forEach((sheet) => injectedStyleSheets.add(sheet));
97
113
  if (typeof require_css.globalPromise_1 === "undefined") require_css.initPromise_1();
98
114
  require_css.resolvePromise_1(uniqueStyleSheets.join(""));
115
+ if (zss_engine.isTestingDevelopment && !zss_engine.isServer) {
116
+ const normalStyles = [];
117
+ const queryStyles = [];
118
+ for (const { hash, sheet } of [...orderedKeys, ...rightmostKeys]) {
119
+ if ((0, zss_engine.isHashInStyleSheets)(hash)) continue;
120
+ if (sheet.includes("@media") || sheet.includes("@container")) queryStyles.push({
121
+ hash,
122
+ sheet
123
+ });
124
+ else normalStyles.push({
125
+ hash,
126
+ sheet
127
+ });
128
+ }
129
+ for (const { hash, sheet } of normalStyles.reverse()) (0, zss_engine.injectClientCSS)(hash, sheet);
130
+ if (queryStyles.length > 0) {
131
+ const combinedSheet = queryStyles.map((s) => s.sheet).join("");
132
+ const combinedHashes = queryStyles.map((s) => s.hash).join(" ");
133
+ (0, zss_engine.injectClientQuery)(combinedHashes, combinedSheet);
134
+ }
135
+ }
99
136
  return classList.join(" ");
100
137
  }
101
138
 
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { globalPromise_1, globalPromise_2, initPromise_1, initPromise_2, resolvePromise_1, resolvePromise_2 } from "./css.mjs";
2
- import { camelToKebabCase, genBase36Hash, injectClientGlobalCSS, isServer, isTestingDevelopment, processAtomicProps, splitAtomicAndNested, transpile } from "zss-engine";
2
+ import { camelToKebabCase, genBase36Hash, injectClientCSS, injectClientGlobalCSS, injectClientQuery, isHashInStyleSheets, isServer, isTestingDevelopment, processAtomicProps, splitAtomicAndNested, transpile } from "zss-engine";
3
3
 
4
4
  const styleAtomMap = new WeakMap();
5
5
  function create(object) {
@@ -13,16 +13,32 @@ function create(object) {
13
13
  const hashes = new Set();
14
14
  const sheets = new Set();
15
15
  processAtomicProps({ [prop]: value }, hashes, sheets);
16
- const baseSheets = [];
17
- const querySheets = [];
18
- for (const sheet$1 of sheets) if (sheet$1.includes("@media") || sheet$1.includes("@container")) querySheets.push(sheet$1);
19
- else baseSheets.push(sheet$1);
20
- const hash = [...hashes].join(" ");
21
- const sheet = [...baseSheets, ...querySheets].join("");
22
- records.push({
16
+ const hashArray = [...hashes];
17
+ const sheetArray = [...sheets];
18
+ const baseSheetParts = [];
19
+ const baseHashParts = [];
20
+ const querySheetParts = [];
21
+ const queryHashParts = [];
22
+ for (let i = 0; i < sheetArray.length; i++) {
23
+ const sheet = sheetArray[i];
24
+ const hash = hashArray[i];
25
+ if (sheet.includes("@media") || sheet.includes("@container")) {
26
+ querySheetParts.push(sheet);
27
+ queryHashParts.push(hash);
28
+ } else {
29
+ baseSheetParts.push(sheet);
30
+ baseHashParts.push(hash);
31
+ }
32
+ }
33
+ if (baseSheetParts.length > 0) records.push({
23
34
  key: prop,
24
- hash,
25
- sheet
35
+ hash: baseHashParts.join(" "),
36
+ sheet: baseSheetParts.join(" ")
37
+ });
38
+ if (querySheetParts.length > 0) records.push({
39
+ key: prop + "__queries__",
40
+ hash: queryHashParts.join(" "),
41
+ sheet: querySheetParts.join(" ")
26
42
  });
27
43
  });
28
44
  if (Object.keys(nonFlat).length > 0) {
@@ -95,6 +111,27 @@ function props(...objects) {
95
111
  uniqueStyleSheets.forEach((sheet) => injectedStyleSheets.add(sheet));
96
112
  if (typeof globalPromise_1 === "undefined") initPromise_1();
97
113
  resolvePromise_1(uniqueStyleSheets.join(""));
114
+ if (isTestingDevelopment && !isServer) {
115
+ const normalStyles = [];
116
+ const queryStyles = [];
117
+ for (const { hash, sheet } of [...orderedKeys, ...rightmostKeys]) {
118
+ if (isHashInStyleSheets(hash)) continue;
119
+ if (sheet.includes("@media") || sheet.includes("@container")) queryStyles.push({
120
+ hash,
121
+ sheet
122
+ });
123
+ else normalStyles.push({
124
+ hash,
125
+ sheet
126
+ });
127
+ }
128
+ for (const { hash, sheet } of normalStyles.reverse()) injectClientCSS(hash, sheet);
129
+ if (queryStyles.length > 0) {
130
+ const combinedSheet = queryStyles.map((s) => s.sheet).join("");
131
+ const combinedHashes = queryStyles.map((s) => s.hash).join(" ");
132
+ injectClientQuery(combinedHashes, combinedSheet);
133
+ }
134
+ }
98
135
  return classList.join(" ");
99
136
  }
100
137
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plumeria/core",
3
- "version": "0.16.1",
3
+ "version": "0.17.0",
4
4
  "description": "A library for scalable and optimized styling",
5
5
  "repository": {
6
6
  "type": "git",
@@ -31,7 +31,7 @@
31
31
  "stylesheet.css"
32
32
  ],
33
33
  "dependencies": {
34
- "zss-engine": "0.2.82"
34
+ "zss-engine": "0.2.83"
35
35
  },
36
36
  "publishConfig": {
37
37
  "access": "public"