@generaltranslation/compiler 0.0.0-alpha.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/LICENSE.md +105 -0
- package/README.md +274 -0
- package/dist/config.d.ts +25 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +6 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +68 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +132 -0
- package/dist/index.js.map +1 -0
- package/dist/passes/basePass.d.ts +4 -0
- package/dist/passes/basePass.d.ts.map +1 -0
- package/dist/passes/basePass.js +86 -0
- package/dist/passes/basePass.js.map +1 -0
- package/dist/passes/handleErrors.d.ts +13 -0
- package/dist/passes/handleErrors.d.ts.map +1 -0
- package/dist/passes/handleErrors.js +35 -0
- package/dist/passes/handleErrors.js.map +1 -0
- package/dist/processing/first-pass/processCallExpression.d.ts +12 -0
- package/dist/processing/first-pass/processCallExpression.d.ts.map +1 -0
- package/dist/processing/first-pass/processCallExpression.js +203 -0
- package/dist/processing/first-pass/processCallExpression.js.map +1 -0
- package/dist/processing/first-pass/processVariableDeclarator.d.ts +17 -0
- package/dist/processing/first-pass/processVariableDeclarator.d.ts.map +1 -0
- package/dist/processing/first-pass/processVariableDeclarator.js +22 -0
- package/dist/processing/first-pass/processVariableDeclarator.js.map +1 -0
- package/dist/processing/index.d.ts +15 -0
- package/dist/processing/index.d.ts.map +1 -0
- package/dist/processing/index.js +31 -0
- package/dist/processing/index.js.map +1 -0
- package/dist/processing/processArrowFunctionExpression.d.ts +9 -0
- package/dist/processing/processArrowFunctionExpression.d.ts.map +1 -0
- package/dist/processing/processArrowFunctionExpression.js +20 -0
- package/dist/processing/processArrowFunctionExpression.js.map +1 -0
- package/dist/processing/processAssignmentExpression.d.ts +9 -0
- package/dist/processing/processAssignmentExpression.d.ts.map +1 -0
- package/dist/processing/processAssignmentExpression.js +14 -0
- package/dist/processing/processAssignmentExpression.js.map +1 -0
- package/dist/processing/processCatchClause.d.ts +9 -0
- package/dist/processing/processCatchClause.d.ts.map +1 -0
- package/dist/processing/processCatchClause.js +20 -0
- package/dist/processing/processCatchClause.js.map +1 -0
- package/dist/processing/processClassDeclaration.d.ts +9 -0
- package/dist/processing/processClassDeclaration.d.ts.map +1 -0
- package/dist/processing/processClassDeclaration.js +20 -0
- package/dist/processing/processClassDeclaration.js.map +1 -0
- package/dist/processing/processClassMethod.d.ts +9 -0
- package/dist/processing/processClassMethod.d.ts.map +1 -0
- package/dist/processing/processClassMethod.js +21 -0
- package/dist/processing/processClassMethod.js.map +1 -0
- package/dist/processing/processClassPrivateMethod.d.ts +9 -0
- package/dist/processing/processClassPrivateMethod.d.ts.map +1 -0
- package/dist/processing/processClassPrivateMethod.js +21 -0
- package/dist/processing/processClassPrivateMethod.js.map +1 -0
- package/dist/processing/processForInStatement.d.ts +9 -0
- package/dist/processing/processForInStatement.d.ts.map +1 -0
- package/dist/processing/processForInStatement.js +20 -0
- package/dist/processing/processForInStatement.js.map +1 -0
- package/dist/processing/processForOfStatement.d.ts +9 -0
- package/dist/processing/processForOfStatement.d.ts.map +1 -0
- package/dist/processing/processForOfStatement.js +20 -0
- package/dist/processing/processForOfStatement.js.map +1 -0
- package/dist/processing/processFunctionDeclaration.d.ts +9 -0
- package/dist/processing/processFunctionDeclaration.d.ts.map +1 -0
- package/dist/processing/processFunctionDeclaration.js +22 -0
- package/dist/processing/processFunctionDeclaration.js.map +1 -0
- package/dist/processing/processFunctionExpression.d.ts +13 -0
- package/dist/processing/processFunctionExpression.d.ts.map +1 -0
- package/dist/processing/processFunctionExpression.js +28 -0
- package/dist/processing/processFunctionExpression.js.map +1 -0
- package/dist/processing/processImportDeclaration.d.ts +8 -0
- package/dist/processing/processImportDeclaration.d.ts.map +1 -0
- package/dist/processing/processImportDeclaration.js +13 -0
- package/dist/processing/processImportDeclaration.js.map +1 -0
- package/dist/processing/processObjectMethod.d.ts +10 -0
- package/dist/processing/processObjectMethod.d.ts.map +1 -0
- package/dist/processing/processObjectMethod.js +22 -0
- package/dist/processing/processObjectMethod.js.map +1 -0
- package/dist/processing/processProgram.d.ts +9 -0
- package/dist/processing/processProgram.d.ts.map +1 -0
- package/dist/processing/processProgram.js +17 -0
- package/dist/processing/processProgram.js.map +1 -0
- package/dist/processing/processScopeChange.d.ts +8 -0
- package/dist/processing/processScopeChange.d.ts.map +1 -0
- package/dist/processing/processScopeChange.js +17 -0
- package/dist/processing/processScopeChange.js.map +1 -0
- package/dist/processing/second-pass/processCallExpression.d.ts +8 -0
- package/dist/processing/second-pass/processCallExpression.d.ts.map +1 -0
- package/dist/processing/second-pass/processCallExpression.js +147 -0
- package/dist/processing/second-pass/processCallExpression.js.map +1 -0
- package/dist/processing/second-pass/processVariableDeclarator.d.ts +17 -0
- package/dist/processing/second-pass/processVariableDeclarator.d.ts.map +1 -0
- package/dist/processing/second-pass/processVariableDeclarator.js +24 -0
- package/dist/processing/second-pass/processVariableDeclarator.js.map +1 -0
- package/dist/state/ErrorTracker.d.ts +7 -0
- package/dist/state/ErrorTracker.d.ts.map +1 -0
- package/dist/state/ErrorTracker.js +19 -0
- package/dist/state/ErrorTracker.js.map +1 -0
- package/dist/state/Logger.d.ts +23 -0
- package/dist/state/Logger.d.ts.map +1 -0
- package/dist/state/Logger.js +56 -0
- package/dist/state/Logger.js.map +1 -0
- package/dist/state/ScopeTracker.d.ts +126 -0
- package/dist/state/ScopeTracker.d.ts.map +1 -0
- package/dist/state/ScopeTracker.js +212 -0
- package/dist/state/ScopeTracker.js.map +1 -0
- package/dist/state/StringCollector.d.ts +108 -0
- package/dist/state/StringCollector.d.ts.map +1 -0
- package/dist/state/StringCollector.js +159 -0
- package/dist/state/StringCollector.js.map +1 -0
- package/dist/state/types.d.ts +21 -0
- package/dist/state/types.d.ts.map +1 -0
- package/dist/state/types.js +3 -0
- package/dist/state/types.js.map +1 -0
- package/dist/state/utils/initializeState.d.ts +7 -0
- package/dist/state/utils/initializeState.d.ts.map +1 -0
- package/dist/state/utils/initializeState.js +30 -0
- package/dist/state/utils/initializeState.js.map +1 -0
- package/dist/transform/getTrackedVariable.d.ts +14 -0
- package/dist/transform/getTrackedVariable.d.ts.map +1 -0
- package/dist/transform/getTrackedVariable.js +42 -0
- package/dist/transform/getTrackedVariable.js.map +1 -0
- package/dist/transform/injection/callbacks/injectUseGTCallbackParameters.d.ts +8 -0
- package/dist/transform/injection/callbacks/injectUseGTCallbackParameters.d.ts.map +1 -0
- package/dist/transform/injection/callbacks/injectUseGTCallbackParameters.js +84 -0
- package/dist/transform/injection/callbacks/injectUseGTCallbackParameters.js.map +1 -0
- package/dist/transform/injection/callbacks/injectUseMessagesCallbackParameters.d.ts +7 -0
- package/dist/transform/injection/callbacks/injectUseMessagesCallbackParameters.d.ts.map +1 -0
- package/dist/transform/injection/callbacks/injectUseMessagesCallbackParameters.js +8 -0
- package/dist/transform/injection/callbacks/injectUseMessagesCallbackParameters.js.map +1 -0
- package/dist/transform/injection/callbacks/injectUseTranslationsCallbackParameters.d.ts +7 -0
- package/dist/transform/injection/callbacks/injectUseTranslationsCallbackParameters.d.ts.map +1 -0
- package/dist/transform/injection/callbacks/injectUseTranslationsCallbackParameters.js +8 -0
- package/dist/transform/injection/callbacks/injectUseTranslationsCallbackParameters.js.map +1 -0
- package/dist/transform/injection/injectCallbackDeclaratorFunctionParameters.d.ts +8 -0
- package/dist/transform/injection/injectCallbackDeclaratorFunctionParameters.d.ts.map +1 -0
- package/dist/transform/injection/injectCallbackDeclaratorFunctionParameters.js +160 -0
- package/dist/transform/injection/injectCallbackDeclaratorFunctionParameters.js.map +1 -0
- package/dist/transform/injection/injectTComponentParameters.d.ts +7 -0
- package/dist/transform/injection/injectTComponentParameters.d.ts.map +1 -0
- package/dist/transform/injection/injectTComponentParameters.js +69 -0
- package/dist/transform/injection/injectTComponentParameters.js.map +1 -0
- package/dist/transform/jsx-children/constructJsxChildren.d.ts +17 -0
- package/dist/transform/jsx-children/constructJsxChildren.d.ts.map +1 -0
- package/dist/transform/jsx-children/constructJsxChildren.js +387 -0
- package/dist/transform/jsx-children/constructJsxChildren.js.map +1 -0
- package/dist/transform/jsx-children/index.d.ts +2 -0
- package/dist/transform/jsx-children/index.d.ts.map +1 -0
- package/dist/transform/jsx-children/index.js +6 -0
- package/dist/transform/jsx-children/index.js.map +1 -0
- package/dist/transform/jsx-children/utils/getBranchComponentParameters.d.ts +6 -0
- package/dist/transform/jsx-children/utils/getBranchComponentParameters.d.ts.map +1 -0
- package/dist/transform/jsx-children/utils/getBranchComponentParameters.js +82 -0
- package/dist/transform/jsx-children/utils/getBranchComponentParameters.js.map +1 -0
- package/dist/transform/jsx-children/utils/getCalleeNameFromJsxExpressionParam.d.ts +10 -0
- package/dist/transform/jsx-children/utils/getCalleeNameFromJsxExpressionParam.d.ts.map +1 -0
- package/dist/transform/jsx-children/utils/getCalleeNameFromJsxExpressionParam.js +62 -0
- package/dist/transform/jsx-children/utils/getCalleeNameFromJsxExpressionParam.js.map +1 -0
- package/dist/transform/jsx-children/utils/id.d.ts +8 -0
- package/dist/transform/jsx-children/utils/id.d.ts.map +1 -0
- package/dist/transform/jsx-children/utils/id.js +19 -0
- package/dist/transform/jsx-children/utils/id.js.map +1 -0
- package/dist/transform/jsx-children/validation/validateChildrenElement.d.ts +6 -0
- package/dist/transform/jsx-children/validation/validateChildrenElement.d.ts.map +1 -0
- package/dist/transform/jsx-children/validation/validateChildrenElement.js +51 -0
- package/dist/transform/jsx-children/validation/validateChildrenElement.js.map +1 -0
- package/dist/transform/jsx-children/validation/validateChildrenFromArgs.d.ts +9 -0
- package/dist/transform/jsx-children/validation/validateChildrenFromArgs.d.ts.map +1 -0
- package/dist/transform/jsx-children/validation/validateChildrenFromArgs.js +57 -0
- package/dist/transform/jsx-children/validation/validateChildrenFromArgs.js.map +1 -0
- package/dist/transform/jsx-children/validation/validateIdentifier.d.ts +11 -0
- package/dist/transform/jsx-children/validation/validateIdentifier.d.ts.map +1 -0
- package/dist/transform/jsx-children/validation/validateIdentifier.js +45 -0
- package/dist/transform/jsx-children/validation/validateIdentifier.js.map +1 -0
- package/dist/transform/jsx-children/validation/validateJsxCall.d.ts +7 -0
- package/dist/transform/jsx-children/validation/validateJsxCall.d.ts.map +1 -0
- package/dist/transform/jsx-children/validation/validateJsxCall.js +30 -0
- package/dist/transform/jsx-children/validation/validateJsxCall.js.map +1 -0
- package/dist/transform/jsx-children/validation/validateNameFieldForVarComponent.d.ts +11 -0
- package/dist/transform/jsx-children/validation/validateNameFieldForVarComponent.d.ts.map +1 -0
- package/dist/transform/jsx-children/validation/validateNameFieldForVarComponent.js +65 -0
- package/dist/transform/jsx-children/validation/validateNameFieldForVarComponent.js.map +1 -0
- package/dist/transform/jsx-children/validation/validateStringLiteralPropertyFromArg.d.ts +9 -0
- package/dist/transform/jsx-children/validation/validateStringLiteralPropertyFromArg.d.ts.map +1 -0
- package/dist/transform/jsx-children/validation/validateStringLiteralPropertyFromArg.js +70 -0
- package/dist/transform/jsx-children/validation/validateStringLiteralPropertyFromArg.js.map +1 -0
- package/dist/transform/jsx-children/validation/validateTemplateLiteral.d.ts +9 -0
- package/dist/transform/jsx-children/validation/validateTemplateLiteral.d.ts.map +1 -0
- package/dist/transform/jsx-children/validation/validateTemplateLiteral.js +17 -0
- package/dist/transform/jsx-children/validation/validateTemplateLiteral.js.map +1 -0
- package/dist/transform/jsx-children/validation/validateUnaryExpression.d.ts +10 -0
- package/dist/transform/jsx-children/validation/validateUnaryExpression.d.ts.map +1 -0
- package/dist/transform/jsx-children/validation/validateUnaryExpression.js +65 -0
- package/dist/transform/jsx-children/validation/validateUnaryExpression.js.map +1 -0
- package/dist/transform/registration/callbacks/registerUseGTCallback.d.ts +7 -0
- package/dist/transform/registration/callbacks/registerUseGTCallback.d.ts.map +1 -0
- package/dist/transform/registration/callbacks/registerUseGTCallback.js +26 -0
- package/dist/transform/registration/callbacks/registerUseGTCallback.js.map +1 -0
- package/dist/transform/registration/callbacks/registerUseMessagesCallback.d.ts +7 -0
- package/dist/transform/registration/callbacks/registerUseMessagesCallback.d.ts.map +1 -0
- package/dist/transform/registration/callbacks/registerUseMessagesCallback.js +11 -0
- package/dist/transform/registration/callbacks/registerUseMessagesCallback.js.map +1 -0
- package/dist/transform/registration/callbacks/registerUseTranslationsCallback.d.ts +7 -0
- package/dist/transform/registration/callbacks/registerUseTranslationsCallback.d.ts.map +1 -0
- package/dist/transform/registration/callbacks/registerUseTranslationsCallback.js +11 -0
- package/dist/transform/registration/callbacks/registerUseTranslationsCallback.js.map +1 -0
- package/dist/transform/registration/registerTranslationComponent.d.ts +7 -0
- package/dist/transform/registration/registerTranslationComponent.d.ts.map +1 -0
- package/dist/transform/registration/registerTranslationComponent.js +16 -0
- package/dist/transform/registration/registerTranslationComponent.js.map +1 -0
- package/dist/transform/tracking/trackAssignmentExpression.d.ts +8 -0
- package/dist/transform/tracking/trackAssignmentExpression.d.ts.map +1 -0
- package/dist/transform/tracking/trackAssignmentExpression.js +71 -0
- package/dist/transform/tracking/trackAssignmentExpression.js.map +1 -0
- package/dist/transform/tracking/trackCatchClause.d.ts +8 -0
- package/dist/transform/tracking/trackCatchClause.d.ts.map +1 -0
- package/dist/transform/tracking/trackCatchClause.js +52 -0
- package/dist/transform/tracking/trackCatchClause.js.map +1 -0
- package/dist/transform/tracking/trackClassDeclaration.d.ts +8 -0
- package/dist/transform/tracking/trackClassDeclaration.d.ts.map +1 -0
- package/dist/transform/tracking/trackClassDeclaration.js +17 -0
- package/dist/transform/tracking/trackClassDeclaration.js.map +1 -0
- package/dist/transform/tracking/trackForDeclaration.d.ts +9 -0
- package/dist/transform/tracking/trackForDeclaration.d.ts.map +1 -0
- package/dist/transform/tracking/trackForDeclaration.js +57 -0
- package/dist/transform/tracking/trackForDeclaration.js.map +1 -0
- package/dist/transform/tracking/trackFunctionName.d.ts +9 -0
- package/dist/transform/tracking/trackFunctionName.d.ts.map +1 -0
- package/dist/transform/tracking/trackFunctionName.js +13 -0
- package/dist/transform/tracking/trackFunctionName.js.map +1 -0
- package/dist/transform/tracking/trackFunctionParams.d.ts +9 -0
- package/dist/transform/tracking/trackFunctionParams.d.ts.map +1 -0
- package/dist/transform/tracking/trackFunctionParams.js +58 -0
- package/dist/transform/tracking/trackFunctionParams.js.map +1 -0
- package/dist/transform/tracking/trackImportDeclaration.d.ts +9 -0
- package/dist/transform/tracking/trackImportDeclaration.d.ts.map +1 -0
- package/dist/transform/tracking/trackImportDeclaration.js +102 -0
- package/dist/transform/tracking/trackImportDeclaration.js.map +1 -0
- package/dist/transform/tracking/trackLabeledStatement.d.ts +8 -0
- package/dist/transform/tracking/trackLabeledStatement.d.ts.map +1 -0
- package/dist/transform/tracking/trackLabeledStatement.js +13 -0
- package/dist/transform/tracking/trackLabeledStatement.js.map +1 -0
- package/dist/transform/tracking/trackOverridingVariable.d.ts +6 -0
- package/dist/transform/tracking/trackOverridingVariable.d.ts.map +1 -0
- package/dist/transform/tracking/trackOverridingVariable.js +15 -0
- package/dist/transform/tracking/trackOverridingVariable.js.map +1 -0
- package/dist/transform/tracking/trackVariableDeclarator.d.ts +16 -0
- package/dist/transform/tracking/trackVariableDeclarator.d.ts.map +1 -0
- package/dist/transform/tracking/trackVariableDeclarator.js +108 -0
- package/dist/transform/tracking/trackVariableDeclarator.js.map +1 -0
- package/dist/transform/validation/validateTranslationComponentArgs.d.ts +21 -0
- package/dist/transform/validation/validateTranslationComponentArgs.d.ts.map +1 -0
- package/dist/transform/validation/validateTranslationComponentArgs.js +167 -0
- package/dist/transform/validation/validateTranslationComponentArgs.js.map +1 -0
- package/dist/utils/constants/gt/constants.d.ts +96 -0
- package/dist/utils/constants/gt/constants.d.ts.map +1 -0
- package/dist/utils/constants/gt/constants.js +115 -0
- package/dist/utils/constants/gt/constants.js.map +1 -0
- package/dist/utils/constants/gt/helpers.d.ts +73 -0
- package/dist/utils/constants/gt/helpers.d.ts.map +1 -0
- package/dist/utils/constants/gt/helpers.js +165 -0
- package/dist/utils/constants/gt/helpers.js.map +1 -0
- package/dist/utils/constants/other/constants.d.ts +26 -0
- package/dist/utils/constants/other/constants.d.ts.map +1 -0
- package/dist/utils/constants/other/constants.js +46 -0
- package/dist/utils/constants/other/constants.js.map +1 -0
- package/dist/utils/constants/other/helpers.d.ts +10 -0
- package/dist/utils/constants/other/helpers.d.ts.map +1 -0
- package/dist/utils/constants/other/helpers.js +18 -0
- package/dist/utils/constants/other/helpers.js.map +1 -0
- package/dist/utils/constants/react/constants.d.ts +32 -0
- package/dist/utils/constants/react/constants.d.ts.map +1 -0
- package/dist/utils/constants/react/constants.js +47 -0
- package/dist/utils/constants/react/constants.js.map +1 -0
- package/dist/utils/constants/react/helpers.d.ts +15 -0
- package/dist/utils/constants/react/helpers.d.ts.map +1 -0
- package/dist/utils/constants/react/helpers.js +26 -0
- package/dist/utils/constants/react/helpers.js.map +1 -0
- package/dist/utils/errors.d.ts +8 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +26 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/parsing/extractIdentifiersFromLVal.d.ts +6 -0
- package/dist/utils/parsing/extractIdentifiersFromLVal.d.ts.map +1 -0
- package/dist/utils/parsing/extractIdentifiersFromLVal.js +106 -0
- package/dist/utils/parsing/extractIdentifiersFromLVal.js.map +1 -0
- package/dist/utils/parsing/getAttr.d.ts +6 -0
- package/dist/utils/parsing/getAttr.d.ts.map +1 -0
- package/dist/utils/parsing/getAttr.js +71 -0
- package/dist/utils/parsing/getAttr.js.map +1 -0
- package/dist/utils/parsing/getCalleeNameFromExpression.d.ts +10 -0
- package/dist/utils/parsing/getCalleeNameFromExpression.d.ts.map +1 -0
- package/dist/utils/parsing/getCalleeNameFromExpression.js +69 -0
- package/dist/utils/parsing/getCalleeNameFromExpression.js.map +1 -0
- package/dist/utils/parsing/getCalleeNameFromExpressionWrapper.d.ts +9 -0
- package/dist/utils/parsing/getCalleeNameFromExpressionWrapper.d.ts.map +1 -0
- package/dist/utils/parsing/getCalleeNameFromExpressionWrapper.js +14 -0
- package/dist/utils/parsing/getCalleeNameFromExpressionWrapper.js.map +1 -0
- package/dist/utils/parsing/getObjectPropertyFromObjectExpression.d.ts +6 -0
- package/dist/utils/parsing/getObjectPropertyFromObjectExpression.d.ts.map +1 -0
- package/dist/utils/parsing/getObjectPropertyFromObjectExpression.js +55 -0
- package/dist/utils/parsing/getObjectPropertyFromObjectExpression.js.map +1 -0
- package/dist/utils/parsing/getStringLiteralFromExpression.d.ts +6 -0
- package/dist/utils/parsing/getStringLiteralFromExpression.d.ts.map +1 -0
- package/dist/utils/parsing/getStringLiteralFromExpression.js +53 -0
- package/dist/utils/parsing/getStringLiteralFromExpression.js.map +1 -0
- package/dist/utils/parsing/getStringLiteralFromObjectExpression.d.ts +6 -0
- package/dist/utils/parsing/getStringLiteralFromObjectExpression.d.ts.map +1 -0
- package/dist/utils/parsing/getStringLiteralFromObjectExpression.js +64 -0
- package/dist/utils/parsing/getStringLiteralFromObjectExpression.js.map +1 -0
- package/dist/utils/parsing/getTag.d.ts +8 -0
- package/dist/utils/parsing/getTag.d.ts.map +1 -0
- package/dist/utils/parsing/getTag.js +81 -0
- package/dist/utils/parsing/getTag.js.map +1 -0
- package/dist/utils/validation/validateChildrenFromObjectExpression.d.ts +10 -0
- package/dist/utils/validation/validateChildrenFromObjectExpression.d.ts.map +1 -0
- package/dist/utils/validation/validateChildrenFromObjectExpression.js +61 -0
- package/dist/utils/validation/validateChildrenFromObjectExpression.js.map +1 -0
- package/dist/utils/validation/validateExpressionIsStringLiteral.d.ts +8 -0
- package/dist/utils/validation/validateExpressionIsStringLiteral.d.ts.map +1 -0
- package/dist/utils/validation/validateExpressionIsStringLiteral.js +52 -0
- package/dist/utils/validation/validateExpressionIsStringLiteral.js.map +1 -0
- package/dist/utils/validation/validateTranslationFunctionCallback.d.ts +28 -0
- package/dist/utils/validation/validateTranslationFunctionCallback.d.ts.map +1 -0
- package/dist/utils/validation/validateTranslationFunctionCallback.js +154 -0
- package/dist/utils/validation/validateTranslationFunctionCallback.js.map +1 -0
- package/package.json +60 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# Functional Source License, Version 1.1, ALv2 Future License
|
|
2
|
+
|
|
3
|
+
## Abbreviation
|
|
4
|
+
|
|
5
|
+
FSL-1.1-ALv2
|
|
6
|
+
|
|
7
|
+
## Notice
|
|
8
|
+
|
|
9
|
+
Copyright 2025 General Translation, Inc.
|
|
10
|
+
|
|
11
|
+
## Terms and Conditions
|
|
12
|
+
|
|
13
|
+
### Licensor ("We")
|
|
14
|
+
|
|
15
|
+
The party offering the Software under these Terms and Conditions.
|
|
16
|
+
|
|
17
|
+
### The Software
|
|
18
|
+
|
|
19
|
+
The "Software" is each version of the software that we make available under
|
|
20
|
+
these Terms and Conditions, as indicated by our inclusion of these Terms and
|
|
21
|
+
Conditions with the Software.
|
|
22
|
+
|
|
23
|
+
### License Grant
|
|
24
|
+
|
|
25
|
+
Subject to your compliance with this License Grant and the Patents,
|
|
26
|
+
Redistribution and Trademark clauses below, we hereby grant you the right to
|
|
27
|
+
use, copy, modify, create derivative works, publicly perform, publicly display
|
|
28
|
+
and redistribute the Software for any Permitted Purpose identified below.
|
|
29
|
+
|
|
30
|
+
### Permitted Purpose
|
|
31
|
+
|
|
32
|
+
A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
|
|
33
|
+
means making the Software available to others in a commercial product or
|
|
34
|
+
service that:
|
|
35
|
+
|
|
36
|
+
1. substitutes for the Software;
|
|
37
|
+
|
|
38
|
+
2. substitutes for any other product or service we offer using the Software
|
|
39
|
+
that exists as of the date we make the Software available; or
|
|
40
|
+
|
|
41
|
+
3. offers the same or substantially similar functionality as the Software.
|
|
42
|
+
|
|
43
|
+
Permitted Purposes specifically include using the Software:
|
|
44
|
+
|
|
45
|
+
1. for your internal use and access;
|
|
46
|
+
|
|
47
|
+
2. for non-commercial education;
|
|
48
|
+
|
|
49
|
+
3. for non-commercial research; and
|
|
50
|
+
|
|
51
|
+
4. in connection with professional services that you provide to a licensee
|
|
52
|
+
using the Software in accordance with these Terms and Conditions.
|
|
53
|
+
|
|
54
|
+
### Patents
|
|
55
|
+
|
|
56
|
+
To the extent your use for a Permitted Purpose would necessarily infringe our
|
|
57
|
+
patents, the license grant above includes a license under our patents. If you
|
|
58
|
+
make a claim against any party that the Software infringes or contributes to
|
|
59
|
+
the infringement of any patent, then your patent license to the Software ends
|
|
60
|
+
immediately.
|
|
61
|
+
|
|
62
|
+
### Redistribution
|
|
63
|
+
|
|
64
|
+
The Terms and Conditions apply to all copies, modifications and derivatives of
|
|
65
|
+
the Software.
|
|
66
|
+
|
|
67
|
+
If you redistribute any copies, modifications or derivatives of the Software,
|
|
68
|
+
you must include a copy of or a link to these Terms and Conditions and not
|
|
69
|
+
remove any copyright notices provided in or with the Software.
|
|
70
|
+
|
|
71
|
+
### Disclaimer
|
|
72
|
+
|
|
73
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
|
|
74
|
+
IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
|
|
75
|
+
PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
|
|
76
|
+
|
|
77
|
+
IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
|
|
78
|
+
SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
|
|
79
|
+
EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
|
|
80
|
+
|
|
81
|
+
### Trademarks
|
|
82
|
+
|
|
83
|
+
Except for displaying the License Details and identifying us as the origin of
|
|
84
|
+
the Software, you have no right under these Terms and Conditions to use our
|
|
85
|
+
trademarks, trade names, service marks or product names.
|
|
86
|
+
|
|
87
|
+
## Grant of Future License
|
|
88
|
+
|
|
89
|
+
We hereby irrevocably grant you an additional license to use the Software under
|
|
90
|
+
the Apache License, Version 2.0 that is effective on the second anniversary of
|
|
91
|
+
the date we make the Software available. On or after that date, you may use the
|
|
92
|
+
Software under the Apache License, Version 2.0, in which case the following
|
|
93
|
+
will apply:
|
|
94
|
+
|
|
95
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
96
|
+
this file except in compliance with the License.
|
|
97
|
+
|
|
98
|
+
You may obtain a copy of the License at
|
|
99
|
+
|
|
100
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
101
|
+
|
|
102
|
+
Unless required by applicable law or agreed to in writing, software distributed
|
|
103
|
+
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
104
|
+
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
105
|
+
specific language governing permissions and limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
# GT Compiler
|
|
2
|
+
|
|
3
|
+
A universal plugin for compile-time optimization of GT translation components that works across webpack, Vite, Rollup, and other bundlers.
|
|
4
|
+
|
|
5
|
+
## What It Does
|
|
6
|
+
|
|
7
|
+
This plugin performs two main functions during the build process:
|
|
8
|
+
|
|
9
|
+
### 1. Dynamic Content Detection
|
|
10
|
+
|
|
11
|
+
Detects and prevents invalid usage patterns in GT translation components:
|
|
12
|
+
|
|
13
|
+
#### JSX Component Violations:
|
|
14
|
+
|
|
15
|
+
```jsx
|
|
16
|
+
// ❌ Unwrapped expressions
|
|
17
|
+
<T>Hello {userName}!</T>
|
|
18
|
+
<T>You have {count} {count === 1 ? 'item' : 'items'}</T>
|
|
19
|
+
<T>{greeting} world</T>
|
|
20
|
+
|
|
21
|
+
// ❌ Mixed content
|
|
22
|
+
<T>Price: <span>{price}</span></T>
|
|
23
|
+
|
|
24
|
+
// ✅ Correct usage
|
|
25
|
+
<T>Hello <Var>{userName}</Var>!</T>
|
|
26
|
+
<T>You have <Num>{count}</Num> <Plural n={count} one="item" other="items" />!</T>
|
|
27
|
+
<T><Var>{greeting}</Var> world</T>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
#### Function Call Violations:
|
|
31
|
+
|
|
32
|
+
```js
|
|
33
|
+
// ❌ Template literals
|
|
34
|
+
const msg = t(`Hello ${name}!`);
|
|
35
|
+
const error = t(`Error: ${code} - ${message}`);
|
|
36
|
+
|
|
37
|
+
// ❌ String concatenation
|
|
38
|
+
const welcome = t('Welcome ' + username);
|
|
39
|
+
const path = t('Go to ' + destination + ' page');
|
|
40
|
+
|
|
41
|
+
// ❌ Dynamic expressions
|
|
42
|
+
const dynamic = t(isError ? errorMsg : successMsg);
|
|
43
|
+
|
|
44
|
+
// ✅ Correct usage
|
|
45
|
+
const msg = t('Hello world!');
|
|
46
|
+
const welcome = t('Welcome to our app');
|
|
47
|
+
const error = t('Something went wrong', { context: 'error' });
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### 2. Compile-Time Hash Generation
|
|
51
|
+
|
|
52
|
+
Pre-computes translation keys at build time for better performance:
|
|
53
|
+
|
|
54
|
+
- Generates stable hashes for `<T>` components and `t()` function calls
|
|
55
|
+
- Injects hash attributes (`_hash`) into components
|
|
56
|
+
- Creates content arrays for translation functions
|
|
57
|
+
|
|
58
|
+
## Installation
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
npm install @generaltranslation/compiler
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Usage
|
|
65
|
+
|
|
66
|
+
### With Next.js (Automatic)
|
|
67
|
+
|
|
68
|
+
If you're using `gt-next`, the plugin is automatically configured for you. No additional setup required!
|
|
69
|
+
|
|
70
|
+
### With Webpack (Manual)
|
|
71
|
+
|
|
72
|
+
```js
|
|
73
|
+
// webpack.config.js
|
|
74
|
+
const gtCompiler = require('@generaltranslation/compiler/webpack');
|
|
75
|
+
|
|
76
|
+
module.exports = {
|
|
77
|
+
plugins: [
|
|
78
|
+
gtCompiler({
|
|
79
|
+
compileTimeHash: true,
|
|
80
|
+
logLevel: 'warn',
|
|
81
|
+
}),
|
|
82
|
+
],
|
|
83
|
+
};
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### With Vite
|
|
87
|
+
|
|
88
|
+
```js
|
|
89
|
+
// vite.config.js
|
|
90
|
+
import { defineConfig } from 'vite';
|
|
91
|
+
import gtCompiler from '@generaltranslation/compiler/vite';
|
|
92
|
+
|
|
93
|
+
export default defineConfig({
|
|
94
|
+
plugins: [
|
|
95
|
+
gtCompiler({
|
|
96
|
+
compileTimeHash: true,
|
|
97
|
+
logLevel: 'warn',
|
|
98
|
+
}),
|
|
99
|
+
],
|
|
100
|
+
});
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### With Rollup
|
|
104
|
+
|
|
105
|
+
```js
|
|
106
|
+
// rollup.config.js
|
|
107
|
+
import gtCompiler from '@generaltranslation/compiler/rollup';
|
|
108
|
+
|
|
109
|
+
export default {
|
|
110
|
+
plugins: [
|
|
111
|
+
gtCompiler({
|
|
112
|
+
compileTimeHash: true,
|
|
113
|
+
logLevel: 'warn',
|
|
114
|
+
}),
|
|
115
|
+
],
|
|
116
|
+
};
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### With esbuild
|
|
120
|
+
|
|
121
|
+
```js
|
|
122
|
+
// esbuild.config.js
|
|
123
|
+
const { build } = require('esbuild');
|
|
124
|
+
const gtCompiler = require('@generaltranslation/compiler/esbuild');
|
|
125
|
+
|
|
126
|
+
build({
|
|
127
|
+
plugins: [
|
|
128
|
+
gtCompiler({
|
|
129
|
+
compileTimeHash: true,
|
|
130
|
+
logLevel: 'warn',
|
|
131
|
+
}),
|
|
132
|
+
],
|
|
133
|
+
};
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Configuration Options
|
|
137
|
+
|
|
138
|
+
```typescript
|
|
139
|
+
interface GTCompilerOptions {
|
|
140
|
+
/** Control warning output */
|
|
141
|
+
logLevel?: 'silent' | 'error' | 'warn' | 'info' | 'debug';
|
|
142
|
+
|
|
143
|
+
/** Enable hash generation at compile time */
|
|
144
|
+
compileTimeHash?: boolean;
|
|
145
|
+
|
|
146
|
+
/** Skip dynamic content validation */
|
|
147
|
+
disableBuildChecks?: boolean;
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## How It Works
|
|
152
|
+
|
|
153
|
+
The plugin uses the [unplugin](https://unplugin.unjs.io/) framework to provide universal bundler support. It analyzes your code using Babel's parser and transformer to:
|
|
154
|
+
|
|
155
|
+
### String Collector
|
|
156
|
+
|
|
157
|
+
Manages translation content across the two-pass transformation:
|
|
158
|
+
|
|
159
|
+
- **Pass 1**: Collects translation strings, JSX content, and hash data
|
|
160
|
+
- **Pass 2**: Injects collected data back into `useGT()`/`getGT()` calls
|
|
161
|
+
- Associates content with function calls using deterministic counter IDs
|
|
162
|
+
- Supports multiple `t()` calls per translation function
|
|
163
|
+
|
|
164
|
+
### Scope Tracker
|
|
165
|
+
|
|
166
|
+
Handles variable scoping and import tracking:
|
|
167
|
+
|
|
168
|
+
- Tracks `useGT`/`getGT` variable assignments across nested scopes
|
|
169
|
+
- Manages variable shadowing (`const t = useGT()` in different scopes)
|
|
170
|
+
- Maps component names to their original GT imports (`T`, `Var`, etc.)
|
|
171
|
+
- Handles both named imports and namespace imports (`GT.T`)
|
|
172
|
+
|
|
173
|
+
### AST Traversal
|
|
174
|
+
|
|
175
|
+
Converts JSX components into sanitized hash-able objects:
|
|
176
|
+
|
|
177
|
+
- Recursively processes JSX elements and their children
|
|
178
|
+
- Identifies GT components vs regular HTML elements
|
|
179
|
+
- Extracts content from `Branch`/`Plural` component attributes
|
|
180
|
+
- Generates stable hash representations for consistent builds
|
|
181
|
+
|
|
182
|
+
## Two-Pass Traversal System
|
|
183
|
+
|
|
184
|
+
The plugin uses a two-pass approach to handle the circular dependency between translation functions and their usage:
|
|
185
|
+
|
|
186
|
+
### Pass 1: Collection
|
|
187
|
+
|
|
188
|
+
- **Discover translation functions**: Find `useGT()` and `getGT()` calls, assign unique counter IDs
|
|
189
|
+
- **Track variable assignments**: Follow `const t = useGT()` patterns using scope tracker
|
|
190
|
+
- **Collect content**: Gather `t()` calls and `<T>` components, associate with counter IDs
|
|
191
|
+
- **Generate hashes**: Calculate stable hashes for JSX content using AST traversal
|
|
192
|
+
- **Validate usage**: Check for dynamic content violations and report errors
|
|
193
|
+
|
|
194
|
+
### Pass 2: Transformation
|
|
195
|
+
|
|
196
|
+
- **Inject content arrays**: Add collected `t()` strings to `useGT()`/`getGT()` calls
|
|
197
|
+
- **Add hash attributes**: Insert `_hash` props into `<T>` components
|
|
198
|
+
- **Preserve order**: Use the same counter sequence to match content with functions
|
|
199
|
+
|
|
200
|
+
This approach solves the "chicken-and-egg" problem: we need to know what `t()` calls exist before we can inject content into the `useGT()` function that creates `t()`.
|
|
201
|
+
|
|
202
|
+
## Supported Bundlers
|
|
203
|
+
|
|
204
|
+
This plugin works with:
|
|
205
|
+
|
|
206
|
+
- ✅ **Webpack** 4, 5
|
|
207
|
+
- ✅ **Vite** 2, 3, 4, 5
|
|
208
|
+
- ✅ **Rollup** 2, 3, 4
|
|
209
|
+
- ✅ **esbuild** 0.15+
|
|
210
|
+
- ✅ **Next.js** (via gt-next)
|
|
211
|
+
- ✅ **Nuxt** (via unplugin auto-detection)
|
|
212
|
+
|
|
213
|
+
## Components Tracked
|
|
214
|
+
|
|
215
|
+
- **Translation**: `T`
|
|
216
|
+
- **Variables**: `Var`, `Num`, `Currency`, `DateTime`
|
|
217
|
+
- **Branching**: `Branch`, `Plural`
|
|
218
|
+
- **Functions**: `useGT()`, `getGT()`, and their callbacks
|
|
219
|
+
|
|
220
|
+
## Development Status
|
|
221
|
+
|
|
222
|
+
Files ported from Rust SWC plugin with their implementation status:
|
|
223
|
+
|
|
224
|
+
### ✅ Core Framework
|
|
225
|
+
|
|
226
|
+
- **`src/index.ts`** - Universal plugin entry point with unplugin integration
|
|
227
|
+
|
|
228
|
+
### ✅ Completed (with tests)
|
|
229
|
+
|
|
230
|
+
- **`src/visitor/analysis.ts`** - Component identification functions
|
|
231
|
+
- **`src/visitor/string-collector.ts`** - Two-pass transformation system
|
|
232
|
+
- **`src/logging.ts`** - Logger implementation
|
|
233
|
+
- **`src/visitor/errors.ts`** - Error message creation
|
|
234
|
+
|
|
235
|
+
### 🚧 Implemented (needs integration)
|
|
236
|
+
|
|
237
|
+
- **`src/visitor/scope-tracker.ts`** - Scope tracking and variable management
|
|
238
|
+
- **`src/visitor/import-tracker.ts`** - Import tracking and component resolution
|
|
239
|
+
|
|
240
|
+
### ❌ Not Yet Implemented
|
|
241
|
+
|
|
242
|
+
- **`src/ast/traversal.ts`** - JSX to sanitized objects conversion
|
|
243
|
+
- **`src/ast/utilities.ts`** - AST utility functions
|
|
244
|
+
- **`src/hash.ts`** - Hash generation utilities
|
|
245
|
+
- **`src/whitespace.ts`** - Whitespace handling utilities
|
|
246
|
+
- **`src/visitor/transform.ts`** - Main transformation logic
|
|
247
|
+
- **`src/visitor/jsx-utils.ts`** - JSX processing utilities
|
|
248
|
+
- **`src/visitor/expr-utils.ts`** - Expression analysis utilities
|
|
249
|
+
|
|
250
|
+
## Contributing
|
|
251
|
+
|
|
252
|
+
This plugin is part of the General Translation ecosystem. The transformation logic is gradually being ported from the existing Rust SWC plugin to provide broader bundler support.
|
|
253
|
+
|
|
254
|
+
### Test Files Structure
|
|
255
|
+
|
|
256
|
+
```
|
|
257
|
+
src/
|
|
258
|
+
├── __tests__/
|
|
259
|
+
│ ├── index.test.ts (unplugin integration tests)
|
|
260
|
+
├── visitor/
|
|
261
|
+
│ └── __tests__/
|
|
262
|
+
│ ├── string-collector.test.ts ✅
|
|
263
|
+
│ ├── analysis.test.ts (pending)
|
|
264
|
+
│ ├── scope-tracker.test.ts (pending)
|
|
265
|
+
│ └── import-tracker.test.ts (pending)
|
|
266
|
+
├── logging.test.ts (pending)
|
|
267
|
+
└── ast/
|
|
268
|
+
└── __tests__/
|
|
269
|
+
└── traversal.test.ts (pending)
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
## License
|
|
273
|
+
|
|
274
|
+
MIT - General Translation, Inc.
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration types for the GT Babel plugin
|
|
3
|
+
*/
|
|
4
|
+
export type LogLevel = 'silent' | 'error' | 'warn' | 'info' | 'debug';
|
|
5
|
+
/**
|
|
6
|
+
* Plugin configuration options (from babel config)
|
|
7
|
+
*/
|
|
8
|
+
export interface PluginConfig {
|
|
9
|
+
/** Log level for the plugin */
|
|
10
|
+
logLevel?: LogLevel;
|
|
11
|
+
/** Enable compile-time hash generation */
|
|
12
|
+
compileTimeHash?: boolean;
|
|
13
|
+
/** Disable dynamic content validation checks */
|
|
14
|
+
disableBuildChecks?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Internal plugin settings (processed config)
|
|
18
|
+
*/
|
|
19
|
+
export interface PluginSettings {
|
|
20
|
+
logLevel: LogLevel;
|
|
21
|
+
compileTimeHash: boolean;
|
|
22
|
+
disableBuildChecks: boolean;
|
|
23
|
+
filename?: string;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAEtE;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,+BAA+B;IAC/B,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,0CAA0C;IAC1C,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,gDAAgD;IAChD,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,QAAQ,CAAC;IACnB,eAAe,EAAE,OAAO,CAAC;IACzB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";AAAA;;GAEG"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { PluginConfig } from './config';
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* First Pass:
|
|
5
|
+
* - Collect + calculate all data
|
|
6
|
+
* - Check for violations
|
|
7
|
+
* - "Register" - collect data to inject
|
|
8
|
+
* - "Track" - track a function call/variable assignment
|
|
9
|
+
*
|
|
10
|
+
* Second Pass:
|
|
11
|
+
* - Inject all data
|
|
12
|
+
*
|
|
13
|
+
* Architecture:
|
|
14
|
+
*
|
|
15
|
+
* Babel functions:
|
|
16
|
+
* - 1-to-1 relationship with processing functions
|
|
17
|
+
* - Handle (1) enter/exit scope (2) invoking processing function
|
|
18
|
+
* - ex) JSXElement()
|
|
19
|
+
*
|
|
20
|
+
* Processing functions:
|
|
21
|
+
* - Are dependent on the pass, so they have three categories: (1) first pass, (2) second pass, (3) shared/general
|
|
22
|
+
* - Invoke transformation functions and utility functions
|
|
23
|
+
* - ex) processJSXElement()
|
|
24
|
+
* - Has the following file structure:
|
|
25
|
+
* + processing
|
|
26
|
+
* | sharedProcessingFunction.ts
|
|
27
|
+
* | + first-pass
|
|
28
|
+
* | | firstPassProcessingFunction.ts
|
|
29
|
+
* | + second-pass
|
|
30
|
+
* | | secondPassProcessingFunction.ts
|
|
31
|
+
*
|
|
32
|
+
* Transformation functions:
|
|
33
|
+
* - Are AGNOSTIC to pass number
|
|
34
|
+
* - MUST be stateful in some way
|
|
35
|
+
* - ex) trackImportDeclaration()
|
|
36
|
+
*
|
|
37
|
+
* Utility functions:
|
|
38
|
+
* - Are AGNOSTIC to pass number
|
|
39
|
+
* - Are stateless
|
|
40
|
+
* - ex) extractIdentifiersFromLVal()
|
|
41
|
+
*
|
|
42
|
+
* State:
|
|
43
|
+
* - Includes classes for tracking state
|
|
44
|
+
*
|
|
45
|
+
* Currently no support for:
|
|
46
|
+
* - namespaces and and modules
|
|
47
|
+
*/
|
|
48
|
+
/**
|
|
49
|
+
* GT Universal Plugin Options
|
|
50
|
+
*/
|
|
51
|
+
export interface GTUnpluginOptions extends PluginConfig {
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* GT Universal Plugin - Main entry point
|
|
55
|
+
*
|
|
56
|
+
* Universal plugin for compile-time optimization of GT translation components
|
|
57
|
+
* that works across webpack, Vite, Rollup, and other bundlers.
|
|
58
|
+
*
|
|
59
|
+
* First pass: construct all information. no replacements, lest we lose our the monkey patching
|
|
60
|
+
* Second pass: inject all information (hashes, messages, etc.)
|
|
61
|
+
*/
|
|
62
|
+
declare const gtUnplugin: import("unplugin").UnpluginInstance<GTUnpluginOptions | undefined, boolean>;
|
|
63
|
+
export default gtUnplugin;
|
|
64
|
+
export declare const webpack: (options?: GTUnpluginOptions | undefined) => import("unplugin").WebpackPluginInstance;
|
|
65
|
+
export declare const vite: (options?: GTUnpluginOptions | undefined) => import("vite").Plugin<any> | import("vite").Plugin<any>[];
|
|
66
|
+
export declare const rollup: (options?: GTUnpluginOptions | undefined) => import("rollup").Plugin<any> | import("rollup").Plugin<any>[];
|
|
67
|
+
export declare const esbuild: (options?: GTUnpluginOptions | undefined) => import("unplugin").EsbuildPlugin;
|
|
68
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAcxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH;;GAEG;AACH,MAAM,WAAW,iBAAkB,SAAQ,YAAY;CAEtD;AAED;;;;;;;;GAQG;AACH,QAAA,MAAM,UAAU,6EAgFf,CAAC;AAGF,eAAe,UAAU,CAAC;AAC1B,eAAO,MAAM,OAAO,uFAAqB,CAAC;AAC1C,eAAO,MAAM,IAAI,wGAAkB,CAAC;AACpC,eAAO,MAAM,MAAM,4GAAoB,CAAC;AACxC,eAAO,MAAM,OAAO,+EAAqB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.esbuild = exports.rollup = exports.vite = exports.webpack = void 0;
|
|
40
|
+
const unplugin_1 = require("unplugin");
|
|
41
|
+
const parser = __importStar(require("@babel/parser"));
|
|
42
|
+
const generator_1 = __importDefault(require("@babel/generator"));
|
|
43
|
+
const traverse_1 = __importDefault(require("@babel/traverse"));
|
|
44
|
+
// Import transformation functions
|
|
45
|
+
const processCallExpression_1 = require("./processing/first-pass/processCallExpression");
|
|
46
|
+
const processCallExpression_2 = require("./processing/second-pass/processCallExpression");
|
|
47
|
+
const basePass_1 = require("./passes/basePass");
|
|
48
|
+
const handleErrors_1 = require("./passes/handleErrors");
|
|
49
|
+
const processVariableDeclarator_1 = require("./processing/first-pass/processVariableDeclarator");
|
|
50
|
+
const processVariableDeclarator_2 = require("./processing/second-pass/processVariableDeclarator");
|
|
51
|
+
const handleErrors_2 = require("./passes/handleErrors");
|
|
52
|
+
const initializeState_1 = require("./state/utils/initializeState");
|
|
53
|
+
/**
|
|
54
|
+
* GT Universal Plugin - Main entry point
|
|
55
|
+
*
|
|
56
|
+
* Universal plugin for compile-time optimization of GT translation components
|
|
57
|
+
* that works across webpack, Vite, Rollup, and other bundlers.
|
|
58
|
+
*
|
|
59
|
+
* First pass: construct all information. no replacements, lest we lose our the monkey patching
|
|
60
|
+
* Second pass: inject all information (hashes, messages, etc.)
|
|
61
|
+
*/
|
|
62
|
+
const gtUnplugin = (0, unplugin_1.createUnplugin)((options = {}) => {
|
|
63
|
+
return {
|
|
64
|
+
name: '@generaltranslation/GT_PLUGIN',
|
|
65
|
+
transformInclude(id) {
|
|
66
|
+
// Only transform TSX and JSX files
|
|
67
|
+
return (id.endsWith('.tsx') ||
|
|
68
|
+
id.endsWith('.jsx') ||
|
|
69
|
+
id.endsWith('.ts') ||
|
|
70
|
+
id.endsWith('.js'));
|
|
71
|
+
},
|
|
72
|
+
transform(code, id) {
|
|
73
|
+
// Initialize processing state
|
|
74
|
+
const state = (0, initializeState_1.initializeState)(options, id);
|
|
75
|
+
try {
|
|
76
|
+
// Skip transformation if not needed
|
|
77
|
+
if (state.settings.disableBuildChecks &&
|
|
78
|
+
!state.settings.compileTimeHash) {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
// Parse the code into AST
|
|
82
|
+
const ast = parser.parse(code, {
|
|
83
|
+
sourceType: 'module',
|
|
84
|
+
plugins: ['jsx', 'typescript', 'decorators-legacy'],
|
|
85
|
+
allowImportExportEverywhere: true,
|
|
86
|
+
allowReturnOutsideFunction: true,
|
|
87
|
+
});
|
|
88
|
+
// PASS 1: Collection phase - collect translation data without transforming
|
|
89
|
+
(0, traverse_1.default)(ast, Object.assign(Object.assign({}, (0, basePass_1.basePass)(state)), {
|
|
90
|
+
// const gt = useGT();
|
|
91
|
+
CallExpression: (0, processCallExpression_1.processCallExpression)(state),
|
|
92
|
+
// let T = ...
|
|
93
|
+
VariableDeclarator: (0, processVariableDeclarator_1.processVariableDeclarator)(state) }));
|
|
94
|
+
// Handle errors
|
|
95
|
+
if ((0, handleErrors_1.handleErrors)(state)) {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
// PASS 2: Transformation phase - apply collected data to generate hashes and content arrays
|
|
99
|
+
if (!state.stringCollector.hasContent()) {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
// Complete second-pass traversal matching Rust Fold trait
|
|
103
|
+
(0, traverse_1.default)(ast, Object.assign(Object.assign({}, (0, basePass_1.basePass)(state)), {
|
|
104
|
+
// const gt = useGT();
|
|
105
|
+
CallExpression: (0, processCallExpression_2.processCallExpression)(state),
|
|
106
|
+
// let T = ...
|
|
107
|
+
VariableDeclarator: (0, processVariableDeclarator_2.processVariableDeclarator)(state) }));
|
|
108
|
+
// Generate code
|
|
109
|
+
return (0, generator_1.default)(ast, {
|
|
110
|
+
retainLines: true,
|
|
111
|
+
compact: false,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
// If the error is an instance of InvalidLibraryUsageError, throw it
|
|
116
|
+
if (error instanceof handleErrors_2.InvalidLibraryUsageError) {
|
|
117
|
+
throw error;
|
|
118
|
+
}
|
|
119
|
+
// Otherwise, log the error
|
|
120
|
+
state.logger.logError(`Error processing ${id}: ${error}`);
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
});
|
|
126
|
+
// Export the unplugin with different bundler integrations
|
|
127
|
+
exports.default = gtUnplugin;
|
|
128
|
+
exports.webpack = gtUnplugin.webpack;
|
|
129
|
+
exports.vite = gtUnplugin.vite;
|
|
130
|
+
exports.rollup = gtUnplugin.rollup;
|
|
131
|
+
exports.esbuild = gtUnplugin.esbuild;
|
|
132
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"basePass.d.ts","sourceRoot":"","sources":["../../src/passes/basePass.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGlD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,cAAc,GAAG,eAAe,CAoD/D"}
|