diff --git a/build-profile.json5 b/build-profile.json5 index 76efa93..d9f1314 100644 --- a/build-profile.json5 +++ b/build-profile.json5 @@ -68,10 +68,6 @@ { "name": "calendar", "srcPath": "./commons/calendar" - }, - { - "name": "json_bigint", - "srcPath": "./commons/json_bigint" } ] } \ No newline at end of file diff --git a/commons/json_bigint/.gitignore b/commons/json_bigint/.gitignore deleted file mode 100644 index e2713a2..0000000 --- a/commons/json_bigint/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/commons/json_bigint/BuildProfile.ets b/commons/json_bigint/BuildProfile.ets deleted file mode 100644 index 3a501e5..0000000 --- a/commons/json_bigint/BuildProfile.ets +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Use these variables when you tailor your ArkTS code. They must be of the const type. - */ -export const HAR_VERSION = '1.0.0'; -export const BUILD_MODE_NAME = 'debug'; -export const DEBUG = true; -export const TARGET_NAME = 'default'; - -/** - * BuildProfile Class is used only for compatibility purposes. - */ -export default class BuildProfile { - static readonly HAR_VERSION = HAR_VERSION; - static readonly BUILD_MODE_NAME = BUILD_MODE_NAME; - static readonly DEBUG = DEBUG; - static readonly TARGET_NAME = TARGET_NAME; -} \ No newline at end of file diff --git a/commons/json_bigint/Index.ets b/commons/json_bigint/Index.ets deleted file mode 100644 index 704cd7c..0000000 --- a/commons/json_bigint/Index.ets +++ /dev/null @@ -1,3 +0,0 @@ -import JsonBigInt from './src/main/ets' - -export default JsonBigInt diff --git a/commons/json_bigint/LICENSE b/commons/json_bigint/LICENSE deleted file mode 100644 index ee4f51c..0000000 --- a/commons/json_bigint/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright 2023 Shugang·Zhou - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. \ No newline at end of file diff --git a/commons/json_bigint/README.md b/commons/json_bigint/README.md deleted file mode 100644 index 03d74f3..0000000 --- a/commons/json_bigint/README.md +++ /dev/null @@ -1,58 +0,0 @@ -# json-bigint - -## Intro - -JSON.parse/stringify with bigints support for HarmonyOS Next. - -## Setup - -```shell -ohpm install @ohmos/json-bigint -``` - -## Usage - -- Example: - -```arkts -import JSONbig from '@ohmos/json-bigint' - -var json = '{ "value" : 9223372036854775807, "v2": 123 }'; -console.log('Input:', json); -console.log(''); - -console.log('node.js built-in JSON:'); -var r = JSON.parse(json); -console.log('JSON.parse(input).value : ', r.value.toString()); -console.log('JSON.stringify(JSON.parse(input)):', JSON.stringify(r)); - -console.log('\n\nbig number JSON:'); -var r1 = JSONbig.parse(json); -console.log('JSONbig.parse(input).value : ', r1.value.toString()); -console.log('JSONbig.stringify(JSONbig.parse(input)):', JSONbig.stringify(r1)); -``` - -- Output: - -```text -Input: { "value" : 9223372036854775807, "v2": 123 } - -node.js built-in JSON: -JSON.parse(input).value : 9223372036854776000 -JSON.stringify(JSON.parse(input)): {"value":9223372036854776000,"v2":123} - - -big number JSON: -JSONbig.parse(input).value : 9223372036854775807 -JSONbig.stringify(JSONbig.parse(input)): {"value":9223372036854775807,"v2":123} -``` - -## Other - -You can see https://github.com/sidorares/json-bigint - -## Connect - -- 仓库:https://github.com/HarmonyOS-Next/mini-calendar -- 作者:zhousg1007@qq.com - diff --git a/commons/json_bigint/build-profile.json5 b/commons/json_bigint/build-profile.json5 deleted file mode 100644 index 312d38e..0000000 --- a/commons/json_bigint/build-profile.json5 +++ /dev/null @@ -1,28 +0,0 @@ -{ - "apiType": "stageMode", - "buildOption": { - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": true, - "files": [ - "./obfuscation-rules.txt" - ] - }, - "consumerFiles": [ - "./consumer-rules.txt" - ] - } - }, - }, - ], - "targets": [ - { - "name": "default" - } - ] -} diff --git a/commons/json_bigint/changelog.md b/commons/json_bigint/changelog.md deleted file mode 100644 index 779bb48..0000000 --- a/commons/json_bigint/changelog.md +++ /dev/null @@ -1,3 +0,0 @@ -## Release 1.0.0 - -- Migrate json-bigint \ No newline at end of file diff --git a/commons/json_bigint/consumer-rules.txt b/commons/json_bigint/consumer-rules.txt deleted file mode 100644 index e69de29..0000000 diff --git a/commons/json_bigint/hvigorfile.ts b/commons/json_bigint/hvigorfile.ts deleted file mode 100644 index 4218707..0000000 --- a/commons/json_bigint/hvigorfile.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { harTasks } from '@ohos/hvigor-ohos-plugin'; - -export default { - system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ - plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ -} diff --git a/commons/json_bigint/obfuscation-rules.txt b/commons/json_bigint/obfuscation-rules.txt deleted file mode 100644 index 985b2ae..0000000 --- a/commons/json_bigint/obfuscation-rules.txt +++ /dev/null @@ -1,18 +0,0 @@ -# Define project specific obfuscation rules here. -# You can include the obfuscation configuration files in the current module's build-profile.json5. -# -# For more details, see -# https://gitee.com/openharmony/arkcompiler_ets_frontend/blob/master/arkguard/README.md - -# Obfuscation options: -# -disable-obfuscation: disable all obfuscations -# -enable-property-obfuscation: obfuscate the property names -# -enable-toplevel-obfuscation: obfuscate the names in the global scope -# -compact: remove unnecessary blank spaces and all line feeds -# -remove-log: remove all console.* statements -# -print-namecache: print the name cache that contains the mapping from the old names to new names -# -apply-namecache: reuse the given cache file - -# Keep options: -# -keep-property-name: specifies property names that you want to keep -# -keep-global-name: specifies names that you want to keep in the global scope \ No newline at end of file diff --git a/commons/json_bigint/oh-package.json5 b/commons/json_bigint/oh-package.json5 deleted file mode 100644 index 7d9e533..0000000 --- a/commons/json_bigint/oh-package.json5 +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "@ohmos/json-bigint", - "version": "1.0.0", - "description": "JSON.parse/stringify with bigints support for HarmonyOS Next.", - "keywords": [ - "JSON", - "parse", - "stringify", - "next" - ], - "main": "Index.ets", - "author": { - "name": 'zhousg', - "email": "zhousg1007@qq.com" - }, - "license": "Apache-2.0", - "repository": "https://github.com/HarmonyOS-Next/json-bigint", - "homepage": "https://github.com/HarmonyOS-Next/json-bigint", -} \ No newline at end of file diff --git a/commons/json_bigint/src/main/ets/index.ts b/commons/json_bigint/src/main/ets/index.ts deleted file mode 100644 index 9228186..0000000 --- a/commons/json_bigint/src/main/ets/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -import parse from './parse' -import stringify from './stringify' - - -const JsonBigInt = { - parse, - stringify -} - -export default JsonBigInt \ No newline at end of file diff --git a/commons/json_bigint/src/main/ets/parse.ts b/commons/json_bigint/src/main/ets/parse.ts deleted file mode 100644 index b188d7c..0000000 --- a/commons/json_bigint/src/main/ets/parse.ts +++ /dev/null @@ -1,438 +0,0 @@ -// regexpxs extracted from -// (c) BSD-3-Clause -// https://github.com/fastify/secure-json-parse/graphs/contributors and https://github.com/hapijs/bourne/graphs/contributors - -const suspectProtoRx = /(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])/; -const suspectConstructorRx = /(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)/; - -/* - json_parse.js - 2012-06-20 - - Public Domain. - - NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. - - This file creates a json_parse function. - During create you can (optionally) specify some behavioural switches - - require('json-bigint')(options) - - The optional options parameter holds switches that drive certain - aspects of the parsing process: - * options.strict = true will warn about duplicate-key usage in the json. - The default (strict = false) will silently ignore those and overwrite - values for keys that are in duplicate use. - - The resulting function follows this signature: - json_parse(text, reviver) - This method parses a JSON text to produce an object or array. - It can throw a SyntaxError exception. - - The optional reviver parameter is a function that can filter and - transform the results. It receives each of the keys and values, - and its return value is used instead of the original value. - If it returns what it received, then the structure is not modified. - If it returns undefined then the member is deleted. - - Example: - - // Parse the text. Values that look like ISO date strings will - // be converted to Date objects. - - myData = json_parse(text, function (key, value) { - var a; - if (typeof value === 'string') { - a = -/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value); - if (a) { - return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4], - +a[5], +a[6])); - } - } - return value; - }); - - This is a reference implementation. You are free to copy, modify, or - redistribute. - - This code should be minified before deployment. - See http://javascript.crockford.com/jsmin.html - - USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO - NOT CONTROL. -*/ - -/*members "", "\"", "\/", "\\", at, b, call, charAt, f, fromCharCode, - hasOwnProperty, message, n, name, prototype, push, r, t, text -*/ - -var json_parse = function (options) { - 'use strict'; - - // This is a function that can parse a JSON text, producing a JavaScript - // data structure. It is a simple, recursive descent parser. It does not use - // eval or regular expressions, so it can be used as a model for implementing - // a JSON parser in other languages. - - // We are defining the function inside of another function to avoid creating - // global variables. - - // Default options one can override by passing options to the parse() - var _options = { - strict: false, // not being strict means do not generate syntax errors for "duplicate key" - storeAsString: false, // toggles whether the values should be stored as BigNumber (default) or a string - alwaysParseAsBig: false, // toggles whether all numbers should be Big - useNativeBigInt: false, // toggles whether to use native BigInt instead of bignumber.js - protoAction: 'error', - constructorAction: 'error', - }; - - // If there are options, then use them to override the default _options - if (options !== undefined && options !== null) { - if (options.strict === true) { - _options.strict = true; - } - if (options.storeAsString === true) { - _options.storeAsString = true; - } - _options.alwaysParseAsBig = - options.alwaysParseAsBig === true ? options.alwaysParseAsBig : false; - _options.useNativeBigInt = - options.useNativeBigInt === true ? options.useNativeBigInt : false; - - if (typeof options.constructorAction !== 'undefined') { - if ( - options.constructorAction === 'error' || - options.constructorAction === 'ignore' || - options.constructorAction === 'preserve' - ) { - _options.constructorAction = options.constructorAction; - } else { - throw new Error( - `Incorrect value for constructorAction option, must be "error", "ignore" or undefined but passed ${options.constructorAction}` - ); - } - } - - if (typeof options.protoAction !== 'undefined') { - if ( - options.protoAction === 'error' || - options.protoAction === 'ignore' || - options.protoAction === 'preserve' - ) { - _options.protoAction = options.protoAction; - } else { - throw new Error( - `Incorrect value for protoAction option, must be "error", "ignore" or undefined but passed ${options.protoAction}` - ); - } - } - } - - var at, // The index of the current character - ch, // The current character - escapee = { - '"': '"', - '\\': '\\', - '/': '/', - b: '\b', - f: '\f', - n: '\n', - r: '\r', - t: '\t', - }, - text, - error = function (m) { - // Call error when something is wrong. - - throw { - name: 'SyntaxError', - message: m, - at: at, - text: text, - }; - }, - next = function (c?) { - // If a c parameter is provided, verify that it matches the current character. - - if (c && c !== ch) { - error("Expected '" + c + "' instead of '" + ch + "'"); - } - - // Get the next character. When there are no more characters, - // return the empty string. - - ch = text.charAt(at); - at += 1; - return ch; - }, - number = function () { - // Parse a number value. - - var number, - string = ''; - - if (ch === '-') { - string = '-'; - next('-'); - } - while (ch >= '0' && ch <= '9') { - string += ch; - next(); - } - if (ch === '.') { - string += '.'; - while (next() && ch >= '0' && ch <= '9') { - string += ch; - } - } - if (ch === 'e' || ch === 'E') { - string += ch; - next(); - if (ch === '-' || ch === '+') { - string += ch; - next(); - } - while (ch >= '0' && ch <= '9') { - string += ch; - next(); - } - } - number = +string; - if (!isFinite(number)) { - error('Bad number'); - } else { - if (Number.isSafeInteger(number)) - return!_options.alwaysParseAsBig - ? number - : BigInt(number) - else - // Number with fractional part should be treated as number(double) including big integers in scientific notation, i.e 1.79e+308 - return _options.storeAsString - ? string - : /[\.eE]/.test(string) - ? number - : BigInt(string) - - } - }, - string = function () { - // Parse a string value. - - var hex, - i, - string = '', - uffff; - - // When parsing for string values, we must look for " and \ characters. - - if (ch === '"') { - var startAt = at; - while (next()) { - if (ch === '"') { - if (at - 1 > startAt) string += text.substring(startAt, at - 1); - next(); - return string; - } - if (ch === '\\') { - if (at - 1 > startAt) string += text.substring(startAt, at - 1); - next(); - if (ch === 'u') { - uffff = 0; - for (i = 0; i < 4; i += 1) { - hex = parseInt(next(), 16); - if (!isFinite(hex)) { - break; - } - uffff = uffff * 16 + hex; - } - string += String.fromCharCode(uffff); - } else if (typeof escapee[ch] === 'string') { - string += escapee[ch]; - } else { - break; - } - startAt = at; - } - } - } - error('Bad string'); - }, - white = function () { - // Skip whitespace. - - while (ch && ch <= ' ') { - next(); - } - }, - word = function () { - // true, false, or null. - - switch (ch) { - case 't': - next('t'); - next('r'); - next('u'); - next('e'); - return true; - case 'f': - next('f'); - next('a'); - next('l'); - next('s'); - next('e'); - return false; - case 'n': - next('n'); - next('u'); - next('l'); - next('l'); - return null; - } - error("Unexpected '" + ch + "'"); - }, - value, // Place holder for the value function. - array = function () { - // Parse an array value. - - var array = []; - - if (ch === '[') { - next('['); - white(); - if (ch === ']') { - next(']'); - return array; // empty array - } - while (ch) { - array.push(value()); - white(); - if (ch === ']') { - next(']'); - return array; - } - next(','); - white(); - } - } - error('Bad array'); - }, - object = function () { - // Parse an object value. - - var key, - object = Object.create(null); - - if (ch === '{') { - next('{'); - white(); - if (ch === '}') { - next('}'); - return object; // empty object - } - while (ch) { - key = string(); - white(); - next(':'); - if ( - _options.strict === true && - Object.hasOwnProperty.call(object, key) - ) { - error('Duplicate key "' + key + '"'); - } - - if (suspectProtoRx.test(key) === true) { - if (_options.protoAction === 'error') { - error('Object contains forbidden prototype property'); - } else if (_options.protoAction === 'ignore') { - value(); - } else { - object[key] = value(); - } - } else if (suspectConstructorRx.test(key) === true) { - if (_options.constructorAction === 'error') { - error('Object contains forbidden constructor property'); - } else if (_options.constructorAction === 'ignore') { - value(); - } else { - object[key] = value(); - } - } else { - object[key] = value(); - } - - white(); - if (ch === '}') { - next('}'); - return object; - } - next(','); - white(); - } - } - error('Bad object'); - }; - - value = function () { - // Parse a JSON value. It could be an object, an array, a string, a number, - // or a word. - - white(); - switch (ch) { - case '{': - return object(); - case '[': - return array(); - case '"': - return string(); - case '-': - return number(); - default: - return ch >= '0' && ch <= '9' ? number() : word(); - } - }; - - // Return the json_parse function. It will have access to all of the above - // functions and variables. - - return function (source, reviver?) { - var result; - - text = source + ''; - at = 0; - ch = ' '; - result = value(); - white(); - if (ch) { - error('Syntax error'); - } - - // If there is a reviver function, we recursively walk the new structure, - // passing each name/value pair to the reviver function for possible - // transformation, starting with a temporary root object that holds the result - // in an empty key. If there is not a reviver function, we simply return the - // result. - - return typeof reviver === 'function' - ? (function walk(holder, key) { - var k, - v, - value = holder[key]; - if (value && typeof value === 'object') { - Object.keys(value).forEach(function (k) { - v = walk(value, k); - if (v !== undefined) { - value[k] = v; - } else { - delete value[k]; - } - }); - } - return reviver.call(holder, key, value); - })({ '': result }, '') - : result; - }; -}; - -export default json_parse({}); \ No newline at end of file diff --git a/commons/json_bigint/src/main/ets/stringify.ts b/commons/json_bigint/src/main/ets/stringify.ts deleted file mode 100644 index 4257844..0000000 --- a/commons/json_bigint/src/main/ets/stringify.ts +++ /dev/null @@ -1,376 +0,0 @@ -/* - json2.js - 2013-05-26 - - Public Domain. - - NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. - - See http://www.JSON.org/js.html - - - This code should be minified before deployment. - See http://javascript.crockford.com/jsmin.html - - USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO - NOT CONTROL. - - - This file creates a global JSON object containing two methods: stringify - and parse. - - JSON.stringify(value, replacer, space) - value any JavaScript value, usually an object or array. - - replacer an optional parameter that determines how object - values are stringified for objects. It can be a - function or an array of strings. - - space an optional parameter that specifies the indentation - of nested structures. If it is omitted, the text will - be packed without extra whitespace. If it is a number, - it will specify the number of spaces to indent at each - level. If it is a string (such as '\t' or ' '), - it contains the characters used to indent at each level. - - This method produces a JSON text from a JavaScript value. - - When an object value is found, if the object contains a toJSON - method, its toJSON method will be called and the result will be - stringified. A toJSON method does not serialize: it returns the - value represented by the name/value pair that should be serialized, - or undefined if nothing should be serialized. The toJSON method - will be passed the key associated with the value, and this will be - bound to the value - - For example, this would serialize Dates as ISO strings. - - Date.prototype.toJSON = function (key) { - function f(n) { - // Format integers to have at least two digits. - return n < 10 ? '0' + n : n; - } - - return this.getUTCFullYear() + '-' + - f(this.getUTCMonth() + 1) + '-' + - f(this.getUTCDate()) + 'T' + - f(this.getUTCHours()) + ':' + - f(this.getUTCMinutes()) + ':' + - f(this.getUTCSeconds()) + 'Z'; - }; - - You can provide an optional replacer method. It will be passed the - key and value of each member, with this bound to the containing - object. The value that is returned from your method will be - serialized. If your method returns undefined, then the member will - be excluded from the serialization. - - If the replacer parameter is an array of strings, then it will be - used to select the members to be serialized. It filters the results - such that only members with keys listed in the replacer array are - stringified. - - Values that do not have JSON representations, such as undefined or - functions, will not be serialized. Such values in objects will be - dropped; in arrays they will be replaced with null. You can use - a replacer function to replace those with JSON values. - JSON.stringify(undefined) returns undefined. - - The optional space parameter produces a stringification of the - value that is filled with line breaks and indentation to make it - easier to read. - - If the space parameter is a non-empty string, then that string will - be used for indentation. If the space parameter is a number, then - the indentation will be that many spaces. - - Example: - - text = JSON.stringify(['e', {pluribus: 'unum'}]); - // text is '["e",{"pluribus":"unum"}]' - - - text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t'); - // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]' - - text = JSON.stringify([new Date()], function (key, value) { - return this[key] instanceof Date ? - 'Date(' + this[key] + ')' : value; - }); - // text is '["Date(---current time---)"]' - - - JSON.parse(text, reviver) - This method parses a JSON text to produce an object or array. - It can throw a SyntaxError exception. - - The optional reviver parameter is a function that can filter and - transform the results. It receives each of the keys and values, - and its return value is used instead of the original value. - If it returns what it received, then the structure is not modified. - If it returns undefined then the member is deleted. - - Example: - - // Parse the text. Values that look like ISO date strings will - // be converted to Date objects. - - myData = JSON.parse(text, function (key, value) { - var a; - if (typeof value === 'string') { - a = -/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value); - if (a) { - return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4], - +a[5], +a[6])); - } - } - return value; - }); - - myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) { - var d; - if (typeof value === 'string' && - value.slice(0, 5) === 'Date(' && - value.slice(-1) === ')') { - d = new Date(value.slice(5, -1)); - if (d) { - return d; - } - } - return value; - }); - - - This is a reference implementation. You are free to copy, modify, or - redistribute. -*/ - -/*jslint evil: true, regexp: true */ - -/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply, - call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours, - getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join, - lastIndex, length, parse, prototype, push, replace, slice, stringify, - test, toJSON, toString, valueOf -*/ - - -// Create a JSON object only if one does not already exist. We create the -// methods in a closure to avoid creating global variables. - - -function f(n) { - // Format integers to have at least two digits. - return n < 10 ? '0' + n : n; -} - -var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, - escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, - gap, - indent, - meta = { - // table of character substitutions - '\b': '\\b', - '\t': '\\t', - '\n': '\\n', - '\f': '\\f', - '\r': '\\r', - '"': '\\"', - '\\': '\\\\' - }, - rep; - - -function quote(string) { - - // If the string contains no control characters, no quote characters, and no - // backslash characters, then we can safely slap some quotes around it. - // Otherwise we must also replace the offending characters with safe escape - // sequences. - - escapable.lastIndex = 0; - return escapable.test(string) ? '"' + string.replace(escapable, function (a) { - var c = meta[a]; - return typeof c === 'string' - ? c - : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); - }) + '"' : '"' + string + '"'; -} - - -function str(key, holder) { - - // Produce a string from holder[key]. - - var i, // The loop counter. - k, // The member key. - v, // The member value. - length, - mind = gap, - partial, - value = holder[key], - isBigNumber = value != null && (value instanceof BigInt); - - // If the value has a toJSON method, call it to obtain a replacement value. - - if (value && typeof value === 'object' && - typeof value.toJSON === 'function') { - value = value.toJSON(key); - } - - // If we were called with a replacer function, then call the replacer to - // obtain a replacement value. - - if (typeof rep === 'function') { - value = rep.call(holder, key, value); - } - - // What happens next depends on the value's type. - - switch (typeof value) { - case 'string': - if (isBigNumber) { - return value; - } else { - return quote(value); - } - - case 'number': - - // JSON numbers must be finite. Encode non-finite numbers as null. - - return isFinite(value) ? String(value) : 'null'; - - case 'boolean': - // case 'null': - case 'bigint': - - // If the value is a boolean or null, convert it to a string. Note: - // typeof null does not produce 'null'. The case is included here in - // the remote chance that this gets fixed someday. - - return String(value); - - // If the type is 'object', we might be dealing with an object or an array or - // null. - - case 'object': - - // Due to a specification blunder in ECMAScript, typeof null is 'object', - // so watch out for that case. - - if (!value) { - return 'null'; - } - - // Make an array to hold the partial results of stringifying this object value. - - gap += indent; - partial = []; - - // Is the value an array? - - if (Object.prototype.toString.apply(value) === '[object Array]') { - - // The value is an array. Stringify every element. Use null as a placeholder - // for non-JSON values. - - length = value.length; - for (i = 0; i < length; i += 1) { - partial[i] = str(i, value) || 'null'; - } - - // Join all of the elements together, separated with commas, and wrap them in - // brackets. - - v = partial.length === 0 - ? '[]' - : gap - ? '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' - : '[' + partial.join(',') + ']'; - gap = mind; - return v; - } - - // If the replacer is an array, use it to select the members to be stringified. - - if (rep && typeof rep === 'object') { - length = rep.length; - for (i = 0; i < length; i += 1) { - if (typeof rep[i] === 'string') { - k = rep[i]; - v = str(k, value); - if (v) { - partial.push(quote(k) + (gap ? ': ' : ':') + v); - } - } - } - } else { - - // Otherwise, iterate through all of the keys in the object. - - Object.keys(value).forEach(function (k) { - var v = str(k, value); - if (v) { - partial.push(quote(k) + (gap ? ': ' : ':') + v); - } - }); - } - - // Join all of the member texts together, separated with commas, - // and wrap them in braces. - - v = partial.length === 0 - ? '{}' - : gap - ? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' - : '{' + partial.join(',') + '}'; - gap = mind; - return v; - } -} - -export default function (value, replacer, space) { - - // The stringify method takes a value and an optional replacer, and an optional - // space parameter, and returns a JSON text. The replacer can be a function - // that can replace values, or an array of strings that will select the keys. - // A default replacer method can be provided. Use of the space parameter can - // produce text that is more easily readable. - - var i; - gap = ''; - indent = ''; - - // If the space parameter is a number, make an indent string containing that - // many spaces. - - if (typeof space === 'number') { - for (i = 0; i < space; i += 1) { - indent += ' '; - } - - // If the space parameter is a string, it will be used as the indent string. - - } else if (typeof space === 'string') { - indent = space; - } - - // If there is a replacer, it must be a function or an array. - // Otherwise, throw an error. - - rep = replacer; - if (replacer && typeof replacer !== 'function' && - (typeof replacer !== 'object' || - typeof replacer.length !== 'number')) { - throw new Error('JSON.stringify'); - } - - // Make a fake root object containing our value under the key of ''. - // Return the result of stringifying the value. - - return str('', { - '': value - }); -}; \ No newline at end of file diff --git a/commons/json_bigint/src/main/module.json5 b/commons/json_bigint/src/main/module.json5 deleted file mode 100644 index 48937d1..0000000 --- a/commons/json_bigint/src/main/module.json5 +++ /dev/null @@ -1,11 +0,0 @@ -{ - "module": { - "name": "json_bigint", - "type": "har", - "deviceTypes": [ - "default", - "tablet", - "2in1" - ] - } -} diff --git a/commons/json_bigint/src/main/resources/base/element/string.json b/commons/json_bigint/src/main/resources/base/element/string.json deleted file mode 100644 index f51a9c8..0000000 --- a/commons/json_bigint/src/main/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "page_show", - "value": "page from package" - } - ] -} diff --git a/commons/json_bigint/src/main/resources/en_US/element/string.json b/commons/json_bigint/src/main/resources/en_US/element/string.json deleted file mode 100644 index f51a9c8..0000000 --- a/commons/json_bigint/src/main/resources/en_US/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "page_show", - "value": "page from package" - } - ] -} diff --git a/commons/json_bigint/src/main/resources/zh_CN/element/string.json b/commons/json_bigint/src/main/resources/zh_CN/element/string.json deleted file mode 100644 index f51a9c8..0000000 --- a/commons/json_bigint/src/main/resources/zh_CN/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "page_show", - "value": "page from package" - } - ] -} diff --git a/commons/json_bigint/src/test/List.test.ets b/commons/json_bigint/src/test/List.test.ets deleted file mode 100644 index bb5b5c3..0000000 --- a/commons/json_bigint/src/test/List.test.ets +++ /dev/null @@ -1,5 +0,0 @@ -import localUnitTest from './LocalUnit.test'; - -export default function testsuite() { - localUnitTest(); -} \ No newline at end of file diff --git a/commons/json_bigint/src/test/LocalUnit.test.ets b/commons/json_bigint/src/test/LocalUnit.test.ets deleted file mode 100644 index ad96173..0000000 --- a/commons/json_bigint/src/test/LocalUnit.test.ets +++ /dev/null @@ -1,43 +0,0 @@ -import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from '@ohos/hypium'; -import JsonBigInt from '../main/ets'; - -export default function localUnitTest() { - describe('localUnitTest', () => { - // Defines a test suite. Two parameters are supported: test suite name and test suite function. - beforeAll(() => { - // Presets an action, which is performed only once before all test cases of the test suite start. - // This API supports only one parameter: preset action function. - }); - beforeEach(() => { - // Presets an action, which is performed before each unit test case starts. - // The number of execution times is the same as the number of test cases defined by **it**. - // This API supports only one parameter: preset action function. - }); - afterEach(() => { - // Presets a clear action, which is performed after each unit test case ends. - // The number of execution times is the same as the number of test cases defined by **it**. - // This API supports only one parameter: clear action function. - }); - afterAll(() => { - // Presets a clear action, which is performed after all test cases of the test suite end. - // This API supports only one parameter: clear action function. - }); - it('assertContain', 0, () => { - // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. - // let a = 'abc'; - // let b = 'b'; - // // Defines a variety of assertion methods, which are used to declare expected boolean conditions. - // expect(a).assertContain(b); - // expect(a).assertEqual(a); - interface User { - id: number - name: string - } - - const str = `{ "id": 9489483248329483284, "name": "jack" }` - const obj = JsonBigInt.parse(str) as User - expect(obj.id.toString()).assertEqual('9489483248329483284') - expect(obj.name).assertEqual('jack') - }); - }); -} \ No newline at end of file diff --git a/products/phone/oh-package-lock.json5 b/products/phone/oh-package-lock.json5 index 4945218..a1bd742 100644 --- a/products/phone/oh-package-lock.json5 +++ b/products/phone/oh-package-lock.json5 @@ -9,8 +9,7 @@ "@itcast/home@../../features/home": "@itcast/home@../../features/home", "@itcast/project@../../features/project": "@itcast/project@../../features/project", "@itcast/interview@../../features/interview": "@itcast/interview@../../features/interview", - "@itcast/mine@../../features/mine": "@itcast/mine@../../features/mine", - "@ohmos/json-bigint@../../commons/json_bigint": "@ohmos/json-bigint@../../commons/json_bigint" + "@itcast/mine@../../features/mine": "@itcast/mine@../../features/mine" }, "packages": { "@itcast/basic@../../commons/basic": { @@ -58,12 +57,6 @@ "@itcast/home": "file:../../features/home", "@itcast/interview": "file:../../features/interview" } - }, - "@ohmos/json-bigint@../../commons/json_bigint": { - "name": "@ohmos/json-bigint", - "version": "1.0.0", - "resolved": "../../commons/json_bigint", - "registryType": "local" } } } \ No newline at end of file diff --git a/products/phone/oh-package.json5 b/products/phone/oh-package.json5 index be75c4b..b80831f 100644 --- a/products/phone/oh-package.json5 +++ b/products/phone/oh-package.json5 @@ -10,7 +10,6 @@ "@itcast/home": "file:../../features/home", "@itcast/project": "file:../../features/project", "@itcast/interview": "file:../../features/interview", - "@itcast/mine": "file:../../features/mine", - "@ohmos/json-bigint": "file:../../commons/json_bigint" + "@itcast/mine": "file:../../features/mine" } } \ No newline at end of file