@scalar/helpers 0.2.9 → 0.2.11

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @scalar/helpers
2
2
 
3
+ ## 0.2.11
4
+
5
+ ### Patch Changes
6
+
7
+ - [#8016](https://github.com/scalar/scalar/pull/8016): feat: move history and auth into their own store
8
+
9
+ ## 0.2.10
10
+
11
+ ### Patch Changes
12
+
13
+ - [#7963](https://github.com/scalar/scalar/pull/7963): feat: unify is-object helpers
14
+
3
15
  ## 0.2.9
4
16
 
5
17
  ### Patch Changes
@@ -1,17 +1,19 @@
1
1
  /**
2
- * Returns true if the provided value is a plain object
3
- * (i.e. not null, not an array, and typeof value is "object").
2
+ * Returns true if the provided value is a record object
3
+ * (i.e. not null, not an array, and has an actual object as the prototype).
4
4
  *
5
- * This is a type guard useful for narrowing types in TypeScript.
5
+ * Differs from the previous isObject in that it returns false for Date,
6
+ * RegExp, Error, Map, Set, WeakMap, WeakSet, Promise, and other non-plain objects.
6
7
  *
7
8
  * Examples:
8
- * isObject({}) // true
9
- * isObject({ a: 1 }) // true
10
- * isObject([]) // false (Array)
11
- * isObject(null) // false
12
- * isObject(123) // false
13
- * isObject('string') // false
14
- * isObject(new Date()) // true (note: Date is technically an object)
9
+ * isObject({}) // true
10
+ * isObject({ a: 1 }) // true
11
+ * isObject([]) // false (Array)
12
+ * isObject(null) // false
13
+ * isObject(123) // false
14
+ * isObject('string') // false
15
+ * isObject(new Error('test')) // false
16
+ * isObject(new Date()) // false
15
17
  * isObject(Object.create(null)) // true
16
18
  */
17
19
  export declare const isObject: (value: unknown) => value is Record<string, unknown>;
@@ -1 +1 @@
1
- {"version":3,"file":"is-object.d.ts","sourceRoot":"","sources":["../../src/object/is-object.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,QAAQ,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAExE,CAAA"}
1
+ {"version":3,"file":"is-object.d.ts","sourceRoot":"","sources":["../../src/object/is-object.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,QAAQ,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAOxE,CAAA"}
@@ -1,5 +1,9 @@
1
1
  const isObject = (value) => {
2
- return typeof value === "object" && value !== null && !Array.isArray(value);
2
+ if (value === null || typeof value !== "object") {
3
+ return false;
4
+ }
5
+ const proto = Object.getPrototypeOf(value);
6
+ return proto === Object.prototype || proto === null;
3
7
  };
4
8
  export {
5
9
  isObject
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/object/is-object.ts"],
4
- "sourcesContent": ["/**\n * Returns true if the provided value is a plain object\n * (i.e. not null, not an array, and typeof value is \"object\").\n *\n * This is a type guard useful for narrowing types in TypeScript.\n *\n * Examples:\n * isObject({}) // true\n * isObject({ a: 1 }) // true\n * isObject([]) // false (Array)\n * isObject(null) // false\n * isObject(123) // false\n * isObject('string') // false\n * isObject(new Date()) // true (note: Date is technically an object)\n * isObject(Object.create(null)) // true\n */\nexport const isObject = (value: unknown): value is Record<string, unknown> => {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n"],
5
- "mappings": "AAgBO,MAAM,WAAW,CAAC,UAAqD;AAC5E,SAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;",
4
+ "sourcesContent": ["/**\n * Returns true if the provided value is a record object\n * (i.e. not null, not an array, and has an actual object as the prototype).\n *\n * Differs from the previous isObject in that it returns false for Date,\n * RegExp, Error, Map, Set, WeakMap, WeakSet, Promise, and other non-plain objects.\n *\n * Examples:\n * isObject({}) // true\n * isObject({ a: 1 }) // true\n * isObject([]) // false (Array)\n * isObject(null) // false\n * isObject(123) // false\n * isObject('string') // false\n * isObject(new Error('test')) // false\n * isObject(new Date()) // false\n * isObject(Object.create(null)) // true\n */\nexport const isObject = (value: unknown): value is Record<string, unknown> => {\n if (value === null || typeof value !== 'object') {\n return false\n }\n\n const proto = Object.getPrototypeOf(value)\n return proto === Object.prototype || proto === null\n}\n"],
5
+ "mappings": "AAkBO,MAAM,WAAW,CAAC,UAAqD;AAC5E,MAAI,UAAU,QAAQ,OAAO,UAAU,UAAU;AAC/C,WAAO;AAAA,EACT;AAEA,QAAM,QAAQ,OAAO,eAAe,KAAK;AACzC,SAAO,UAAU,OAAO,aAAa,UAAU;AACjD;",
6
6
  "names": []
7
7
  }
@@ -23,13 +23,9 @@ export declare const REFERENCE_LS_KEYS: {
23
23
  */
24
24
  readonly SELECTED_CLIENT: "scalar-reference-selected-client-v2";
25
25
  /**
26
- * Store the auth schemes as a string in localStorage
26
+ * Store the auth as a string in localStorage
27
27
  */
28
- readonly AUTH_SCHEMES: "scalar-reference-auth-schemes";
29
- /**
30
- * Store the selected auth schemes as a string in localStorage
31
- */
32
- readonly SELECTED_AUTH_SCHEMES: "scalar-reference-selected-auth-schemes";
28
+ readonly AUTH: "scalar-reference-auth";
33
29
  };
34
30
  /**
35
31
  * localStorage keys for all client resources
@@ -1 +1 @@
1
- {"version":3,"file":"local-storage.d.ts","sourceRoot":"","sources":["../../src/object/local-storage.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,OAAO;;;;;;;;;;CAUV,CAAA;AAEV;;;GAGG;AACH,eAAO,MAAM,iBAAiB;IAC5B;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;CAEK,CAAA;AAEV;;;GAGG;AACH,eAAO,MAAM,cAAc;IACzB;;;OAGG;;IAEH;;;OAGG;;CAEK,CAAA;AAEV,sCAAsC;AACtC,eAAO,MAAM,gBAAgB;;;;CAOX,CAAA"}
1
+ {"version":3,"file":"local-storage.d.ts","sourceRoot":"","sources":["../../src/object/local-storage.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,OAAO;;;;;;;;;;CAUV,CAAA;AAEV;;;GAGG;AACH,eAAO,MAAM,iBAAiB;IAC5B;;OAEG;;IAEH;;OAEG;;CAEK,CAAA;AAEV;;;GAGG;AACH,eAAO,MAAM,cAAc;IACzB;;;OAGG;;IAEH;;;OAGG;;CAEK,CAAA;AAEV,sCAAsC;AACtC,eAAO,MAAM,gBAAgB;;;;CAOX,CAAA"}
@@ -15,13 +15,9 @@ const REFERENCE_LS_KEYS = {
15
15
  */
16
16
  SELECTED_CLIENT: "scalar-reference-selected-client-v2",
17
17
  /**
18
- * Store the auth schemes as a string in localStorage
18
+ * Store the auth as a string in localStorage
19
19
  */
20
- AUTH_SCHEMES: "scalar-reference-auth-schemes",
21
- /**
22
- * Store the selected auth schemes as a string in localStorage
23
- */
24
- SELECTED_AUTH_SCHEMES: "scalar-reference-selected-auth-schemes"
20
+ AUTH: "scalar-reference-auth"
25
21
  };
26
22
  const CLIENT_LS_KEYS = {
27
23
  /**
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/object/local-storage.ts"],
4
- "sourcesContent": ["/**\n * localStorage keys for resources\n * DO NOT CHANGE THESE AS IT WILL BREAK THE MIGRATION\n */\nexport const LS_KEYS = {\n COLLECTION: 'collection',\n COOKIE: 'cookie',\n ENVIRONMENT: 'environment',\n REQUEST: 'request',\n REQUEST_EXAMPLE: 'requestExample',\n SECURITY_SCHEME: 'securityScheme',\n SERVER: 'server',\n TAG: 'tag',\n WORKSPACE: 'workspace',\n} as const\n\n/**\n * localStorage keys for all reference resources\n * to ensure we do not have any conflicts\n */\nexport const REFERENCE_LS_KEYS = {\n /**\n * Store the selected client as a string in localStorage\n */\n SELECTED_CLIENT: 'scalar-reference-selected-client-v2',\n /**\n * Store the auth schemes as a string in localStorage\n */\n AUTH_SCHEMES: 'scalar-reference-auth-schemes',\n /**\n * Store the selected auth schemes as a string in localStorage\n */\n SELECTED_AUTH_SCHEMES: 'scalar-reference-selected-auth-schemes',\n} as const\n\n/**\n * localStorage keys for all client resources\n * to ensure we do not have any conflicts\n */\nexport const CLIENT_LS_KEYS = {\n /**\n * @deprecated This key is deprecated and will be removed in a future release.\n * We are now storing the entire document for the api-client instead.\n */\n AUTH: 'scalar-client-auth',\n /**\n * @deprecated This key is deprecated and will be removed in a future release.\n * We are now storing the entire document for the api-client instead.\n */\n SELECTED_SECURITY_SCHEMES: 'scalar-client-selected-security-schemes',\n} as const\n\n/** SSR safe alias for localStorage */\nexport const safeLocalStorage = () =>\n typeof window === 'undefined'\n ? {\n getItem: () => null,\n setItem: () => null,\n removeItem: () => null,\n }\n : localStorage\n"],
5
- "mappings": "AAIO,MAAM,UAAU;AAAA,EACrB,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,aAAa;AAAA,EACb,SAAS;AAAA,EACT,iBAAiB;AAAA,EACjB,iBAAiB;AAAA,EACjB,QAAQ;AAAA,EACR,KAAK;AAAA,EACL,WAAW;AACb;AAMO,MAAM,oBAAoB;AAAA;AAAA;AAAA;AAAA,EAI/B,iBAAiB;AAAA;AAAA;AAAA;AAAA,EAIjB,cAAc;AAAA;AAAA;AAAA;AAAA,EAId,uBAAuB;AACzB;AAMO,MAAM,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA,EAK5B,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA,EAKN,2BAA2B;AAC7B;AAGO,MAAM,mBAAmB,MAC9B,OAAO,WAAW,cACd;AAAA,EACE,SAAS,MAAM;AAAA,EACf,SAAS,MAAM;AAAA,EACf,YAAY,MAAM;AACpB,IACA;",
4
+ "sourcesContent": ["/**\n * localStorage keys for resources\n * DO NOT CHANGE THESE AS IT WILL BREAK THE MIGRATION\n */\nexport const LS_KEYS = {\n COLLECTION: 'collection',\n COOKIE: 'cookie',\n ENVIRONMENT: 'environment',\n REQUEST: 'request',\n REQUEST_EXAMPLE: 'requestExample',\n SECURITY_SCHEME: 'securityScheme',\n SERVER: 'server',\n TAG: 'tag',\n WORKSPACE: 'workspace',\n} as const\n\n/**\n * localStorage keys for all reference resources\n * to ensure we do not have any conflicts\n */\nexport const REFERENCE_LS_KEYS = {\n /**\n * Store the selected client as a string in localStorage\n */\n SELECTED_CLIENT: 'scalar-reference-selected-client-v2',\n /**\n * Store the auth as a string in localStorage\n */\n AUTH: 'scalar-reference-auth',\n} as const\n\n/**\n * localStorage keys for all client resources\n * to ensure we do not have any conflicts\n */\nexport const CLIENT_LS_KEYS = {\n /**\n * @deprecated This key is deprecated and will be removed in a future release.\n * We are now storing the entire document for the api-client instead.\n */\n AUTH: 'scalar-client-auth',\n /**\n * @deprecated This key is deprecated and will be removed in a future release.\n * We are now storing the entire document for the api-client instead.\n */\n SELECTED_SECURITY_SCHEMES: 'scalar-client-selected-security-schemes',\n} as const\n\n/** SSR safe alias for localStorage */\nexport const safeLocalStorage = () =>\n typeof window === 'undefined'\n ? {\n getItem: () => null,\n setItem: () => null,\n removeItem: () => null,\n }\n : localStorage\n"],
5
+ "mappings": "AAIO,MAAM,UAAU;AAAA,EACrB,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,aAAa;AAAA,EACb,SAAS;AAAA,EACT,iBAAiB;AAAA,EACjB,iBAAiB;AAAA,EACjB,QAAQ;AAAA,EACR,KAAK;AAAA,EACL,WAAW;AACb;AAMO,MAAM,oBAAoB;AAAA;AAAA;AAAA;AAAA,EAI/B,iBAAiB;AAAA;AAAA;AAAA;AAAA,EAIjB,MAAM;AACR;AAMO,MAAM,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA,EAK5B,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA,EAKN,2BAA2B;AAC7B;AAGO,MAAM,mBAAmB,MAC9B,OAAO,WAAW,cACd;AAAA,EACE,SAAS,MAAM;AAAA,EACf,SAAS,MAAM;AAAA,EACf,YAAY,MAAM;AACpB,IACA;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "helpers",
15
15
  "js"
16
16
  ],
17
- "version": "0.2.9",
17
+ "version": "0.2.11",
18
18
  "engines": {
19
19
  "node": ">=20"
20
20
  },
@@ -88,7 +88,7 @@
88
88
  "CHANGELOG.md"
89
89
  ],
90
90
  "devDependencies": {
91
- "jsdom": "26.1.0",
91
+ "jsdom": "27.4.0",
92
92
  "vite": "^7.3.1",
93
93
  "vitest": "4.0.16",
94
94
  "@scalar/build-tooling": "0.4.1"